tags:

views:

99

answers:

1

I'm reading dicom tags using openDicom.net like this:

string tag = "";
string description = "";
string val_rep = "";

foreach (DataElement elementy in sq)
{
    tag = elementy.Tag.ToString();
    description = elementy.VR.Tag.GetDictionaryEntry().Description;
    val_rep = elementy.VR.ToString();
}

How can I read dicom tag values?

A: 

I'm assuming that sq is a Sequence...

I've not worked with openDicom, but I'm pretty sure what you're doing there isn't going to yield the results you want.

You have a single tag, description, and val_rep variable, but you're filling them using a foreach, meaning the last DataElement in the Sequence will be the only values you retrieve. You would achieve the same effect by using:

string tag = sq[sq.Count - 1].Tag.ToString();
string description = sq[sq.Count -1].VR.Tag.GetDictionaryEntry().Description;
string val_rep = sq[sq.Count - 1].VR.ToString();

Thus retrieving the last set of values from the Sequence. I believe you'll find that if you step through the foreach as it executes, it will be loading all the different DataElements contained in your DICOM file.

Feel free to return a comment or post more information in your original post if I'm way off base here.

md5sum
Your code doesn't read any tag.My code read the same things like another viewers,but i can't find how to show tag value.
luc
As you step through your foreach, does val_rep get loaded with other values? My point is that even though you're using a foreach on the Sequence's DataElements, you're still only going to RETURN the values from the final DataElement from the Sequence. That final DataElement could very well be empty.
md5sum