TST: Add test to verify `MergeSeries` affine handling
@@ -155,3 +155,21 @@ def test_MergeSeries(tmp_path):
with pytest.raises(ValueError):
MergeSeries(in_files=[str(in_file)] + [str(in_4D)], allow_4D=False).run()
+
+
+def test_MergeSeries_affines(tmp_path):
+ os.chdir(str(tmp_path))
+
+ files = ['img0.nii.gz', 'img1.nii.gz']
+ data = np.ones((10, 10, 10), dtype=int)
+ aff = np.eye(4)
+ nb.Nifti1Image(data, aff, None).to_filename(files[0])
+ # slightly alter affine
+ aff[0][0] = 1.00005
+ nb.Nifti1Image(data, aff, None).to_filename(files[1])
+
+ # affine mismatch will cause this to fail
+ with pytest.raises(ValueError):
+ MergeSeries(in_files=files).run()
+ # but works if we set a tolerance
+ MergeSeries(in_files=files, affine_tolerance=1e-04).run()
