From Ohm

DCMTK Keys

DCMTK also offers access to the meta data of each image specified by a particular standardized DCMTK key via:

image->findAndGetOFString(key, ...);

Common DCMTK keys [1] are

Each DCM key is represented by two numbers (g, e), a 16-bit group number g and a 16-bit element number e. The two numbers are known as DICOM tag [2].

For example, the patient’s name, as given by the DCMTK key DCM_PatientName, corresponds to the DICOM tag (0010,1001).

To read the patient name, we query for the DCM_PatientName key:

OFString name;
image->findAndGetOFString(DCM_PatientName, name));

Note: To convert from the internal dcmtk data type OFString to a std::string type we use a copy constructor:

std::string(name.c_str())

To get the dimensions of an image, we query the DCM_Columns and DCM_Rows keys:

bool getDimensions(DcmDataSet *image, long long &cols,long long &rows)
{
   OFString tmp;

   if (image->findAndGetOFString(DCM_Columns,tmp).bad()) return(false);
   sscanf(tmp.c_str(),"%lld",&cols);
   if (image->findAndGetOFString(DCM_Rows,tmp).bad()) return(false);
   sscanf(tmp.c_str(),"%lld",&rows);

   return(true);
}

Each value associated with a DCM key can have multiple fields, for example to represent a vector: To get the 3 fields for the position vector of the origin of an image (in meters), we query the DCM_ImagePositionPatient tag 3 times:

bool getPosition(DcmDataSet *image, float position[3])
{
   if (image->findAndGetOFString(DCM_ImagePositionPatient,tmp,0).bad()) return(false);
   sscanf(tmp.c_str(),"%g",&position[0]);
   if (image->findAndGetOFString(DCM_ImagePositionPatient,tmp,1).bad()) return(false);
   sscanf(tmp.c_str(),"%g",&position[1]);
   if (image->findAndGetOFString(DCM_ImagePositionPatient,tmp,2).bad()) return(false);
   sscanf(tmp.c_str(),"%g",&position[2]);

   return(true);
}

Links

  1. support.dcmtk.org/docs/classDcmTagKey.html
  2. dicomlookup.com

Retrieved from http://schorsch.efi.fh-nuernberg.de/roettger/index.php/MedicalVisualization/DCMTKKeys

Page last modified on October 18, 2019, at 12:56 PM