@@ -125,33 +125,43 @@ def test_anat_fit_wf(
125
125
)
126
126
127
127
128
+ @pytest .mark .parametrize ("t1w" , [1 , 2 ])
129
+ @pytest .mark .parametrize ("t2w" , [0 , 1 ])
130
+ @pytest .mark .parametrize ("skull_strip_mode" , ['skip' , 'force' ])
128
131
@pytest .mark .parametrize ("t1w_preproc" , [False , True ])
129
132
@pytest .mark .parametrize ("t2w_preproc" , [False , True ])
130
133
@pytest .mark .parametrize ("t1w_mask" , [False , True ])
131
134
@pytest .mark .parametrize ("t1w_dseg" , [False , True ])
132
135
@pytest .mark .parametrize ("t1w_tpms" , [False , True ])
133
- @pytest .mark .parametrize ("t1w " , [1 , 2 ])
134
- @pytest .mark .parametrize ("t2w " , [0 , 1 ])
136
+ @pytest .mark .parametrize ("xfms " , [False , True ])
137
+ @pytest .mark .parametrize ("sphere_reg_msm " , [0 , 1 , 2 ])
135
138
def test_anat_fit_precomputes (
136
139
bids_root : Path ,
137
140
tmp_path : Path ,
141
+ t1w : int ,
142
+ t2w : int ,
143
+ skull_strip_mode : str ,
138
144
t1w_preproc : bool ,
139
145
t2w_preproc : bool ,
140
146
t1w_mask : bool ,
141
147
t1w_dseg : bool ,
142
148
t1w_tpms : bool ,
143
- t1w : int ,
144
- t2w : int ,
149
+ xfms : bool ,
150
+ sphere_reg_msm : int ,
145
151
):
152
+ """Test as many combinations of precomputed files and input
153
+ configurations as possible."""
146
154
output_dir = tmp_path / 'output'
147
155
output_dir .mkdir ()
148
156
157
+ # Construct inputs
149
158
t1w_list = [
150
159
str (bids_root / "sub-01" / "anat" / "sub-01_run-1_T1w.nii.gz" ),
151
160
str (bids_root / "sub-01" / "anat" / "sub-01_run-2_T1w.nii.gz" ),
152
161
][:t1w ]
153
162
t2w_list = [str (bids_root / "sub-01" / "anat" / "sub-01_T2w.nii.gz" )][:t2w ]
154
163
164
+ # Construct precomputed files
155
165
empty_img = nb .Nifti1Image (np .zeros ((1 , 1 , 1 )), np .eye (4 ))
156
166
precomputed = {}
157
167
if t1w_preproc :
@@ -168,6 +178,30 @@ def test_anat_fit_precomputes(
168
178
for path in precomputed .values ():
169
179
empty_img .to_filename (path )
170
180
181
+ precomputed ["sphere_reg_msm" ] = [
182
+ str (tmp_path / f"sub-01_hemi-{ hemi } _desc-msm_sphere.surf.gii" )
183
+ for hemi in ["L" , "R" ]
184
+ ][:sphere_reg_msm ]
185
+ for path in precomputed ["sphere_reg_msm" ]:
186
+ Path (path ).touch ()
187
+
188
+ if xfms :
189
+ transforms = precomputed ["transforms" ] = {}
190
+ transforms ["MNI152NLin2009cAsym" ] = {
191
+ "forward" : str (tmp_path / "MNI152NLin2009cAsym_forward_xfm.txt" ),
192
+ "reverse" : str (tmp_path / "MNI152NLin2009cAsym_reverse_xfm.txt" ),
193
+ }
194
+ transforms ["fsnative" ] = {
195
+ "forward" : str (tmp_path / "fsnative_forward_xfm.txt" ),
196
+ "reverse" : str (tmp_path / "fsnative_reverse_xfm.txt" ),
197
+ }
198
+
199
+ # Write dummy transforms
200
+ for xfm in transforms .values ():
201
+ for path in xfm .values ():
202
+ Path (path ).touch ()
203
+
204
+ # Create workflow
171
205
init_anat_fit_wf (
172
206
bids_root = str (bids_root ),
173
207
output_dir = str (output_dir ),
@@ -177,7 +211,7 @@ def test_anat_fit_precomputes(
177
211
msm_sulc = True ,
178
212
t1w = t1w_list ,
179
213
t2w = t2w_list ,
180
- skull_strip_mode = 'force' ,
214
+ skull_strip_mode = skull_strip_mode ,
181
215
skull_strip_template = Reference ("OASIS30ANTs" ),
182
216
spaces = SpatialReferences (
183
217
spaces = ["MNI152NLin2009cAsym" , "fsaverage5" ],
0 commit comments