如何使用 fo-dicom 从序列中读取 nested/child DICOM 标签?
How to read nested/child DICOM tags from sequences using fo-dicom?
对于我的项目,我正在尝试使用 fo-dicom 3.0.2 和 VS2015 (.Net 4.5.2) 中的 C# 从 DICOM 文件中读取放射治疗计划(RT 计划)。
感谢 DICOM 编辑器,我知道存储在不同 DicomTags
中的值,但我无法访问所有 Tag
。例如,我正在尝试读取 DicomTag.BeamDose
并且我知道该值不为空。
string storedfile = file_path + file_name;
Dicom.DicomFile file = Dicom.DicomFile.Open(@storedfile);
MessageBox.Show(file.Dataset.Get<string>(Dicom.DicomTag.BeamDose));
运行 代码抛出异常消息:
(300a,0084) not found in dataset.
如前所述,我知道它在那里,但嵌套在序列项中。
接下来我尝试分析存储 BeamDose
的序列。
var NewDataSet = file.Dataset.Get<Dicom.DicomItem>(Dicom.DicomTag.FractionGroupSequence);
但是下一次处理这个变量的机会并没有让我进入序列的下一个级别。
我应该如何使用 fo-dicom 从序列中读取 nested/child DICOM 标签?
您查找标签的方式仅在 DICOM 标签树的最外层层次结构中查找。要正确搜索标签,您需要首先访问正确的序列,然后是适当的项目,然后您应该在该项目中搜索标签。 DICOM 数据集可能包含可以进一步嵌套的序列(由 VR SQ 标识)。
以下是从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.
以下是从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:
[
足够的理论。以下是如何读取序列中的嵌套标签:
var value = file.Dataset.Get<DicomSequence>(DicomTag.FractionGroupSequence).Items[0].Get<string>(DicomTag.BeamDose);
有关详细信息,请参阅 this 主题。
对于我的项目,我正在尝试使用 fo-dicom 3.0.2 和 VS2015 (.Net 4.5.2) 中的 C# 从 DICOM 文件中读取放射治疗计划(RT 计划)。
感谢 DICOM 编辑器,我知道存储在不同 DicomTags
中的值,但我无法访问所有 Tag
。例如,我正在尝试读取 DicomTag.BeamDose
并且我知道该值不为空。
string storedfile = file_path + file_name;
Dicom.DicomFile file = Dicom.DicomFile.Open(@storedfile);
MessageBox.Show(file.Dataset.Get<string>(Dicom.DicomTag.BeamDose));
运行 代码抛出异常消息:
(300a,0084) not found in dataset.
如前所述,我知道它在那里,但嵌套在序列项中。
接下来我尝试分析存储 BeamDose
的序列。
var NewDataSet = file.Dataset.Get<Dicom.DicomItem>(Dicom.DicomTag.FractionGroupSequence);
但是下一次处理这个变量的机会并没有让我进入序列的下一个级别。
我应该如何使用 fo-dicom 从序列中读取 nested/child DICOM 标签?
您查找标签的方式仅在 DICOM 标签树的最外层层次结构中查找。要正确搜索标签,您需要首先访问正确的序列,然后是适当的项目,然后您应该在该项目中搜索标签。 DICOM 数据集可能包含可以进一步嵌套的序列(由 VR SQ 标识)。
以下是从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.
以下是从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: [
足够的理论。以下是如何读取序列中的嵌套标签:
var value = file.Dataset.Get<DicomSequence>(DicomTag.FractionGroupSequence).Items[0].Get<string>(DicomTag.BeamDose);
有关详细信息,请参阅 this 主题。