datalad / datalad-neuroimaging

DataLad extension for neuroimaging research
http://datalad.org
Other
17 stars 14 forks source link

"Support" MultiValue type from pydicom #49

Closed yarikoptic closed 5 years ago

yarikoptic commented 5 years ago

I was surprised to not find ImageType meta data field in aggregated metadata, and discovered that it is not provided by pydicom as list or tuple but as pydicom.multival.MultiValue which is used for a few fields in a sample DICOM I have tortured. IMHO should get the same treatment as list -- the distinctive feature for this class is assuring uniform data typing.

*(Pdb) pprint(dict([(f, (getattr(d, f), type(getattr(d, f)))) for f in d.dir() if not isinstance(getattr(d, f), (int, float, string_types, dcm.valuerep.DSfloat, dcm.valuerep.IS, dcm.valuerep.PersonName3, list, tuple))]))
{'ImageOrientationPatient': (['0', '1', '0', '0', '0', '-1'],
                             <class 'pydicom.multival.MultiValue'>),
 'ImagePositionPatient': (['-101.60000151396', '-140', '130'],
                          <class 'pydicom.multival.MultiValue'>),
 'ImageType': (['ORIGINAL', 'PRIMARY', 'M', 'ND', 'NORM'],
               <class 'pydicom.multival.MultiValue'>),
 'PixelSpacing': (['1.625', '1.625'], <class 'pydicom.multival.MultiValue'>)}
yarikoptic commented 5 years ago

heh heh - here is the actual reason:

$> python -c 'import dicom as dcm; print(issubclass(dcm.multival.MultiValue, list), dcm.__version__)'
(True, '0.9.9')
$> python -c 'import pydicom as dcm; print(issubclass(dcm.multival.MultiValue, list), dcm.__version__)'
(False, '1.0.2')