3

Given a gdcm tag, e.g. gdcm::Tag(0x0010,0x0010) how can it be convert to the corresponding tag name string, in this case "PatientsName" in C++?

Dov Grobgeld
  • 4,783
  • 1
  • 25
  • 36

1 Answers1

3

Here is what I do in a Qt based application with GDCM:

QString duDicomDictionary::getTagName( const gdcm::Tag & tag )
{
    QString retVal;

    const gdcm::Global& g = gdcm::Global::GetInstance();
    const gdcm::Dicts &dicts = g.GetDicts();
    const gdcm::Dict &pubdict = dicts.GetPublicDict();

    gdcm::DictEntry ent = pubdict.GetDictEntry(tag);

    if (ent.GetVR() != gdcm::VR::INVALID ) {
        retVal = QString::fromStdString(ent.GetName());
    }

    return retVal;
}

This code will only work for public groups.

To get the private groups I use (after I populated the private dictionary):

QString duDicomDictionary::getTagName( const gdcm::PrivateTag & tag )
{
    QString retVal;

    const gdcm::Global& g = gdcm::Global::GetInstance();
    const gdcm::Dicts &dicts = g.GetDicts();
    const gdcm::PrivateDict &privdict = dicts.GetPrivateDict();

    gdcm::DictEntry ent = privdict.GetDictEntry(tag);

    if (ent.GetVR() != gdcm::VR::INVALID ) {
        retVal = QString::fromStdString(ent.GetName());
    }
    else
    {
        ent = g_privateDict.GetDictEntry(tag);

        if (ent.GetVR() != gdcm::VR::INVALID ) {
            retVal = QString::fromStdString(ent.GetName());
        }

    }

    return retVal;
}
drescherjm
  • 10,365
  • 5
  • 44
  • 64