For my project, I'm trying to read a radiation therapy plan (RT Plan) out of a DICOM file with fo-dicom 3.0.2 and C# in VS2015 (.Net 4.5.2).
Thanks to a DICOM Editor, I know the values stored in the different DicomTags
, but I cant get access to all Tag
s. e.g I'm trying to read the DicomTag.BeamDose
and I know the value isn't empty.
string storedfile = file_path + file_name;
Dicom.DicomFile file = Dicom.DicomFile.Open(@storedfile);
MessageBox.Show(file.Dataset.Get<string>(Dicom.DicomTag.BeamDose));
Running the code throws an exception with message:
(300a,0084) not found in dataset.
As mentioned I know it is there, but nested in items of sequences in sequences.
Next thing I tried is to analyse the sequence, where BeamDose
is stored.
var NewDataSet = file.Dataset.Get<Dicom.DicomItem>(Dicom.DicomTag.FractionGroupSequence);
But every next opportunity to handle this variable doesn't bring me to the next level of the sequence.
How should I read nested/child DICOM tags from sequences using fo-dicom?
The way you are looking for tag only look for it in outermost hierarchy of DICOM tag tree. To search the tag correctly, you need to access the correct sequence first, then the appropriate item and then you should search the tag in that item. DICOM Dataset may contain sequences (identified by VR SQ) those could be even further nested.
Following is copied from here:
The VR identified "SQ" shall be used for Data Elements with a Value consisting of a Sequence of zero or more Items, where each Item contains a set of Data Elements. SQ provides a flexible encoding scheme that may be used for simple structures of repeating sets of Data Elements, or the encoding of more complex Information Object Definitions often called folders. SQ Data Elements can also be used recursively to contain multi-level nested structures.
Items present in an SQ Data Element shall be an ordered set where each Item may be referenced by its ordinal position. Each Item shall be implicitly assigned an ordinal position starting with the value 1 for the first Item in the Sequence, and incremented by 1 with each subsequent Item. The last Item in the Sequence shall have an ordinal position equal to the number of Items in the Sequence.
Following is copied from here:
DICOM allows a dataset to contain other nested datasets, which are encoded as "sequences". The point of this structure is to allow repeating groups of data, so whilst such sequences often only contain a single dataset, the format is defined such that each sequence consists of a set of datasets. Of course, this structure lends itself perfectly to recursion, and some DICOM IODs such a Structured_Reporting and the Radiotherapy_Extensions can use sequences nested 5 or 6 deep !
The format of a sequence is as shown here: [
Enough theory. Following is how you can read nested tags within the sequences:
var value = file.Dataset.Get<DicomSequence>(DicomTag.FractionGroupSequence).Items[0].Get<string>(DicomTag.BeamDose);
Refer this thread for more details.
来源:https://stackoverflow.com/questions/46690392/how-to-read-nested-child-dicom-tags-from-sequences-using-fo-dicom