在C ++中将dicom标记转换为gdcm中的字符串名称

时间:2014-07-24 21:06:58

标签: c++ gdcm

给出gdcm标签,例如gdcm::Tag(0x0010,0x0010)如何将其转换为相应的标记名称字符串,在本例中为C ++中的"PatientsName"

1 个答案:

答案 0 :(得分:2)

以下是我在使用GDCM的基于Qt的应用程序中所做的事情:

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;
}

此代码仅适用于公共群组。

获取我使用的私人群组(填写私人词典后):

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;
}