itk.MetaDataObject.GetMetaDataObjectValue() is missing in Python

dicom
python

(Julien Finet) #1

Hi,

When using ITK with Python, how can you get the DICOM Tags of a DICOM directory ?
It seems that itk.MetaDataObject.GetMetaDataObjectValue() is missing.

dicomReader = itk.ImageSeriesReader[ImageType].New()
dicomReader.SetFileNames(fileNames)
dicomReader.MetaDataDictionaryArrayUpdateOn()
dicomReader.Update()
tag = dicomReader.GetMetaDataDictionaryArray()[0].Get('0008|0060')
# tag.GetMetaDataObjectValue() does not exist

Is it a bug or is there another way to get the DICOM tags ?

Thanks,
Julien.


(Francois Budin) #2

In Python, you can directly access the values of the metadata dictionary with the [ ] operator. For example:

metadict['0028|1050']

Another way is to get the dicom IO and get the information directly from that object. Either you specify the IO when creating the reader:

dicomIO = itk.GDCMImageIO.New()
reader.SetImageIO(dicomIO)

Or you recover the IO object from the reader and down cast it to be able to access the method you need:

io=reader.GetImageIO()
dc=itk.down_cast(io)
print dc.GetValueFromTag("0028|1051", "")

(Julien Finet) #3

Thanks, that works great with the [] operator.

Julien.