8
8
9
9
from heudiconv .convert import (update_complex_name ,
10
10
update_multiecho_name ,
11
- update_uncombined_name )
11
+ update_uncombined_name ,
12
+ DW_IMAGE_IN_FMAP_FOLDER_WARNING ,
13
+ )
12
14
from heudiconv .bids import BIDSError
13
15
from heudiconv .cli .run import main as runner
14
16
@@ -83,10 +85,11 @@ def test_update_uncombined_name():
83
85
assert out_fn_test == out_fn_true
84
86
85
87
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
90
93
"""
91
94
tmppath = tmpdir .strpath
92
95
subID = 'b0dwiForFmap'
@@ -96,14 +99,15 @@ def test_b0dwi_for_fmap(tmpdir):
96
99
).split (' ' )
97
100
runner (args )
98
101
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 ]
104
107
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
106
109
# *.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