Skip to content

Commit aca523b

Browse files
committed
Modify unit test for b0dwi_for_fmap
Now it checks that there is a warning that `*.bvec` and `*.bval` files are present in a non-`dwi` folder
1 parent 0f84c67 commit aca523b

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

heudiconv/tests/test_convert.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
from heudiconv.convert import (update_complex_name,
1010
update_multiecho_name,
11-
update_uncombined_name)
11+
update_uncombined_name,
12+
DW_IMAGE_IN_FMAP_FOLDER_WARNING,
13+
)
1214
from heudiconv.bids import BIDSError
1315
from heudiconv.cli.run import main as runner
1416

@@ -83,10 +85,11 @@ def test_update_uncombined_name():
8385
assert out_fn_test == out_fn_true
8486

8587

86-
def test_b0dwi_for_fmap(tmpdir):
87-
"""Make sure that we don't copy .bvec and .bval files
88-
when the modality is not dwi.
89-
We check it by extracting a b-value=0 dwi image as fmap and dwi
88+
def test_b0dwi_for_fmap(tmpdir, capfd):
89+
"""Make sure we raise a warning when .bvec and .bval files
90+
are present but the modality is not dwi.
91+
We check it by extracting a few DICOMs from a series with
92+
bvals: 5 5 1500
9093
"""
9194
tmppath = tmpdir.strpath
9295
subID = 'b0dwiForFmap'
@@ -96,14 +99,15 @@ def test_b0dwi_for_fmap(tmpdir):
9699
).split(' ')
97100
runner(args)
98101

99-
# check that the fmap directory has been extracted and it doesn't contain
100-
# any *.bvec or *.bval files
101-
assert op.isdir(op.join(tmppath, 'sub-%s', 'fmap') % (subID))
102-
for ext in ['bval', 'bvec']:
103-
assert not glob(op.join(tmppath, 'sub-%s', 'fmap', 'sub-%s_*.%s') % (subID, subID, ext))
102+
# assert that it raised a warning that the fmap directory will contain
103+
# bvec and bval files.
104+
output = capfd.readouterr().err.split('\n')
105+
expected_msg = DW_IMAGE_IN_FMAP_FOLDER_WARNING.format(folder=op.join(tmppath, 'sub-%s', 'fmap') % subID)
106+
assert [o for o in output if expected_msg in o]
104107

105-
# check that the dwi directory has been extracted and it does contain a
108+
# check that both 'fmap' and 'dwi' directories have been extracted and they contain
106109
# *.bvec and a *.bval files
107-
assert op.isdir(op.join(tmppath, 'sub-%s', 'dwi') % (subID))
108-
for ext in ['bval', 'bvec']:
109-
assert glob(op.join(tmppath, 'sub-%s', 'dwi', 'sub-%s_*.%s') % (subID, subID, ext))
110+
for mod in ['fmap', 'dwi']:
111+
assert op.isdir(op.join(tmppath, 'sub-%s', mod) % (subID))
112+
for ext in ['bval', 'bvec']:
113+
assert glob(op.join(tmppath, 'sub-%s', mod, 'sub-%s_*.%s') % (subID, subID, ext))

0 commit comments

Comments
 (0)