Skip to content

Commit fdb9dbc

Browse files
committed
TST: Add non-RAS orientation
1 parent 46f8ca8 commit fdb9dbc

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

sdcflows/interfaces/tests/test_utils.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,25 @@ def test_Xeoblique(tmpdir, angles, oblique):
117117
def test_pad_slices(tmpdir, in_shape, expected_shape, padded):
118118
tmpdir.chdir()
119119

120-
img = nb.Nifti1Image(np.zeros(in_shape), np.eye(4))
121-
img.to_filename("epi.nii.gz")
122-
res = PadSlices(in_file="epi.nii.gz").run().outputs
123-
124-
out_file = nb.load(res.out_file)
125-
assert out_file.shape == expected_shape
120+
data = np.random.rand(*in_shape)
121+
aff = np.eye(4)
122+
123+
# RAS
124+
img = nb.Nifti1Image(data, aff)
125+
img.to_filename("epi-ras.nii.gz")
126+
res = PadSlices(in_file="epi-ras.nii.gz").run().outputs
127+
128+
# LPS
129+
newaff = aff.copy()
130+
newaff[0, 0] *= -1.0
131+
newaff[1, 1] *= -1.0
132+
newaff[:2, 3] = aff.dot(np.hstack((np.array(img.shape[:3]) - 1, 1.0)))[:2]
133+
img2 = nb.Nifti1Image(np.flip(np.flip(data, 0), 1), newaff)
134+
img2.to_filename("epi-lps.nii.gz")
135+
res2 = PadSlices(in_file="epi-lps.nii.gz").run().outputs
136+
137+
138+
out_ras = nb.load(res.out_file)
139+
out_lps = nb.load(res2.out_file)
140+
assert out_ras.shape == out_lps == expected_shape
126141
assert res.padded == padded

0 commit comments

Comments
 (0)