moloney / dcmstack

DICOM to Nifti conversion with meta data preservation
Other
72 stars 51 forks source link

MetaExtractor fails in case some DICOM fields are empty #85

Closed josiglo closed 1 month ago

josiglo commented 11 months ago

We noticed that MetaExtractor fails in _get_elem_value() in case some DICOM fields are empty / are of length zero.

For example, if PatientWeight is included in a dataset, but empty, MetaExtractor fails in this line with TypeError: 'NoneType' object is not iterable as we try to iterate over value, which is None.

According to the DICOM standard, optional fields such as PatientWeight "may or may not be included and could be zero length". (source). Leaving the field empty thus conforms to the standard.

Note that this error only occurs for DICOM fields of these value representations due to this line.

A None check in _get_elem_value() would probably fix the issue.

I am aware that the repo is no longer actively maintained but decided to report the issue anyway due to the planned integration into nibabel.

moloney commented 1 month ago

Thanks for the report, fixed now.

Spenhouet commented 1 month ago

@moloney will you push the fix in a small patch release?