Get ClearCanvas DicomTag from dicom group and item numbers

I am trying to read dicom tags from text file like (####,####)

and create corresponding DicomTag from transparent canvas library

//parsing txt string to find the corresponding dicomtag
foreach (String elem in settings)
{
    String tag = elem.Replace("(", "").Replace(")", "");
    String[] arr = tag.Split(',');
    DicomTag dTag = DicomTagDictionary.GetDicomTag(ushort.Parse(arr[0]), ushort.Parse(arr[1]));

    if (dTag != null)
    {
        toRemove.Add(dTag);
    }
    else
    {
        MessageBox.Show("Tag: (" + arr[0] + "," + arr[1] + ") is not valid");
    }
}

      

For a while, even if the tag exists, the method DicomTagDictionary.GetDicomTag(ushort group, ushort element)

cannot find the tag, for example (0008 0008), but the tag (0008,1070) does not work.

tags can be found here: http://medical.nema.org/Dicom/2011/11_06pu.pdf

a clear canvas equivalent can be found here: https://github.com/ClearCanvas/ClearCanvas/blob/master/Dicom/DicomTags.cs

+3


source to share


2 answers


I think the text file has group and item in hex, and ushort parses them as decimal. 0008, 1070 as decimal 0x0008, 0x042E in hex, which is not a valid dicom tag (at least according to dicomlookup.com).

If you give ushort.Parse with HexNumber number type that should parse the value from text file correctly.



msdn.microsoft.com/en-us/library/kbaxyssf (v = vs .110) .aspx

+2


source


I use the following to edit or create non-existent tags in Clear Canvas:

Platform.Log(LogLevel.Info, "Setting Tag: " + "0x" + Stats.g_TaglistTag1 + " to value of: " + Stats.g_tbTagList1);
AC_To_Coerce[Convert.ToUInt32("0x" + Stats.g_TaglistTag1, 16)].SetStringValue(Stats.g_tbTagList1);

      

AC_To_Coerce is a DicomAttributeCollection object. Stats.g_TaglistTag1 is the hex string for the DICOM tag, Stats.g_tbTagList1 is the value for the tag. It can also be used to set a tag value for a DicomFile object or a DicomMessage object with simple modification.



This sets or creates and sets the value and logs the following line, for example:

2015-09-18 21: 02: 24.944 [6704] [7] INFO - set tag: 0x00100010 for value: Test

+1


source







All Articles