[英]How to get the full string element of a dicom item with fo-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#將字符串拆分為另一個字符串,或者是在.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>()
只能再次獲得剪切的字符串。
希望您能找到我做錯了什么以及如何獲得此項的完整字符串。
他們從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());
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.