Skip to content

Commit c5ca00f

Browse files
committed
TEST: Test precomputed transforms
1 parent 849fa41 commit c5ca00f

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

smriprep/workflows/tests/test_anatomical.py

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,33 +125,43 @@ def test_anat_fit_wf(
125125
)
126126

127127

128+
@pytest.mark.parametrize("t1w", [1, 2])
129+
@pytest.mark.parametrize("t2w", [0, 1])
130+
@pytest.mark.parametrize("skull_strip_mode", ['skip', 'force'])
128131
@pytest.mark.parametrize("t1w_preproc", [False, True])
129132
@pytest.mark.parametrize("t2w_preproc", [False, True])
130133
@pytest.mark.parametrize("t1w_mask", [False, True])
131134
@pytest.mark.parametrize("t1w_dseg", [False, True])
132135
@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])
135138
def test_anat_fit_precomputes(
136139
bids_root: Path,
137140
tmp_path: Path,
141+
t1w: int,
142+
t2w: int,
143+
skull_strip_mode: str,
138144
t1w_preproc: bool,
139145
t2w_preproc: bool,
140146
t1w_mask: bool,
141147
t1w_dseg: bool,
142148
t1w_tpms: bool,
143-
t1w: int,
144-
t2w: int,
149+
xfms: bool,
150+
sphere_reg_msm: int,
145151
):
152+
"""Test as many combinations of precomputed files and input
153+
configurations as possible."""
146154
output_dir = tmp_path / 'output'
147155
output_dir.mkdir()
148156

157+
# Construct inputs
149158
t1w_list = [
150159
str(bids_root / "sub-01" / "anat" / "sub-01_run-1_T1w.nii.gz"),
151160
str(bids_root / "sub-01" / "anat" / "sub-01_run-2_T1w.nii.gz"),
152161
][:t1w]
153162
t2w_list = [str(bids_root / "sub-01" / "anat" / "sub-01_T2w.nii.gz")][:t2w]
154163

164+
# Construct precomputed files
155165
empty_img = nb.Nifti1Image(np.zeros((1, 1, 1)), np.eye(4))
156166
precomputed = {}
157167
if t1w_preproc:
@@ -168,6 +178,30 @@ def test_anat_fit_precomputes(
168178
for path in precomputed.values():
169179
empty_img.to_filename(path)
170180

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
171205
init_anat_fit_wf(
172206
bids_root=str(bids_root),
173207
output_dir=str(output_dir),
@@ -177,7 +211,7 @@ def test_anat_fit_precomputes(
177211
msm_sulc=True,
178212
t1w=t1w_list,
179213
t2w=t2w_list,
180-
skull_strip_mode='force',
214+
skull_strip_mode=skull_strip_mode,
181215
skull_strip_template=Reference("OASIS30ANTs"),
182216
spaces=SpatialReferences(
183217
spaces=["MNI152NLin2009cAsym", "fsaverage5"],

0 commit comments

Comments
 (0)