nipy / heudiconv

Flexible DICOM conversion into structured directory layouts
https://heudiconv.readthedocs.io
Other
232 stars 125 forks source link

properly remove GE multiecho bvals/bvecs #728

Closed bpinsard closed 6 months ago

bpinsard commented 7 months ago

GE Hyperband (at least some versions of it) multi-echo data get diffusion vector/values in the dicom tags used by dcm2niix to generate bvecs/bvals.

While heudiconv is properly coded to remove such data when there is a single bvec/bval per series, multi-echo data outputs as many as there are echoes causing it to crash.

An error occur processing s398
expected str, bytes or os.PathLike object, not TraitListObject
Traceback (most recent call last):
  File "/app/convert.py", line 54, in convert_pipeline
    heudiconv_workflow(**heudiconv_params)
  File "/usr/local/lib/python3.9/dist-packages/heudiconv/main.py", line 463, in workflow
    prep_conversion(
  File "/usr/local/lib/python3.9/dist-packages/heudiconv/convert.py", line 258, in prep_conversion
    convert(
  File "/usr/local/lib/python3.9/dist-packages/heudiconv/convert.py", line 623, in convert
    bids_outfiles = save_converted_files(
  File "/usr/local/lib/python3.9/dist-packages/heudiconv/convert.py", line 891, in save_converted_files
    if bvals_are_zero(res.outputs.bvals):
  File "/usr/local/lib/python3.9/dist-packages/heudiconv/convert.py", line 1083, in bvals_are_zero
    with open(bval_file) as f:
TypeError: expected str, bytes or os.PathLike object, not TraitListObject

The current PR fixes that by checking if all files only contain zeros bvals when not suffixed _dwi, and remove all of them appropriately.

FYI @miltoncamachocamacho

codecov[bot] commented 7 months ago

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (1d614cd) 81.97% compared to head (bc4ce42) 82.00%. Report is 7 commits behind head on master.

Files Patch % Lines
heudiconv/convert.py 75.00% 4 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #728 +/- ## ========================================== + Coverage 81.97% 82.00% +0.03% ========================================== Files 41 41 Lines 4149 4163 +14 ========================================== + Hits 3401 3414 +13 - Misses 748 749 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

github-actions[bot] commented 6 months ago

:rocket: PR was released in v1.0.2 :rocket: