Update tags in nested configuration

18 views
Skip to first unread message

Picasso

unread,
Apr 1, 2024, 8:56:45 PMApr 1
to Fellow Oak DICOM

I would like to update (300A,004A) and (300A,00B8) dicom tags both are type string strings.

The challenge is that it is nested and multiple instances of these Tags.

 

Here is my code:

string[] files = Directory.GetFiles(dirPath);

 

foreach (var item in files)

{

    DicomFile dicomFile = DicomFile.Open(item, FileReadOption.ReadAll);

 

    var dicomDataset = dicomFile.Dataset;

 

        //Count number of items found in the sequence

        int count = dicomDataset.GetSequence(DicomTag.ToleranceTableSequence).Items[0].GetSequence(DicomTag.BeamLimitingDeviceToleranceSequence).Items.Count();

 

//go thru items until you find the correct one that contains "ASYMX

        for (int i = 0; i < count; i++)

      {

var Dev1 = dicomDataset.GetSequence(DicomTag.ToleranceTableSequence).Items[0].GetSequence(DicomTag.BeamLimitingDeviceToleranceSequence).Items[i].GetSingleValueOrDefault<string>(DicomTag.RTBeamLimitingDeviceType, "");

            if (Dev1 == "ASYMX")

            {

//Code works up to here because it found the item that contains ASYMX

             

             

       //Now, I need to update those tags

      

  dicomFile.Dataset.AddOrUpdate<string>(DicomTag.BeamLimitingDevicePositionTolerance, "Valu1");

                  dicomFile.Dataset.AddOrUpdate<string>(DicomTag.RTBeamLimitingDeviceType, "ASYMX2");

 

      dicomFile.Save(item);            

             }

           }

     }

 

    else

    {

        //Console.WriteLine("TBD");

    }

 

The code compiles correctly but file does not update

Picasso

unread,
Apr 2, 2024, 3:56:59 PMApr 2
to Fellow Oak DICOM
Reply all
Reply to author
Forward
0 new messages