2017-10-13 249 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

相關問題