|
36 | 36 | _adjust_zooms, |
37 | 37 | _set_dtype, |
38 | 38 | _mm2vox, |
| 39 | + _warp_dir, |
39 | 40 | ) |
40 | 41 |
|
41 | 42 |
|
@@ -317,3 +318,37 @@ def test_mm2vox(tmp_path, fixed_ornt, moving_ornt, ijk, index): |
317 | 318 | mm_level[:2] == vox_level[:2] for mm_level, vox_level in zip(params, vox_params) |
318 | 319 | ] |
319 | 320 | 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