How to get the keyword of a tag in dcm4che2?

622 views
Skip to first unread message

Xiaohu Mo

unread,
Dec 5, 2013, 6:18:00 PM12/5/13
to dcm...@googlegroups.com
Hi,

Is there any method to get the keyword of a DICOM tag as specified in DICOM standard part 6?  For example, something like getTagKeyword(0020,0032) could return "ImagePositionPatient".

The closest I've found is the nameOf() method, which returns the "name" of the tag. E.g. obj.nameOf(dec2hex("0020,0032")) returns "Image Position (Patient)".

Any help is much appreciated.

Best regards,
Xiaohu

Gunter Zeilinger

unread,
Dec 9, 2013, 6:42:22 AM12/9/13
to dcm...@googlegroups.com
org.dcm4che.data.Keyword.valueOf(int)


--
You received this message because you are subscribed to the Google Groups "dcm4che" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dcm4che+u...@googlegroups.com.
To post to this group, send email to dcm...@googlegroups.com.
Visit this group at http://groups.google.com/group/dcm4che.
For more options, visit https://groups.google.com/groups/opt_out.

Xiaohu Mo

unread,
Dec 9, 2013, 9:16:27 AM12/9/13
to dcm...@googlegroups.com
Thanks!
I found this works in dcm4che 3.x.
Does similar method exist in dcm4che2?

Best regards

Gunter Zeilinger

unread,
Dec 9, 2013, 9:53:18 AM12/9/13
to dcm...@googlegroups.com
No.
You may workarround by

String keywordOf(int tag) {
        for (Field field : Tag.class.getDeclaredFields()) {
            try {
              if (field.getInt(null) == tag)
                return field.getName();
            } catch (Exception ignore) {};
        }
        return null;
}

Xiaohu Mo

unread,
Dec 9, 2013, 10:32:52 AM12/9/13
to dcm...@googlegroups.com
Great!  Thank you very much.
Sincerely,
Xiaohu
Reply all
Reply to author
Forward
0 new messages