Компиляция кода OpenDicom, но не выполнение - PullRequest
0 голосов
/ 15 июня 2019

Я использую следующий код (измененный с здесь ) для чтения файла dicom:

using System;
using System.IO;
using openDicom.Registry;
using openDicom.File;
using openDicom.DataStructure;
using openDicom.DataStructure.DataSet;

class RnReadDicom{
    public static void Main(string[] args){
        string fileName = "33141578.dcm"; 
        AcrNemaFile file = null;
        file = new DicomFile (fileName, false);
        Sequence sq = file.GetJointDataSets ().GetJointSubsequences ();
        string tag = string.Empty;
        string description = string.Empty;
        foreach (DataElement element in sq){
            tag = element.Tag.ToString ();
            description = element.VR.Tag.GetDictionaryEntry ().Description;
            Console.WriteLine (tag + " " + description);
            }}}

Он компилируется с командой без ошибок:

$ mcs a.cs -r:opendicom-sharp.dll 

Однако я получаю следующую ошибку:

$ ./a.exe

Unhandled Exception:
openDicom.DicomException:
   No global data element dictionary available.Possibly it has not been initialized or is empty.
Context:
   Tag:            (0002,0000)
   StreamPosition: 136
StackTrace:
  at openDicom.Registry.DataElementDictionary.get_Global () [0x00024] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.DataStructure.Tag.get_IsUserDefined () [0x00000] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.DataStructure.Tag.GetDictionaryEntry () [0x00000] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.DataStructure.ValueRepresentation.IsImplicitBy (openDicom.DataStructure.Tag tag) [0x00000] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.DataStructure.ValueRepresentation.LoadFrom (System.IO.Stream stream, openDicom.DataStructure.Tag tag) [0x00007] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.DataStructure.DataSet.DataElement.LoadFrom (System.IO.Stream stream) [0x0001a] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.DataStructure.DataSet.DataElement..ctor (System.IO.Stream stream, openDicom.Encoding.TransferSyntax transferSyntax) [0x00018] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.File.FileMetaInformation.LoadFrom (System.IO.Stream stream) [0x00084] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.DataStructure.DataSet.Sequence..ctor (System.IO.Stream stream, openDicom.Encoding.TransferSyntax transferSyntax) [0x0002b] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.DataStructure.DataSet.DataSet..ctor (System.IO.Stream stream, openDicom.Encoding.TransferSyntax transferSyntax) [0x0000b] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.File.FileMetaInformation..ctor (System.IO.Stream stream) [0x0000b] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.File.DicomFile.LoadFrom (System.IO.Stream stream) [0x00000] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.File.AcrNemaFile..ctor (System.String fileName, System.Boolean useStrictDecoding) [0x00016] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.File.DicomFile..ctor (System.String fileName, System.Boolean useStrictDecoding) [0x00000] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at RnReadDicom.Main (System.String[] args) [0x00008] in <63cbc787fbe84ea38c195e7c8a430156>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: openDicom.DicomException:
   No global data element dictionary available.Possibly it has not been initialized or is empty.
Context:
   Tag:            (0002,0000)
   StreamPosition: 136
StackTrace:
  at openDicom.Registry.DataElementDictionary.get_Global () [0x00024] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.DataStructure.Tag.get_IsUserDefined () [0x00000] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.DataStructure.Tag.GetDictionaryEntry () [0x00000] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.DataStructure.ValueRepresentation.IsImplicitBy (openDicom.DataStructure.Tag tag) [0x00000] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.DataStructure.ValueRepresentation.LoadFrom (System.IO.Stream stream, openDicom.DataStructure.Tag tag) [0x00007] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.DataStructure.DataSet.DataElement.LoadFrom (System.IO.Stream stream) [0x0001a] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.DataStructure.DataSet.DataElement..ctor (System.IO.Stream stream, openDicom.Encoding.TransferSyntax transferSyntax) [0x00018] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.File.FileMetaInformation.LoadFrom (System.IO.Stream stream) [0x00084] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.DataStructure.DataSet.Sequence..ctor (System.IO.Stream stream, openDicom.Encoding.TransferSyntax transferSyntax) [0x0002b] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.DataStructure.DataSet.DataSet..ctor (System.IO.Stream stream, openDicom.Encoding.TransferSyntax transferSyntax) [0x0000b] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.File.FileMetaInformation..ctor (System.IO.Stream stream) [0x0000b] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.File.DicomFile.LoadFrom (System.IO.Stream stream) [0x00000] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.File.AcrNemaFile..ctor (System.String fileName, System.Boolean useStrictDecoding) [0x00016] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at openDicom.File.DicomFile..ctor (System.String fileName, System.Boolean useStrictDecoding) [0x00000] in <e05529c6d71349f8b90695ce2184bd4f>:0 
  at RnReadDicom.Main (System.String[] args) [0x00008] in <63cbc787fbe84ea38c195e7c8a430156>:0 

Где проблема и как ее можно решить?Спасибо за вашу помощь.

PS: Многие примеры изображений DICOM доступны по адресу: https://barre.nom.fr/medical/samples/

Редактировать: Работает после добавления следующего кода глобального словаря:

DataElementDictionary dataElementDictionary = new DataElementDictionary ();
UidDictionary uidDictionary = new UidDictionary ();
try {
    dataElementDictionary.LoadFrom ("dicom-elements-2007.dic",     DictionaryFileFormat.BinaryFile);
    uidDictionary.LoadFrom ("dicom-uids-2007.dic",                 DictionaryFileFormat.BinaryFile);
    }
catch (Exception dictionaryException) {
    Console.Error.WriteLine ("Problems processing dictionaries:\n" + dictionaryException);
    return;
    }

Однако он выводит только имена тегов, но без описания:

(0002,0000) Group Length
(0002,0001) File Meta Information Version
(0002,0002) Media Storage SOP Class UID
(0002,0003) Media Storage SOP Instance UID
(0002,0010) Transfer Syntax UID
(0002,0012) Implementation Class UID
(0002,0013) Implementation Version Name
(0008,0005) Specific Character Set
(0008,0008) Image Type
(0008,0016) SOP Class UID
(0008,0018) SOP Instance UID
(0008,0020) Study Date
(0008,0021) Series Date
(0008,0022) Acquisition Date
(0008,0023) Content Date
(0008,0030) Study Time
(0008,0031) Series Time
(0008,0032) Acquisition Time
(0008,0033) Content Time
(0008,0050) Accession Number
(0008,0060) Modality
(0008,0070) Manufacturer
(0008,0080) Institution Name
(0008,0081) Institution Address
(0008,0090) Referring Physician's Name
(0008,1010) Station Name
(0008,1030) Study Description
(0008,103E) Series Description
(0008,1090) Manufacturer's Model Name
(0008,1140) Referenced Image Sequence
(0008,2112) Source Image Sequence
(0009,0010) Unknown
(0010,0010) Patient's Name
(0010,0020) Patient ID
(0010,0030) Patient's Birth Date
(0010,0040) Patient's Sex
(0010,1010) Patient's Age
(0018,0010) Contrast/Bolus Agent
(0018,0015) Body Part Examined
(0018,0022) Scan Options
(0018,0050) Slice Thickness
(0018,0060) KVP
(0018,0090) Data Collection Diameter
(0018,1000) Device Serial Number
(0018,1020) Software Version(s)
(0018,1030) Protocol Name
(0018,1041) Contrast/Bolus Volume
(0018,1046) Contrast Flow Rate
(0018,1047) Contrast Flow Duration
(0018,1049) Contrast/Bolus Ingredient Concentration
(0018,1100) Reconstruction Diameter
(0018,1110) Distance Source to Detector
(0018,1111) Distance Source to Patient
(0018,1120) Gantry/Detector Tilt
(0018,1130) Table Height
(0018,1140) Rotation Direction
(0018,1150) Exposure Time
(0018,1151) X-ray Tube Current
(0018,1152) Exposure
(0018,1160) Filter Type
(0018,1170) Generator Power
(0018,1190) Focal Spot(s)
(0018,1200) Date of Last Calibration
(0018,1201) Time of Last Calibration
(0018,1210) Convolution Kernel
(0018,5100) Patient Position
(0019,0010) Unknown
(0019,10B0) Unknown
(0020,000D) Study Instance UID
(0020,000E) Series Instance UID
(0020,0010) Study ID
(0020,0011) Series Number
(0020,0012) Acquisition Number
(0020,0013) Instance Number
(0020,0032) Image Position (Patient)
(0020,0037) Image Orientation (Patient)
(0020,0052) Frame of Reference UID
(0020,1040) Position Reference Indicator
(0020,1041) Slice Location
(0020,4000) Image Comments
(0021,0010) Unknown
(0021,1011) Unknown
(0028,0002) Samples per Pixel
(0028,0004) Photometric Interpretation
(0028,0010) Rows
(0028,0011) Columns
(0028,0030) Pixel Spacing
(0028,0100) Bits Allocated
(0028,0101) Bits Stored
(0028,0102) High Bit
(0028,0103) Pixel Representation
(0028,1050) Window Center
(0028,1051) Window Width
(0028,1052) Rescale Intercept
(0028,1053) Rescale Slope
(0028,1055) Window Center & Width Explanation
(0029,0010) Unknown
(0029,0011) Unknown
(0029,1008) Unknown
(0029,1009) Unknown
(0029,1010) Unknown
(0029,1131) Unknown
(0029,1132) Unknown
(0029,1133) Unknown
(0029,1134) Unknown
(0032,1060) Requested Procedure Description
(0088,0140) Storage Media File-set UID
(7FE0,0010) Pixel Data

В чем заключается проблема в коде, что описания не печатаются?

...