public static List <aim_dotnet.Annotation> LoadAimAnnotations(IEnumerable <string> studyInstanceUids)
        {
            var annotationList = new List <aim_dotnet.Annotation>();

            using (var dcmModel = new aim_dotnet.DcmModel())
            {
                foreach (var studyInstanceUID in studyInstanceUids)
                {
                    var aimInstanceDictionary = GetAimInstanceDictionaryForStudy(studyInstanceUID);
                    var annotationSopsInfo    = aimInstanceDictionary[studyInstanceUID];
                    if (annotationSopsInfo == null)
                    {
                        continue;
                    }

                    foreach (var information in annotationSopsInfo)
                    {
                        try
                        {
                            annotationList.AddRange(dcmModel.ReadAnnotationsFromFile(information.InstanceFileName));
                        }
                        catch (Exception ex)
                        {
                            Platform.Log(LogLevel.Error, ex);
                        }
                    }
                }
            }

            return(annotationList.Count > 0 ? annotationList : null);
        }
        private void OnDisplaySetChanged(object sender, DisplaySetChangedEventArgs e)
        {
            if (e.NewDisplaySet != null && e.NewDisplaySet.Visible)
            {
                var uidCnt = new Dictionary <string, int>();
                foreach (var img in e.NewDisplaySet.PresentationImages)
                {
                    var imageSopPrivider = img as IImageSopProvider;
                    if (imageSopPrivider != null)
                    {
                        var studyInstanceUID = imageSopPrivider.ImageSop.StudyInstanceUid;
                        if (uidCnt.ContainsKey(studyInstanceUID))
                        {
                            uidCnt[studyInstanceUID] += 1;
                        }
                        else
                        {
                            uidCnt[studyInstanceUID] = 1;
                        }
                    }
                }

                var annotationList = new List <aim_dotnet.Annotation>();
                var dcmModel       = new aim_dotnet.DcmModel();
                foreach (var studyInstanceUID in uidCnt.Keys)
                {
                    InitializeAnnotationList(studyInstanceUID);
                    var annotationSopsInfo = _annotationDictionary[studyInstanceUID];
                    if (annotationSopsInfo == null)
                    {
                        continue;
                    }

                    foreach (var information in annotationSopsInfo)
                    {
                        try
                        {
                            annotationList.AddRange(dcmModel.ReadAnnotationsFromFile(information.InstanceFileName));
                        }
                        catch (Exception ex)
                        {
                            Platform.Log(LogLevel.Error, ex);
                        }
                    }
                }

                foreach (var annotation in annotationList)
                {
                    foreach (var img in e.NewDisplaySet.PresentationImages)
                    {
                        AimHelpers.ReadGraphicsFromAnnotation(annotation, img);
                    }
                }
            }
        }
        public static List<aim_dotnet.Annotation> LoadAimAnnotations(IEnumerable<string> studyInstanceUids)
        {
            var annotationList = new List<aim_dotnet.Annotation>();
            using (var dcmModel = new aim_dotnet.DcmModel())
            {
                foreach (var studyInstanceUID in studyInstanceUids)
                {
                    var aimInstanceDictionary = GetAimInstanceDictionaryForStudy(studyInstanceUID);
                    var annotationSopsInfo = aimInstanceDictionary[studyInstanceUID];
                    if (annotationSopsInfo == null)
                        continue;

                    foreach (var information in annotationSopsInfo)
                    {
                        try
                        {
                            annotationList.AddRange(dcmModel.ReadAnnotationsFromFile(information.InstanceFileName));
                        }
                        catch (Exception ex)
                        {
                            Platform.Log(LogLevel.Error, ex);
                        }
                    }
                }
            }

            return annotationList.Count > 0 ? annotationList : null;
        }
Ejemplo n.º 4
0
        private void OnDisplaySetChanged(object sender, DisplaySetChangedEventArgs e)
        {
            // toDO - init annotation dictionary here!
            Console.WriteLine("OnDisplaySetChanged");

            // TODO - add/remove DisplaySet.PresentationImages.ItemAdded event handlers

            if (e.NewDisplaySet != null && e.NewDisplaySet.Visible)
            {
                Dictionary <string, int> uidCnt = new Dictionary <string, int>();
                foreach (IPresentationImage img in e.NewDisplaySet.PresentationImages)
                {
                    IImageSopProvider imageSopPrivider = img as IImageSopProvider;
                    if (imageSopPrivider != null)
                    {
                        string studyInstanceUID = imageSopPrivider.ImageSop.StudyInstanceUid;
                        if (uidCnt.ContainsKey(studyInstanceUID))
                        {
                            uidCnt[studyInstanceUID] += 1;
                        }
                        else
                        {
                            uidCnt[studyInstanceUID] = 1;
                        }
                    }
                }

                // 1. Init annotation objects
                List <aim_dotnet.Annotation> annotationList = new List <aim_dotnet.Annotation>();
                aim_dotnet.DcmModel          dcmModel       = new aim_dotnet.DcmModel();
                foreach (string studyInstanceUID in uidCnt.Keys)
                {
                    InitializeAnnotationList(studyInstanceUID);
                    List <AimSopInstanceInformation> annotationSopsInfo = _annotationDictionary[studyInstanceUID];
                    if (annotationSopsInfo == null)
                    {
                        continue;
                    }

                    foreach (AimSopInstanceInformation information in annotationSopsInfo)
                    {
                        try
                        {
                            annotationList.AddRange(dcmModel.ReadAnnotationsFromFile(information.InstanceFileName));
                        }
                        catch (Exception ex)
                        {
                            Platform.Log(LogLevel.Error, ex);
                        }
                    }
                }

                // 2. put markup on the images
                foreach (aim_dotnet.Annotation annotation in annotationList)
                {
                    foreach (IPresentationImage img in e.NewDisplaySet.PresentationImages)
                    {
                        AimHelpers.ReadGraphicsFromAnnotation(annotation, img);
                    }
                }
            }
        }
        private void OnDisplaySetChanged(object sender, DisplaySetChangedEventArgs e)
        {
            if (e.NewDisplaySet != null && e.NewDisplaySet.Visible)
            {
                var uidCnt = new Dictionary<string, int>();
                foreach (var img in e.NewDisplaySet.PresentationImages)
                {
                    var imageSopPrivider = img as IImageSopProvider;
                    if (imageSopPrivider != null)
                    {
                        var studyInstanceUID = imageSopPrivider.ImageSop.StudyInstanceUid;
                        if (uidCnt.ContainsKey(studyInstanceUID))
                            uidCnt[studyInstanceUID] += 1;
                        else
                            uidCnt[studyInstanceUID] = 1;
                    }
                }

                var annotationList = new List<aim_dotnet.Annotation>();
                var dcmModel = new aim_dotnet.DcmModel();
                foreach (var studyInstanceUID in uidCnt.Keys)
                {
                    InitializeAnnotationList(studyInstanceUID);
                    var annotationSopsInfo = _annotationDictionary[studyInstanceUID];
                    if (annotationSopsInfo == null)
                        continue;

                    foreach (var information in annotationSopsInfo)
                    {
                        try
                        {
                            annotationList.AddRange(dcmModel.ReadAnnotationsFromFile(information.InstanceFileName));
                        }
                        catch (Exception ex)
                        {
                            Platform.Log(LogLevel.Error, ex);
                        }
                    }
                }

                foreach (var annotation in annotationList)
                {
                    foreach (var img in e.NewDisplaySet.PresentationImages)
                    {
                        AimHelpers.ReadGraphicsFromAnnotation(annotation, img);
                    }
                }
            }
        }
		private void OnDisplaySetChanged(object sender, DisplaySetChangedEventArgs e)
		{
			// toDO - init annotation dictionary here!
			Console.WriteLine("OnDisplaySetChanged");

			// TODO - add/remove DisplaySet.PresentationImages.ItemAdded event handlers

			if (e.NewDisplaySet != null && e.NewDisplaySet.Visible)
			{
				Dictionary<string, int> uidCnt = new Dictionary<string, int>();
				foreach (IPresentationImage img in e.NewDisplaySet.PresentationImages)
				{
					IImageSopProvider imageSopPrivider = img as IImageSopProvider;
					if (imageSopPrivider != null)
					{
						string studyInstanceUID = imageSopPrivider.ImageSop.StudyInstanceUid;
						if (uidCnt.ContainsKey(studyInstanceUID))
							uidCnt[studyInstanceUID] += 1;
						else
							uidCnt[studyInstanceUID] = 1;
					}
				}

				// 1. Init annotation objects
				List<aim_dotnet.Annotation> annotationList = new List<aim_dotnet.Annotation>();
				aim_dotnet.DcmModel dcmModel = new aim_dotnet.DcmModel();
				foreach (string studyInstanceUID in uidCnt.Keys)
				{
					InitializeAnnotationList(studyInstanceUID);
					List<AimSopInstanceInformation> annotationSopsInfo = _annotationDictionary[studyInstanceUID];
					if (annotationSopsInfo == null)
						continue;

					foreach (AimSopInstanceInformation information in annotationSopsInfo)
					{
						try
						{
							annotationList.AddRange(dcmModel.ReadAnnotationsFromFile(information.InstanceFileName));
						}
						catch (Exception ex)
						{
							Platform.Log(LogLevel.Error, ex);
						}
					}
				}

				// 2. put markup on the images
				foreach (aim_dotnet.Annotation annotation in annotationList)
				{
					foreach (IPresentationImage img in e.NewDisplaySet.PresentationImages)
					{
						AimHelpers.ReadGraphicsFromAnnotation(annotation, img);
					}
				}
			}
		}