Skip to content

Commit f0822f9

Browse files
committed
wip: disable tests that will be addressed by #266
1 parent 0cc4a85 commit f0822f9

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

nitransforms/tests/test_resampling.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ def test_apply_linear_transform(
150150

151151

152152
@pytest.mark.xfail(
153-
reason="Disable while #266 is developed.",
153+
reason="GH-267: disabled while debugging",
154154
strict=False,
155155
)
156156
@pytest.mark.parametrize("image_orientation", ["RAS", "LAS", "LPS", "oblique"])
157157
@pytest.mark.parametrize("sw_tool", ["itk", "afni"])
158158
@pytest.mark.parametrize("axis", [0, 1, 2, (0, 1), (1, 2), (0, 1, 2)])
159-
def test_displacements_field1(
159+
def test_apply_displacements_field1(
160160
tmp_path,
161161
get_testdata,
162162
get_testmask,
@@ -190,18 +190,17 @@ def test_displacements_field1(
190190
else:
191191
field.to_filename(xfm_fname)
192192

193-
xfm = nitnl.load(xfm_fname, fmt=sw_tool)
194-
195-
import pdb; pdb.set_trace()
193+
# xfm = nitnl.load(xfm_fname, fmt=sw_tool)
194+
xfm = nitnl.DenseFieldTransform(fieldmap, reference=nii)
196195

196+
ants_output = tmp_path / "ants_brainmask.nii.gz"
197197
# Then apply the transform and cross-check with software
198198
cmd = APPLY_NONLINEAR_CMD[sw_tool](
199199
transform=os.path.abspath(xfm_fname),
200200
reference=tmp_path / "mask.nii.gz",
201201
moving=tmp_path / "mask.nii.gz",
202-
output=tmp_path / "resampled_brainmask.nii.gz",
203-
extra="",
204-
# extra="--output-data-type uchar" if sw_tool == "itk" else "",
202+
output=ants_output,
203+
extra="--output-data-type uchar" if sw_tool == "itk" else "",
205204
)
206205

207206
# skip test if command is not available on host
@@ -211,11 +210,13 @@ def test_displacements_field1(
211210

212211
# resample mask
213212
exit_code = check_call([cmd], shell=True)
214-
sw_moved_mask = nb.load("resampled_brainmask.nii.gz")
213+
assert exit_code == 0
214+
sw_moved_mask = nb.load(ants_output)
215215
nt_moved_mask = apply(xfm, msk, order=0)
216216

217-
# Calculate xor between both:
218-
sw_mask = np.asanyarray(sw_moved_mask.dataobj, dtype=bool)
217+
nt_moved_mask.to_filename(tmp_path / "nit_brainmask.nii.gz")
218+
219+
assert np.sqrt((diff**2).mean()) < RMSE_TOL_LINEAR
219220
brainmask = np.asanyarray(nt_moved_mask.dataobj, dtype=bool)
220221
percent_diff = (sw_mask != brainmask)[5:-5, 5:-5, 5:-5].sum() / brainmask.size
221222

@@ -249,7 +250,11 @@ def test_displacements_field1(
249250
assert np.sqrt((diff[5:-5, 5:-5, 5:-5] ** 2).mean()) < 1e-6
250251

251252

252-
@pytest.mark.parametrize("sw_tool", ["afni"])
253+
@pytest.mark.xfail(
254+
reason="GH-267: disabled while debugging",
255+
strict=False,
256+
)
257+
@pytest.mark.parametrize("sw_tool", ["itk", "afni"])
253258
def test_displacements_field2(tmp_path, testdata_path, sw_tool):
254259
"""Check a translation-only field on one or more axes, different image orientations."""
255260
os.chdir(str(tmp_path))
@@ -431,4 +436,4 @@ def test_apply_bspline(tmp_path, testdata_path):
431436
** 2
432437
).mean()
433438
< 0.2
434-
)
439+
)

0 commit comments

Comments
 (0)