public override List <IDisplaySet> CreateDisplaySets(Series series)
        {
            List <IDisplaySet> displaySets = new List <IDisplaySet>();

            if (IsValidPETFusionSeries(series))
            {
                var fuseableBaseSeries = new List <Series>(FindFuseableBaseSeries(series));
                if (fuseableBaseSeries.Count > 0)
                {
                    string error;
                    if (!CheckPETFusionSeries(series, out error))
                    {
                        // if there is an error with the PET series, avoid trying to generate the volume entirely
                        // instead, generate a placeholder series for each base series
                        foreach (var baseSeries in fuseableBaseSeries)
                        {
                            displaySets.Add(CreateFusionErrorDisplaySet(baseSeries, series, error));
                        }
                        return(displaySets);
                    }

                    var overlayFrames = GetFrames(series.Sops);
                    using (var fusionOverlayData = new FusionOverlayData(overlayFrames))
                    {
                        foreach (var baseSeries in fuseableBaseSeries)
                        {
                            if (!CheckBaseSeries(baseSeries, out error))
                            {
                                // if there is an error with a single base series, generate a placeholder series
                                displaySets.Add(CreateFusionErrorDisplaySet(baseSeries, series, error));
                                continue;
                            }

                            var descriptor = new PETFusionDisplaySetDescriptor(baseSeries.GetIdentifier(), series.GetIdentifier(), IsAttenuationCorrected(series.Sops[0]));
                            var displaySet = new DisplaySet(descriptor);
                            using (var sops = new DisposableList <Sop>(baseSeries.Sops.OfType <ImageSop>().Select(s => new ImageSop(new FusionSopDataSource(s.DataSource, _fusionType, overlayFrames)))))
                            {
                                foreach (var baseFrame in GetFrames(sops))
                                {
                                    using (var fusionOverlaySlice = fusionOverlayData.CreateOverlaySlice(baseFrame))
                                    {
                                        var fus = new FusionPresentationImage(baseFrame, fusionOverlaySlice);
                                        displaySet.PresentationImages.Add(fus);
                                    }
                                }
                            }
                            displaySet.PresentationImages.Sort();
                            displaySets.Add(displaySet);
                        }
                    }
                }
            }
            return(displaySets);
        }
Beispiel #2
0
        private static DisplaySet CreateFusionErrorDisplaySet(Series baseSeries, Series fusionSeries, string error)
        {
            // create a basic descriptor that's templated from the real PET fusion display descriptor
            var baseDescriptor = new PETFusionDisplaySetDescriptor(baseSeries.GetIdentifier(), fusionSeries.GetIdentifier(), IsAttenuationCorrected(fusionSeries.Sops[0]));
            var descriptor     = new BasicDisplaySetDescriptor {
                Description = baseDescriptor.Description, Name = baseDescriptor.Name, Number = baseDescriptor.Number, Uid = baseDescriptor.Uid
            };
            var displaySet = new DisplaySet(descriptor);

            displaySet.PresentationImages.Add(new ErrorPresentationImage(SR.MessageFusionError + Environment.NewLine + string.Format(SR.FormatReason, error)));
            return(displaySet);
        }
		public override List<IDisplaySet> CreateDisplaySets(Series series)
		{
			List<IDisplaySet> displaySets = new List<IDisplaySet>();
			if (IsValidPETFusionSeries(series))
			{
				var fuseableBaseSeries = new List<Series>(FindFuseableBaseSeries(series));
				if (fuseableBaseSeries.Count > 0)
				{
					string error;
					if (!CheckPETFusionSeries(series, out error))
					{
						// if there is an error with the PET series, avoid trying to generate the volume entirely
						// instead, generate a placeholder series for each base series
						foreach (var baseSeries in fuseableBaseSeries)
							displaySets.Add(CreateFusionErrorDisplaySet(baseSeries, series, error));
						return displaySets;
					}

					using (var fusionOverlayData = new FusionOverlayData(GetFrames(series.Sops)))
					{
						foreach (var baseSeries in fuseableBaseSeries)
						{
							if (!CheckBaseSeries(baseSeries, out error))
							{
								// if there is an error with a single base series, generate a placeholder series
								displaySets.Add(CreateFusionErrorDisplaySet(baseSeries, series, error));
								continue;
							}

							var descriptor = new PETFusionDisplaySetDescriptor(baseSeries.GetIdentifier(), series.GetIdentifier(), IsAttenuationCorrected(series.Sops[0]));
							var displaySet = new DisplaySet(descriptor);
							foreach (var baseFrame in GetFrames(baseSeries.Sops))
							{
								using (var fusionOverlaySlice = fusionOverlayData.CreateOverlaySlice(baseFrame))
								{
									var fus = new FusionPresentationImage(baseFrame, fusionOverlaySlice);
									displaySet.PresentationImages.Add(fus);
								}
							}
							displaySet.PresentationImages.Sort();
							displaySets.Add(displaySet);
						}
					}
				}
			}
			return displaySets;
		}
		private static DisplaySet CreateFusionErrorDisplaySet(Series baseSeries, Series fusionSeries, string error)
		{
			// create a basic descriptor that's templated from the real PET fusion display descriptor
			var baseDescriptor = new PETFusionDisplaySetDescriptor(baseSeries.GetIdentifier(), fusionSeries.GetIdentifier(), IsAttenuationCorrected(fusionSeries.Sops[0]));
			var descriptor = new BasicDisplaySetDescriptor {Description = baseDescriptor.Description, Name = baseDescriptor.Name, Number = baseDescriptor.Number, Uid = baseDescriptor.Uid};
			var displaySet = new DisplaySet(descriptor);
			displaySet.PresentationImages.Add(new ErrorPresentationImage(SR.MessageFusionError + Environment.NewLine + string.Format(SR.FormatReason, error)));
			return displaySet;
		}
 /// <summary>
 /// Cloning constructor.
 /// </summary>
 /// <param name="source">The source object from which to clone.</param>
 /// <param name="context">The cloning context object.</param>
 protected PETFusionDisplaySetDescriptor(PETFusionDisplaySetDescriptor source, ICloningContext context) : base(source, context)
 {
     context.CloneFields(source, this);
 }
		/// <summary>
		/// Cloning constructor.
		/// </summary>
		/// <param name="source">The source object from which to clone.</param>
		/// <param name="context">The cloning context object.</param>
		protected PETFusionDisplaySetDescriptor(PETFusionDisplaySetDescriptor source, ICloningContext context) : base(source, context)
		{
			context.CloneFields(source, this);
		}