|
21 | 21 | # https://www.nipreps.org/community/licensing/
|
22 | 22 | #
|
23 | 23 | """Test fieldmap-less SDC-SyN."""
|
| 24 | + |
24 | 25 | import json
|
25 | 26 | import pytest
|
26 | 27 | from nipype.pipeline import engine as pe
|
@@ -145,6 +146,30 @@ def test_syn_wf(tmpdir, datadir, workdir, outdir, sloppy_mode, sd_prior):
|
145 | 146 | wf.run(plugin="Linear")
|
146 | 147 |
|
147 | 148 |
|
| 149 | +@pytest.mark.parametrize("laplacian_weight", [None, (0.5, 0.1), (0.8, -1.0)]) |
| 150 | +@pytest.mark.parametrize("sloppy", [True, False]) |
| 151 | +def test_syn_wf_inputs(sloppy, laplacian_weight): |
| 152 | + """Test the input validation of the SDC-SyN workflow.""" |
| 153 | + from sdcflows.workflows.fit.syn import MAX_LAPLACIAN_WEIGHT |
| 154 | + |
| 155 | + laplacian_weight = ( |
| 156 | + (0.1, 0.2) |
| 157 | + if laplacian_weight is None |
| 158 | + else ( |
| 159 | + max(min(laplacian_weight[0], MAX_LAPLACIAN_WEIGHT), 0.0), |
| 160 | + max(min(laplacian_weight[1], MAX_LAPLACIAN_WEIGHT), 0.0), |
| 161 | + ) |
| 162 | + ) |
| 163 | + metric_weight = [ |
| 164 | + [1.0 - laplacian_weight[0], laplacian_weight[0]], |
| 165 | + [1.0 - laplacian_weight[1], laplacian_weight[1]], |
| 166 | + ] |
| 167 | + |
| 168 | + wf = init_syn_sdc_wf(sloppy=sloppy, laplacian_weight=laplacian_weight) |
| 169 | + |
| 170 | + assert wf.inputs.syn.metric_weight == metric_weight |
| 171 | + |
| 172 | + |
148 | 173 | @pytest.mark.parametrize("ants_version", ["2.2.0", "2.1.0", None])
|
149 | 174 | def test_syn_wf_version(monkeypatch, ants_version):
|
150 | 175 | """Ensure errors are triggered with ANTs < 2.2."""
|
@@ -188,12 +213,15 @@ def test_adjust_zooms(anat_res, epi_res, retval, tmpdir, datadir):
|
188 | 213 | assert _adjust_zooms("anat.nii.gz", "epi.nii.gz") == retval
|
189 | 214 |
|
190 | 215 |
|
191 |
| -@pytest.mark.parametrize("in_dtype,out_dtype", [ |
192 |
| - ("float32", "int16"), |
193 |
| - ("int16", "int16"), |
194 |
| - ("uint8", "int16"), |
195 |
| - ("float64", "int16"), |
196 |
| -]) |
| 216 | +@pytest.mark.parametrize( |
| 217 | + "in_dtype,out_dtype", |
| 218 | + [ |
| 219 | + ("float32", "int16"), |
| 220 | + ("int16", "int16"), |
| 221 | + ("uint8", "int16"), |
| 222 | + ("float64", "int16"), |
| 223 | + ], |
| 224 | +) |
197 | 225 | def test_ensure_dtype(in_dtype, out_dtype, tmpdir):
|
198 | 226 | """Exercise the set dtype function node."""
|
199 | 227 | import numpy as np
|
|
0 commit comments