'Declaration Public Class DicomSeriesManager
public class DicomSeriesManager
public __gc class DicomSeriesManager
public ref class DicomSeriesManager
Вот C#/VB.NET код, который демонстрирует, как вывести информацию о DICOM-сериях для указанных DICOM-файлов.
''' <summary> ''' Prints information about DICOM series to the console. ''' </summary> ''' <param name="dir">The directory path.</param> Public Shared Sub PrintDicomSeriesInformation(dir As String) ' create the DICOM series manager Dim manager As New Vintasoft.Imaging.Metadata.DicomSeriesManager() manager.Images = New Vintasoft.Imaging.ImageCollection() ' get names of DICOM files in file directory Dim dicomFilePaths As String() = System.IO.Directory.GetFiles(dir, "*.dcm", System.IO.SearchOption.AllDirectories) ' add DICOM files to the DICOM series manager For Each dicomFilePath As String In dicomFilePaths manager.Images.Add(dicomFilePath) Next ' get patient identifiers from DICOM files Dim patientIdentifiers As System.Collections.Generic.IList(Of String) = manager.GetPatientIdentifiers() ' for each patient identifier For Each patientIdentifier As String In patientIdentifiers ' get patient metadata Dim patientMetadata As Vintasoft.Imaging.Metadata.DicomPageMetadata = manager.GetPatientMetadata(patientIdentifier) ' print patient information System.Console.WriteLine("Patient Name: {0}", GetValueAsString(patientMetadata, Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDataElementId.PatientName)) System.Console.WriteLine("Patient Birth Date: {0}", GetValueAsString(patientMetadata, Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDataElementId.PatientBirthDate)) ' get studies identifiers for patient Dim studyIdentifiers As System.Collections.Generic.IList(Of String) = manager.GetStudyIdentifiers(patientIdentifier) ' print the studies count for patient System.Console.WriteLine("Study Count: {0}", studyIdentifiers.Count) ' for each study identifier For Each studyIdentifier As String In studyIdentifiers ' get the study metadata Dim studyMetadata As Vintasoft.Imaging.Metadata.DicomPageMetadata = manager.GetStudyMetadata(studyIdentifier) ' print study information System.Console.WriteLine(vbTab & "Study Date: {0}", GetValueAsString(studyMetadata, Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDataElementId.StudyDate)) System.Console.WriteLine(vbTab & "Study Time: {0}", GetValueAsString(studyMetadata, Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDataElementId.StudyTime)) System.Console.WriteLine(vbTab & "Study Description: {0}", GetValueAsString(studyMetadata, Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDataElementId.StudyDescription)) System.Console.WriteLine(vbTab & "Modality: {0}", GetValueAsString(studyMetadata, Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDataElementId.Modality)) ' get series identifiers for the study Dim seriesIdentifiers As System.Collections.Generic.IList(Of String) = manager.GetSeriesIdentifiers(studyIdentifier) ' print the series count for the study System.Console.WriteLine(vbTab & "Series Count: {0}", seriesIdentifiers.Count) ' for each series identifier For Each seriesIdentifier As String In seriesIdentifiers ' get series metadata Dim seriesMetadata As Vintasoft.Imaging.Metadata.DicomPageMetadata = manager.GetSeriesMetadata(seriesIdentifier) ' print series information System.Console.WriteLine(vbTab & vbTab & "Series Description: {0}", GetValueAsString(seriesMetadata, Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDataElementId.SeriesDescription)) System.Console.WriteLine(vbTab & vbTab & "Series Date: {0}", GetValueAsString(seriesMetadata, Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDataElementId.SeriesDate)) System.Console.WriteLine(vbTab & vbTab & "Series Time: {0}", GetValueAsString(seriesMetadata, Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDataElementId.SeriesTime)) ' get images for the series Dim images As Vintasoft.Imaging.VintasoftImage() = manager.GetSeriesImages(seriesIdentifier) ' print the image count in the series System.Console.WriteLine(vbTab & vbTab & vbTab & "Image Count: {0}", images.Length) Next Next Next End Sub ''' <summary> ''' Returns the DICOM metadata value as a string. ''' </summary> ''' <param name="pageMetadata">The DICOM page metadata.</param> ''' <param name="id">The DICOM data element identifier.</param> ''' <returns> ''' The string with DICOM metadata value. ''' </returns> Private Shared Function GetValueAsString(pageMetadata As Vintasoft.Imaging.Metadata.DicomPageMetadata, id As Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDataElementId) As String ' get metadata node Dim node As Vintasoft.Imaging.Metadata.DicomDataElementMetadata = pageMetadata.FindChildNode(id) ' if metadata node exists If node IsNot Nothing AndAlso node.Value IsNot Nothing Then If TypeOf node.Value Is Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomUid Then Dim uid As Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomUid = DirectCast(node.Value, Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomUid) Return uid.Value ElseIf TypeOf node.Value Is Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDateTime Then Dim dateTime As Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDateTime = DirectCast(node.Value, Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDateTime) Return dateTime.LocalDateTime.ToString() Else Return System.Convert.ToString(node.Value) End If End If Return Nothing End Function ' This code example produces the following output: ' Patient Name: AGECANONIX Patient Birth Date: Study Count: 1 Study Date: 01.12.2003 0:00:00 Study Time: 12:00:00 Study Description: Specials^1CoronaryCTA_with_spiral _CTA_pre Modality: CT Series Count: 1 Series Description: CorCTA w/c 1.0 B20f Series Date: 01.12.2003 0:00:00 Series Time: 12:00:00 Image Count: 10 Patient Name: CEREBRIX Patient Birth Date: 01.04.1935 0:00:00 Study Count: 2 Study Date: 20.07.2007 0:00:00 Study Time: 08:13:35.9680000 Study Description: Neuro^Crane Modality: MR Series Count: 1 Series Description: t1_mpr3D_ns_sag_gd Series Date: 20.07.2007 0:00:00 Series Time: 08:59:10.3750000 Image Count: 15 Study Date: 03.08.2007 0:00:00 Study Time: 16:42:32.1090000 Study Description: PET^PETCT_CTplusFET_LM_Brain (Adult) Modality: PT Series Count: 1 Series Description: dynamic recon 3x10min Volume (Corrected) Series Date: 03.08.2007 0:00:00 Series Time: 16:53:56 Image Count: 10 Patient Name: RATIB^OSMAN Patient Birth Date: 25.06.1955 0:00:00 Study Count: 1 Study Date: 30.09.2004 0:00:00 Study Time: 11:56:15.5930000 Study Description: Cardiac^1CTA_CORONARY_ARTERIES_lowHR_TESTBOLUS (Adult) Modality: CT Series Count: 1 Series Description: CorCTALow 2.0 B25f 0-95% Series Date: 30.09.2004 0:00:00 Series Time: 14:28:38.4680000 Image Count: 25
/// <summary> /// Prints information about DICOM series to the console. /// </summary> /// <param name="dir">The directory path.</param> public static void PrintDicomSeriesInformation(string dir) { // create the DICOM series manager Vintasoft.Imaging.Metadata.DicomSeriesManager manager = new Vintasoft.Imaging.Metadata.DicomSeriesManager(); manager.Images = new Vintasoft.Imaging.ImageCollection(); // get names of DICOM files in file directory string[] dicomFilePaths = System.IO.Directory.GetFiles(dir, "*.dcm", System.IO.SearchOption.AllDirectories); // add DICOM files to the DICOM series manager foreach (string dicomFilePath in dicomFilePaths) manager.Images.Add(dicomFilePath); // get patient identifiers from DICOM files System.Collections.Generic.IList<string> patientIdentifiers = manager.GetPatientIdentifiers(); // for each patient identifier foreach (string patientIdentifier in patientIdentifiers) { // get patient metadata Vintasoft.Imaging.Metadata.DicomPageMetadata patientMetadata = manager.GetPatientMetadata(patientIdentifier); // print patient information System.Console.WriteLine("Patient Name: {0}", GetValueAsString(patientMetadata, Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDataElementId.PatientName)); System.Console.WriteLine("Patient Birth Date: {0}", GetValueAsString(patientMetadata, Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDataElementId.PatientBirthDate)); // get studies identifiers for patient System.Collections.Generic.IList<string> studyIdentifiers = manager.GetStudyIdentifiers(patientIdentifier); // print the studies count for patient System.Console.WriteLine("Study Count: {0}", studyIdentifiers.Count); // for each study identifier foreach (string studyIdentifier in studyIdentifiers) { // get the study metadata Vintasoft.Imaging.Metadata.DicomPageMetadata studyMetadata = manager.GetStudyMetadata(studyIdentifier); // print study information System.Console.WriteLine("\tStudy Date: {0}", GetValueAsString(studyMetadata, Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDataElementId.StudyDate)); System.Console.WriteLine("\tStudy Time: {0}", GetValueAsString(studyMetadata, Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDataElementId.StudyTime)); System.Console.WriteLine("\tStudy Description: {0}", GetValueAsString(studyMetadata, Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDataElementId.StudyDescription)); System.Console.WriteLine("\tModality: {0}", GetValueAsString(studyMetadata, Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDataElementId.Modality)); // get series identifiers for the study System.Collections.Generic.IList<string> seriesIdentifiers = manager.GetSeriesIdentifiers(studyIdentifier); // print the series count for the study System.Console.WriteLine("\tSeries Count: {0}", seriesIdentifiers.Count); // for each series identifier foreach (string seriesIdentifier in seriesIdentifiers) { // get series metadata Vintasoft.Imaging.Metadata.DicomPageMetadata seriesMetadata = manager.GetSeriesMetadata(seriesIdentifier); // print series information System.Console.WriteLine("\t\tSeries Description: {0}", GetValueAsString(seriesMetadata, Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDataElementId.SeriesDescription)); System.Console.WriteLine("\t\tSeries Date: {0}", GetValueAsString(seriesMetadata, Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDataElementId.SeriesDate)); System.Console.WriteLine("\t\tSeries Time: {0}", GetValueAsString(seriesMetadata, Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDataElementId.SeriesTime)); // get images for the series Vintasoft.Imaging.VintasoftImage[] images = manager.GetSeriesImages(seriesIdentifier); // print the image count in the series System.Console.WriteLine("\t\t\tImage Count: {0}", images.Length); } } } } /// <summary> /// Returns the DICOM metadata value as a string. /// </summary> /// <param name="pageMetadata">The DICOM page metadata.</param> /// <param name="id">The DICOM data element identifier.</param> /// <returns> /// The string with DICOM metadata value. /// </returns> private static string GetValueAsString( Vintasoft.Imaging.Metadata.DicomPageMetadata pageMetadata, Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDataElementId id) { // get metadata node Vintasoft.Imaging.Metadata.DicomDataElementMetadata node = pageMetadata.FindChildNode(id); // if metadata node exists if (node != null && node.Value != null) { if (node.Value is Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomUid) { Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomUid uid = (Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomUid)node.Value; return uid.Value; } else if (node.Value is Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDateTime) { Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDateTime dateTime = (Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomDateTime)node.Value; return dateTime.LocalDateTime.ToString(); } else { return System.Convert.ToString(node.Value); } } return null; } /* This code example produces the following output: Patient Name: AGECANONIX Patient Birth Date: Study Count: 1 Study Date: 01.12.2003 0:00:00 Study Time: 12:00:00 Study Description: Specials^1CoronaryCTA_with_spiral _CTA_pre Modality: CT Series Count: 1 Series Description: CorCTA w/c 1.0 B20f Series Date: 01.12.2003 0:00:00 Series Time: 12:00:00 Image Count: 10 Patient Name: CEREBRIX Patient Birth Date: 01.04.1935 0:00:00 Study Count: 2 Study Date: 20.07.2007 0:00:00 Study Time: 08:13:35.9680000 Study Description: Neuro^Crane Modality: MR Series Count: 1 Series Description: t1_mpr3D_ns_sag_gd Series Date: 20.07.2007 0:00:00 Series Time: 08:59:10.3750000 Image Count: 15 Study Date: 03.08.2007 0:00:00 Study Time: 16:42:32.1090000 Study Description: PET^PETCT_CTplusFET_LM_Brain (Adult) Modality: PT Series Count: 1 Series Description: dynamic recon 3x10min Volume (Corrected) Series Date: 03.08.2007 0:00:00 Series Time: 16:53:56 Image Count: 10 Patient Name: RATIB^OSMAN Patient Birth Date: 25.06.1955 0:00:00 Study Count: 1 Study Date: 30.09.2004 0:00:00 Study Time: 11:56:15.5930000 Study Description: Cardiac^1CTA_CORONARY_ARTERIES_lowHR_TESTBOLUS (Adult) Modality: CT Series Count: 1 Series Description: CorCTALow 2.0 B25f 0-95% Series Date: 30.09.2004 0:00:00 Series Time: 14:28:38.4680000 Image Count: 25 */
System.Object
 Vintasoft.Imaging.Metadata.DicomSeriesManager
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5