2017-10-13 5 views
2

J'essaie d'obtenir une chaîne d'un plan de radiothérapie dans un fichier dicom avec fo-dicom. Cela ne semble pas être si difficile pour vous, mais je suis bloqué parce que je ne peux pas trouver la bonne commande.Comment obtenir l'élément string complet d'un item dicom avec fo-dicom?

Je filtrais le plan, par ex. pour le Leaf/Jaw Positions. La valeur de chaîne affichée en mode de débogage VS est "-35 // 35" et je la trouve également dans mon éditeur DICOM. Mais la sortie me donne seulement la valeur -35. Mon code est comme

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); 

Donc, avec cela, je ne reçois que la première valeur mentionnée. En changeant le dernier Get<string>() en Get<Dicom.DicomElement>() ou quelque chose d'autre dans le débogage overwatch je peux voir toute la chaîne à nouveau, mais je ne peux pas l'imprimer.

Comme je l'ai regardé ici C# Split A String By Another String ou Easiest way to split a string on newlines in .NET? je l'ai essayé avec éditer mon code pour

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); 

Mais string n'est pas en mesure d'accepter Dicom.DicomElement comme une chaîne et avec Get<string>() dans la dernière ligne j'obtenir uniquement les couper à nouveau la chaîne. En espérant que vous pouvez aider à trouver où j'ai fait quelque chose de mal et comment obtenir la chaîne complète de cet article.

Répondre

3

De https://github.com/fo-dicom/fo-dicom/issues/491 ils sont la fixation de la question avec une nouvelle API, mais en supposant que vous utilisez une version antérieure,

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

devrait revenir ce que vous attendez.

PS J'utilise une méthode d'extension string pour 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

Merci pour votre réponse. Cela fonctionne très bien. – Booma