简体   繁体   English

如何使用 fo-dicom 从序列中读取嵌套/子 DICOM 标签?

[英]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).对于我的项目,我正在尝试在 VS2015(.Net 4.5.2)中使用 fo-dicom 3.0.2 和 C# 从 DICOM 文件中读取放射治疗计划(RT 计划)。

Thanks to a DICOM Editor, I know the values stored in the different DicomTags , but I cant get access to all Tag seg I'm trying to read the DicomTag.BeamDose and I know the value isn't empty.多亏了 DICOM 编辑器,我知道存储在不同DicomTags中的值,但是我无法访问我试图读取DicomTag.BeamDose的所有Tag段,并且我知道该值不为空。

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. (300a,0084) 在数据集中找不到。

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.接下来我尝试分析存储BeamDose的序列。

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?我应该如何使用 fo-dicom 从序列中读取嵌套/子 DICOM 标签?

The way you are looking for tag only look for it in outermost hierarchy of DICOM tag tree.您查找标签的方式仅在 DICOM 标签树的最外层层次结构中查找。 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. DICOM 数据集可能包含可以进一步嵌套的序列(由 VR SQ 识别)。

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. VR 标识的“SQ”应用于具有由零个或多个项目组成的序列的值的数据元素,其中每个项目包含一组数据元素。 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 提供了一种灵活的编码方案,可用于重复数据元素集的简单结构,或通常称为文件夹的更复杂信息对象定义的编码。 SQ Data Elements can also be used recursively to contain multi-level nested structures. SQ 数据元素也可以递归使用以包含多级嵌套结构。

Items present in an SQ Data Element shall be an ordered set where each Item may be referenced by its ordinal position.出现在 SQ 数据元素中的项目应是一个有序集合,其中每个项目都可以通过其序数位置进行引用。 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.每个项目应隐含地分配一个顺序位置,从序列中第一个项目的值 1 开始,并随着每个后续项目递增 1。 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". DICOM 允许数据集包含其他嵌套数据集,这些数据集被编码为“序列”。 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 !当然,这种结构非常适合递归,并且一些 DICOM IOD(例如 Structured_Reporting 和 Radiotherapy_Extensions)可以使用嵌套 5 或 6 层深的序列!

The format of a sequence is as shown here: [序列的格式如下所示:[图片][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.有关更多详细信息,请参阅线程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM