|
9 | 9 | import numpy as np
|
10 | 10 | import nibabel as nb
|
11 | 11 | from ..io.base import TransformFileError
|
12 |
| -from ..nonlinear import DisplacementsFieldTransform |
| 12 | +from ..nonlinear import DisplacementsFieldTransform, load as nlload |
13 | 13 | from ..io.itk import ITKDisplacementsField
|
14 | 14 | from ..io.afni import AFNIDisplacementsField
|
15 | 15 |
|
@@ -72,12 +72,7 @@ def test_displacements_field1(tmp_path, get_testdata, image_orientation, sw_tool
|
72 | 72 | field = nb.Nifti1Image(fieldmap, nii.affine, _hdr)
|
73 | 73 | field.to_filename(xfm_fname)
|
74 | 74 |
|
75 |
| - if sw_tool == 'itk': |
76 |
| - xfm = DisplacementsFieldTransform( |
77 |
| - ITKDisplacementsField.from_image(field)) |
78 |
| - elif sw_tool == 'afni': |
79 |
| - xfm = DisplacementsFieldTransform( |
80 |
| - AFNIDisplacementsField.from_image(field)) |
| 75 | + xfm = nlload(xfm_fname, fmt=sw_tool) |
81 | 76 |
|
82 | 77 | # Then apply the transform and cross-check with software
|
83 | 78 | cmd = APPLY_NONLINEAR_CMD[sw_tool](
|
@@ -108,12 +103,7 @@ def test_displacements_field2(tmp_path, data_path, sw_tool):
|
108 | 103 | img_fname = data_path / 'tpl-OASIS30ANTs_T1w.nii.gz'
|
109 | 104 | xfm_fname = data_path / 'ds-005_sub-01_from-OASIS_to-T1_warp_{}.nii.gz'.format(sw_tool)
|
110 | 105 |
|
111 |
| - if sw_tool == 'itk': |
112 |
| - xfm = DisplacementsFieldTransform( |
113 |
| - ITKDisplacementsField.from_filename(xfm_fname)) |
114 |
| - elif sw_tool == 'afni': |
115 |
| - xfm = DisplacementsFieldTransform( |
116 |
| - AFNIDisplacementsField.from_filename(xfm_fname)) |
| 106 | + xfm = nlload(xfm_fname, fmt=sw_tool) |
117 | 107 |
|
118 | 108 | # Then apply the transform and cross-check with software
|
119 | 109 | cmd = APPLY_NONLINEAR_CMD[sw_tool](
|
|
0 commit comments