2017-10-13 57 views
2

我试图在fo-dicom的dicom文件中获得一串放射疗法计划。对你来说似乎并不那么难,但我因为找不到正确的命令而陷入困境。如何用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<string>()更改为Get<Dicom.DicomElement>()或其他调试守望组件,我可以再次看到整个字符串,但无法打印。

我抬头这里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<string>()在上线我只得到再次剪切字符串。

希望你能帮助找到我做错了什么地方,以及如何获得这个项目的完整字符串。

回答

3

https://github.com/fo-dicom/fo-dicom/issues/491它们与新的API固定问题,但假设你使用的是旧版本,

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

应该返回你所期望的。

PS我使用string扩展方法Join

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()); 
+0

谢谢您的回答。它工作得很好。 – Booma