How to modify a private tag that contains XML elements?

14 views
Skip to first unread message

Picasso

unread,
Oct 15, 2024, 3:37:06 PMOct 15
to Fellow Oak DICOM

Hello all,

Found few posts that reference private tags but different scenarios. The dicom file I am dealing with contains an XML as private tag (VR=”OB”) so the data type stored is “Other Byte” that is represented as string.

My attempt to read the value first was using this code:

 

                                var tag = DicomTag.Parse("0x3253, 0x1000");

                                var readTag = (from dicomItem in dicomDataset

                                            where dicomItem.Tag.Group == tag.Group &&       dicomItem.Tag.Element == tag.Element

                                            select dicomItem as DicomElement).SingleOrDefault();

                                 var value = readTag == null ? string.Empty : readTag.Get<string>();

  

                                Console.WriteLine($"The value private tag is: {value}");

 

Unfortunately, it generates an error at runtime.

Any help would be greatly appreciated 

Picasso

unread,
Oct 16, 2024, 1:49:34 AMOct 16
to Fellow Oak DICOM
I have also tried:
DicomTag privateTag = new DicomTag(0x3253, 0x1000);
// Check if the tag exists and read its value
if (dicomDataset.Contains(privateTag))
{
    var ptvalue = dicomDataset.GetValues<byte[]>(privateTag);

    if (ptvalue != null)
    {
       
        Console.WriteLine("Private OB tag found!");
    }
    else
    {
        Console.WriteLine("Private OB tag exists but has no value.");
    }

}
else
{
    Console.WriteLine("Private OB tag not found.");
}


But message "Private OB tag not found" is always displayed even though I can see the tag in the dicom file!!.
what am I doin wrong? 
Reply all
Reply to author
Forward
0 new messages