Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

c# - How to read nested/child DICOM tags from sequences using fo-dicom?

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 Tags. 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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: [Image][3]


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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...