How to get DICOM values - topasmc/dicom-interface GitHub Wiki

The RTI library uses GDCM as its DICOM parsing library.

Typically, a DICOM value is obtained in the following way in GDCM:

gdcm::Attribute<0x300a,0x00f0> NumberOfBlocks          ;
NumberOfBlocks.SetFromDataElement(beam_.GetDataElement(NumberOfBlocks.GetTag()));
int tmp = NumberOfBlocks.GetValue();

In RTI, we can get values by either tag or keyword from a rti::dataset (which is a wrapper of gcdm::DataSet) by calling get_values as follows. The resulting type is determined by the parameter type.

std::vector<int> tmp;
block_ds->get_values("NumberOfBlocks", tmp);

or

block_ds->get_values(gdcm::Tag(0x300a,0x00f0), tmp);

If a tag attribute is a decimal string, we convert it to float by default instead of string.

In the GDCM way, we access an internal dataset from a sequence as follows:

const gdcm::DataElement &beamsq = plan_gdcm_ds_.GetDataElement( gdcm::Tag() );
gdcm::SmartPointer<gdcm::SequenceOfItems> sqi = beamsq.GetValueAsSQ();
const gdcm::Item &beam = sqi->GetItem(0);    

In RTI, we get the dataset directly.

const dataset* beam_ds = plan_ds_("IonBeamSequence")
const dataset* beam_ds = plan_ds_(gdcm::Tag(0x300a,0x03a2))

Examples of getting DICOM values


The following examples show how to get DICOM values.

1. get a fluence map of a beam

This is an example of how to get the fluence map of beam number 1.

  • Get DICOM beam dataset from the treatment session.
  • Modality type is important as DICOM tags are different in RTIP and RTIBTR
auto beam_number = 1;
auto ds       = session->get_beam_dataset(beam_number); 
  • Get proper sequence tags and get control points sequence from beam
rti::modality_type m = session->get_modality_type(); //return whether RTIP or RTIBTR
auto seq_tags = &rti::seqtags_per_modality.at(m);    //get sequence tag from RTIP or RTIBTR
auto ictrl    = (*ds)(seq_tags->at("ctrl"));         //obtain control points
  • Create a beam module with control point and modality type
rti::beam_module_ion ion_beam(ictrl, m);   //RTI object to convert ion-control points to fluence map.
  • Obtain sequence pointer and loop over its elements.
const std::vector<rti::beam_module_ion::spot>* sequence = ion_beam.get_sequence();

for(auto s : sequence){
   s.e;         //energy
   s.x;         //position x
   s.y;         //position y
   s.fwhm_x;    //FWHM of x
   s.fwhm_y;    //FWHM of y
   s.meterset;  //meterset, MU or NP
}

Let me know if you have any troubles to get the information using rti::dataset.

DICOM Conformance statements

Here we list DICOM tag we used in the library and thus we are expecting users' DICOM file has these tag information. We tried to minimize reading tags and read in only 'mandatory', i.e., type 1 DICOM tags.

DICOM-RT Ion IOD

TBD

DICOM-RT Ion Beam Treatment Record IOD

TBD

DICOM-RT Dose

TBD

CT

TBD

REG

TBD

⚠️ **GitHub.com Fallback** ⚠️