moloney / dcmstack

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

BF: parse_and_group - explicit comparison to being Nones before np.allclose #76

Closed yarikoptic closed 1 year ago

yarikoptic commented 1 year ago

This situation was encountered in https://github.com/nipy/heudiconv/issues/582 where we got Nones for both values but then np.allclose errored out to compare on them due to

  File "<__array_function__ internals>", line 180, in isclose
  File "/home/yoh/proj/heudiconv/heudiconv-master/venvs/dev3/lib/python3.10/site-packages/numpy/core/numeric.py", line 2372, in isclose
    xfin = isfinite(x)
    TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

as a logical workaround I have decided to add an explicit check for them both being None. There may be could be cases where one of them would be None or other cases where similarly np.allclose is done without similar guarding. If encountered, a better comparator should be introduced, but for this this addresses that original issue in heudiconv.