Skip to content

remove bval bvecs files generated for SBRef on XA60/CMRR/dcm2niix #819

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
10 changes: 3 additions & 7 deletions heudiconv/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ class PopulateIntendedForOpts(TypedDict, total=False):


LOCKFILE = "heudiconv.lock"
DW_IMAGE_IN_FMAP_FOLDER_WARNING = (
"Diffusion-weighted image saved in non dwi folder ({folder})"
)
DW_IMAGE_WRONG_SUFFIX_WARNING = "Diffusion-weighted image saved as non dwi ({prefix})"
lgr = logging.getLogger(__name__)


Expand Down Expand Up @@ -896,7 +894,7 @@ def save_converted_files(
bvals, bvecs = res.outputs.bvals, res.outputs.bvecs
bvals = list(bvals) if isinstance(bvals, TraitListObject) else bvals
bvecs = list(bvecs) if isinstance(bvecs, TraitListObject) else bvecs
if prefix_dirname.endswith("dwi"):
if prefix.endswith("dwi"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for being anal -- just trying to get a better grasp.

With this change I think the else: warning on

                lgr.warning(
                    DW_IMAGE_IN_FMAP_FOLDER_WARNING.format(folder=prefix_dirname)
                )

might be confusing false positive since we might be finding _dwi somewhere else than dwi/ folder (e.g. due to a bug in heuristic or alike)

Also, how/where do we treat fmap/..._epi here -- from the code it seems we could also run into the warnings, can't we?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you're right that the logic has drifted, so we can change that message to

DW_IMAGE_WRONG_SUFFIX_WARNING = (
    "Diffusion-weighted image saved as non dwi ({prefix})"
)

and

                lgr.warning(
                    DW_IMAGE_WRONG_SUFFIX_WARNING.format(prefix=prefix)
                )

outname_bvecs, outname_bvals = prefix + ".bvec", prefix + ".bval"
safe_movefile(bvecs, outname_bvecs, overwrite)
safe_movefile(bvals, outname_bvals, overwrite)
Expand All @@ -907,9 +905,7 @@ def save_converted_files(
os.remove(ftr)
lgr.debug("%s and %s were removed since not dwi", bvecs, bvals)
else:
lgr.warning(
DW_IMAGE_IN_FMAP_FOLDER_WARNING.format(folder=prefix_dirname)
)
lgr.warning(DW_IMAGE_WRONG_SUFFIX_WARNING.format(prefix=prefix))
lgr.warning(
".bvec and .bval files will be generated. This is NOT BIDS compliant"
)
Expand Down
6 changes: 3 additions & 3 deletions heudiconv/tests/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from heudiconv.cli.run import main as runner
import heudiconv.convert
from heudiconv.convert import (
DW_IMAGE_IN_FMAP_FOLDER_WARNING,
DW_IMAGE_WRONG_SUFFIX_WARNING,
bvals_are_zero,
update_complex_name,
update_multiecho_name,
Expand Down Expand Up @@ -170,8 +170,8 @@ def test_b0dwi_for_fmap(tmp_path: Path, caplog: pytest.LogCaptureFixture) -> Non

# assert that it raised a warning that the fmap directory will contain
# bvec and bval files.
expected_msg = DW_IMAGE_IN_FMAP_FOLDER_WARNING.format(
folder=op.join(tmp_path, f"sub-{subID}", "fmap")
expected_msg = DW_IMAGE_WRONG_SUFFIX_WARNING.format(
prefix=op.join(tmp_path, f"sub-{subID}", "fmap", f"sub-{subID}_acq-b0dwi_epi")
)
assert any(expected_msg in c.message for c in caplog.records)

Expand Down