lamyj / dicomifier

A medical image converter
https://dicomifier.readthedocs.io/
Other
30 stars 7 forks source link

dicom2nifti fails when an element is not in the first data set #29

Closed lamyj closed 7 years ago

lamyj commented 7 years ago

If the first data set of a stack does not have an element that is present in other, dicom2nifti fails:

0019100e {1: <odil.Element object at 0x7f3b43615c20>, 2: <odil.Element object at 0x7f3b43608c90>, 4: <odil.Element object at 0x7f3b4346c3d0>, 7: <odil.Element object at 0x7f3b43498a60>, 8: <odil.Element object at 0x7f3b4357b520>, 11: <odil.Element object at 0x7f3b435a43d0>, 12: <odil.Element object at 0x7f3b4359f050>, 15: <odil.Element object at 0x7f3b435d1d00>, 16: <odil.Element object at 0x7f3b435cd0c0>, 18: <odil.Element object at 0x7f3b436f4440>, 21: <odil.Element object at 0x7f3b4370abb0>, 22: <odil.Element object at 0x7f3b436ebe50>, 24: <odil.Element object at 0x7f3b437396e0>, 27: <odil.Element object at 0x7f3b4372d910>, 29: <odil.Element object at 0x7f3b43550de0>, 30: <odil.Element object at 0x7f3b4352a670>, 33: <odil.Element object at 0x7f3b43555590>, 34: <odil.Element object at 0x7f3b434ffc90>, 37: <odil.Element object at 0x7f3b4350c6e0>, 39: <odil.Element object at 0x7f3b43519d00>, 41: <odil.Element object at 0x7f3b434a7360>, 43: <odil.Element object at 0x7f3b434b4980>, 45: <odil.Element object at 0x7f3b434c1fa0>, 47: <odil.Element object at 0x7f3b434cf600>, 49: <odil.Element object at 0x7f3b434dcc20>, 51: <odil.Element object at 0x7f3b40806280>, 53: <odil.Element object at 0x7f3b408138a0>}
Traceback (most recent call last):
  File "/usr/bin/dicom2nifti", line 224, in <module>
    sys.exit(main())
  File "/usr/bin/dicom2nifti", line 42, in main
    convert(**arguments)
  File "/usr/bin/dicom2nifti", line 61, in convert
    nifti_data = convert_series(series_files, dtype)
  File "/usr/bin/dicom2nifti", line 143, in convert_series
    nifti_data = dicomifier.dicom_to_nifti.convert(dicom_data_sets, dtype)
  File "/usr/lib/python2.7/dist-packages/dicomifier/dicom_to_nifti/convert.py", line 93, in convert
    data_sets_frame_idx, meta_data_cache)
  File "/usr/lib/python2.7/dist-packages/dicomifier/dicom_to_nifti/meta_data.py", line 110, in get_meta_data
    sample = values_dict[0]
KeyError: 0