【问题标题】:How to get the full string element of a dicom item with fo-dicom?如何使用 fo-dicom 获取 dicom 项目的完整字符串元素?
【发布时间】:2017-10-13 11:30:11
【问题描述】:

我正在尝试使用 fo-dicom 在 dicom 文件中获取一系列放射治疗计划。对你来说似乎没有那么难,但我卡住了,因为我找不到正确的命令。

我正在过滤计划,例如对于Leaf/Jaw Positions。 VS 调试模式下显示的字符串值是 "-35//35",我也在我的 DICOM 编辑器中找到它。但是输出只给了我 -35 的值。我的代码是这样的

var Leaf = file.Dataset.Get<Dicom.DicomSequence>(Dicom.DicomTag.BeamSequence).Items[0].
            Get<Dicom.DicomSequence>(Dicom.DicomTag.ControlPointSequence).Items[0].
            Get<Dicom.DicomSequence>(Dicom.DicomTag.BeamLimitingDevicePositionSequence).Items[0].
            Get<string>(Dicom.DicomTag.LeafJawPositions);

因此,我只能得到提到的第一个值。通过将最后一个 Get&lt;string&gt;() 更改为 Get&lt;Dicom.DicomElement&gt;() 或调试监视中的其他内容,我可以再次看到整个字符串,但无法打印。

当我在这里查看C# Split A String By Another StringEasiest way to split a string on newlines in .NET? 时,我尝试将代码编辑为

string Leaf = file.Dataset.Get<Dicom.DicomSequence>(Dicom.DicomTag.BeamSequence).Items[0].
            Get<Dicom.DicomSequence>(Dicom.DicomTag.ControlPointSequence).Items[0].
            Get<Dicom.DicomSequence>(Dicom.DicomTag.BeamLimitingDevicePositionSequence).Items[0].
            Get<Dicom.DicomElement>(Dicom.DicomTag.LeafJawPositions);

但是string 不能接受Dicom.DicomElement 作为字符串,并且在最后一行使用Get&lt;string&gt;() 我只能再次得到剪切字符串。

希望您能帮助找到我做错了什么以及如何获取该项目的完整字符串。

【问题讨论】:

    标签: c# string dicom fo-dicom


    【解决方案1】:

    来自https://github.com/fo-dicom/fo-dicom/issues/491,他们正在使用新 API 解决问题,但假设您使用的是旧版本,

    string Leaf = String.Join(@"\",
                  ...
                  Get<string[]>(Dicom.DicomTag.LeafJawPositions));
    

    应该返回你所期望的。

    PS 我对Join 使用string 扩展方法:

    public static string Join(this IEnumerable<string> strings, string sep) => String.Join(sep, strings.ToArray());
    public static string Join(this IEnumerable<string> strings, char sep) => String.Join(sep.ToString(), strings.ToArray());
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-05-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多