1- from subprocess import call
21import os
32
43import pytest
@@ -37,74 +36,41 @@ def test_conditional_arguments(monkeypatch):
3736 get_parser ().parse_args (no_img )
3837
3938
40- def test_nibs_lss (bids_dir , atlas_file , atlas_lut , deriv_dir ):
41- bids_dir = str (bids_dir )
42- out_dir = os .path .join (bids_dir , 'derivatives' )
43- assert call (["nibs" ,
44- "-a " + str (atlas_file ),
45- "-l " + str (atlas_lut ),
46- "-c WhiteMatter CSF" ,
47- "--high-pass 0.008" ,
48- "--estimator lss" ,
49- "-sp MNI152NLin2009cAsym" ,
50- "-sm 0.0" ,
51- "--hrf-model spm" ,
52- "--session-label pre" ,
53- "--task-label waffles" ,
54- "--run-label 1" ,
55- "--description-label preproc" ,
56- "--graph" ,
57- bids_dir ,
58- "fmriprep" ,
59- out_dir ,
60- "participant" ])
61-
62-
63- def test_nibs_fs (bids_dir , atlas_file , atlas_lut , deriv_dir ):
64- bids_dir = str (bids_dir )
65- out_dir = os .path .join (bids_dir , 'derivatives' )
66- assert call (["nibs" ,
67- "-a " + str (atlas_file ),
68- "-l " + str (atlas_lut ),
69- "-c WhiteMatter CSF" ,
70- "--high-pass 0.008" ,
71- "--estimator lss" ,
72- "-sp MNI152NLin2009cAsym" ,
73- "-sm 0.0" ,
74- "--hrf-model fir" ,
75- "--fir-delays 0 1 2 3 4"
76- "--session-label pre" ,
77- "--task-label waffles" ,
78- "--run-label 1" ,
79- "--description-label preproc" ,
80- "--graph" ,
81- bids_dir ,
82- "fmriprep" ,
83- out_dir ,
84- "participant" ])
85-
86-
87- def test_nibs_lsa (bids_dir , atlas_file , atlas_lut , deriv_dir ):
39+ @pytest .mark .parametrize ("estimator,fir_delays,hrf_model" ,
40+ [('lsa' , None , 'spm' ),
41+ ('lss' , None , 'spm' ),
42+ ('lss' , [0 , 1 , 2 , 3 , 4 ], 'fir' )])
43+ def test_nibs (
44+ bids_dir , deriv_dir , sub_fmriprep , sub_metadata , bold_file , preproc_file ,
45+ sub_events , confounds_file , brainmask_file , atlas_file , atlas_lut ,
46+ estimator , fir_delays , hrf_model , monkeypatch ):
47+ import sys
8848 bids_dir = str (bids_dir )
8949 out_dir = os .path .join (bids_dir , 'derivatives' )
90- assert call (["nibs" ,
91- "-a " + str (atlas_file ),
92- "-l " + str (atlas_lut ),
93- "-c WhiteMatter CSF" ,
94- "--high-pass 0.008" ,
95- "--estimator lsa" ,
96- "-sp MNI152NLin2009cAsym" ,
97- "-sm 0.0" ,
98- "--hrf-model spm" ,
99- "--session-label pre" ,
100- "--task-label waffles" ,
101- "--run-label 1" ,
102- "--description-label preproc" ,
103- "--graph" ,
104- bids_dir ,
105- "fmriprep" ,
106- out_dir ,
107- "participant" ])
50+ args = ["nibs" ,
51+ "-a" , str (atlas_file ),
52+ "-l" , str (atlas_lut ),
53+ "-c" , "WhiteMatter" , "CSF" ,
54+ "--high-pass" , "0.008" ,
55+ "--estimator" , estimator ,
56+ "-sp" , "MNI152NLin2009cAsym" ,
57+ "-sm" , "0.0" ,
58+ "--hrf-model" , hrf_model ,
59+ "--session-label" , "pre" ,
60+ "--task-label" , "waffles" ,
61+ "--run-label" , "1" ,
62+ "--description-label" , "preproc" ,
63+ "--graph" ,
64+ bids_dir ,
65+ "fmriprep" ,
66+ out_dir ,
67+ "participant" ]
68+ if fir_delays :
69+ args .append ('--fir-delays' )
70+ args .extend ([str (d ) for d in fir_delays ])
71+
72+ monkeypatch .setattr (sys , 'argv' , args )
73+ assert main () is None
10874
10975
11076def test_init (monkeypatch ):
@@ -114,7 +80,7 @@ def test_init(monkeypatch):
11480 run .init ()
11581
11682
117- def test_main (monkeypatch ):
83+ def test_deriv_directory (monkeypatch ):
11884 import sys
11985
12086 parser_args = [
@@ -131,3 +97,21 @@ def test_main(monkeypatch):
13197 main ()
13298
13399 assert "is not an available directory" in str (no_dir .value )
100+
101+
102+ def test_fir_delays (monkeypatch ):
103+ import sys
104+
105+ parser_args = [
106+ 'nibs' ,
107+ 'bids_dir' ,
108+ 'derivatives_pipeline' ,
109+ 'output_dir' ,
110+ 'participant' ,
111+ '--hrf-model' , 'fir' ,
112+ ]
113+ monkeypatch .setattr (sys , 'argv' , parser_args )
114+ with pytest .raises (ValueError ) as no_delays :
115+ main ()
116+
117+ assert "If the FIR HRF model is selected" in str (no_delays .value )
0 commit comments