2
votes

I'm trying to get a string of a radiation therapy plan in a dicom file with fo-dicom. Doesn't seem to be that hard for you, but I'm stucking because I cannot find the right command.

I was filtering the plan e.g. for the Leaf/Jaw Positions. The string value shown in VS debugging mode is "-35//35" and I find it in my DICOM Editor too. But the output only gives me the value -35. My code is like

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

So with this I only get the mentioned first value. By changing the last Get<string>() to Get<Dicom.DicomElement>() or something else in debugging overwatch I can see the whole string again, but can't print it.

As I looked up here C# Split A String By Another String or Easiest way to split a string on newlines in .NET? I tried it with editing my code to

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

But string isn't able to accept Dicom.DicomElement as a string and with Get<string>() in the last line I only get the cut string again.

Hoping you can help to find where I did something wrong and how to get the full string of this item.

1

1 Answers

4
votes

From https://github.com/fo-dicom/fo-dicom/issues/491 they are fixing the issue with a new API, but assuming you are using an older release,

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

should return what you expect.

PS I use a string extension method for 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());