Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

properly remove GE multiecho bvals/bvecs #728

Merged
merged 5 commits into from
Feb 24, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions heudiconv/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import filelock
from nipype import Node
from nipype.interfaces.base import TraitListObject

from .bids import (
BIDS_VERSION,
Expand Down Expand Up @@ -886,8 +887,13 @@
safe_movefile(res.outputs.bvals, outname_bvals, overwrite)
else:
if bvals_are_zero(res.outputs.bvals):
os.remove(res.outputs.bvecs)
os.remove(res.outputs.bvals)
to_remove = []
if isinstance(res.outputs.bvals, str):
to_remove = [res.outputs.bvals, res.outputs.bvecs]

Check warning on line 892 in heudiconv/convert.py

View check run for this annotation

Codecov / codecov/patch

heudiconv/convert.py#L890-L892

Added lines #L890 - L892 were not covered by tests
else:
to_remove = list(res.outputs.bvals) + list(res.outputs.bvecs)
for ftr in to_remove:
os.remove(ftr)

Check warning on line 896 in heudiconv/convert.py

View check run for this annotation

Codecov / codecov/patch

heudiconv/convert.py#L894-L896

Added lines #L894 - L896 were not covered by tests
lgr.debug(
"%s and %s were removed since not dwi",
res.outputs.bvecs,
Expand Down Expand Up @@ -1077,6 +1083,10 @@
True if all are all 0 or 5; False otherwise.
"""

# GE hyperband multi-echo containing diffusion info
if isinstance(bval_file, TraitListObject):
bpinsard marked this conversation as resolved.
Show resolved Hide resolved
return all([bvals_are_zero(bvf) for bvf in bval_file])

Check warning on line 1088 in heudiconv/convert.py

View check run for this annotation

Codecov / codecov/patch

heudiconv/convert.py#L1088

Added line #L1088 was not covered by tests
bpinsard marked this conversation as resolved.
Show resolved Hide resolved

with open(bval_file) as f:
bvals = f.read().split()

Expand Down