Skip to content

Commit 140d61f

Browse files
committed
test: Validate _warp_dir behavior
1 parent 227f28b commit 140d61f

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

sdcflows/workflows/fit/tests/test_syn.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
_adjust_zooms,
3737
_set_dtype,
3838
_mm2vox,
39+
_warp_dir,
3940
)
4041

4142

@@ -317,3 +318,37 @@ def test_mm2vox(tmp_path, fixed_ornt, moving_ornt, ijk, index):
317318
mm_level[:2] == vox_level[:2] for mm_level, vox_level in zip(params, vox_params)
318319
]
319320
assert np.array_equal(vox_values, mm_values / [2, 3, 4][index])
321+
322+
323+
@pytest.mark.parametrize(
324+
("fixed_ornt", "moving_ornt", "ijk", "index"),
325+
[
326+
("RAS", "RAS", "i", 0),
327+
("RAS", "RAS", "j", 1),
328+
("RAS", "RAS", "k", 2),
329+
("RAS", "PSL", "i", 1),
330+
("RAS", "PSL", "j", 2),
331+
("RAS", "PSL", "k", 0),
332+
("PSL", "RAS", "i", 2),
333+
("PSL", "RAS", "j", 0),
334+
("PSL", "RAS", "k", 1),
335+
],
336+
)
337+
def test_warp_dir(tmp_path, fixed_ornt, moving_ornt, ijk, index):
338+
fixed_path = tmp_path / "fixed.nii.gz"
339+
moving_path = tmp_path / "moving.nii.gz"
340+
341+
nb.save(
342+
nb.Nifti1Image(np.zeros((10, 10, 10)), axcodes2aff(fixed_ornt)),
343+
fixed_path,
344+
)
345+
nb.save(
346+
nb.Nifti1Image(np.zeros((10, 10, 10)), axcodes2aff(moving_ornt)),
347+
moving_path,
348+
)
349+
350+
for nlevels in range(1, 3):
351+
deformations = _warp_dir(str(moving_path), str(fixed_path), ijk, nlevels)
352+
assert len(deformations) == nlevels
353+
for val in deformations:
354+
assert val == [1.0 if i == index else 0.1 for i in range(3)]

0 commit comments

Comments
 (0)