Skip to content

Commit a078813

Browse files
committed
enh: linear lta read/write testing
1 parent bf2e90b commit a078813

File tree

4 files changed

+96
-3
lines changed

4 files changed

+96
-3
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
type = 1 # LINEAR_RAS_TO_RAS
2+
nxforms = 1
3+
mean = 0.0000 0.0000 0.0000
4+
sigma = 1.0000
5+
1 4 4
6+
9.999989867210388e-01 -9.999993490055203e-04 9.999998146668077e-04 4.000000000000000e+00
7+
1.404936308972538e-03 6.216088533401489e-01 -7.833265066146851e-01 2.000000000000000e+00
8+
1.617172238184139e-04 7.833271622657776e-01 6.216096282005310e-01 -1.000000000000000e+00
9+
0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00
10+
src volume info
11+
valid = 1 # volume info valid
12+
filename =
13+
volume = 57 67 56
14+
voxelsize = 2.750000000000000e+00 2.750000000000000e+00 2.750000000000000e+00
15+
xras = -1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
16+
yras = 0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
17+
zras = 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00
18+
cras = -2.375000000000000e+00 1.125000000000000e+00 -1.400000000000000e+01
19+
dst volume info
20+
valid = 1 # volume info valid
21+
filename =
22+
volume = 57 67 56
23+
voxelsize = 2.750000000000000e+00 2.750000000000000e+00 2.750000000000000e+00
24+
xras = -1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
25+
yras = 0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
26+
zras = 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00
27+
cras = -2.375000000000000e+00 1.125000000000000e+00 -1.400000000000000e+01
28+
subject
29+
fscale 0.000000
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
type = 1 # LINEAR_RAS_TO_RAS
2+
nxforms = 1
3+
mean = 0.0000 0.0000 0.0000
4+
sigma = 1.0000
5+
1 4 4
6+
9.999989867210388e-01 -9.999993490055203e-04 9.999998146668077e-04 4.000000000000000e+00
7+
1.404936308972538e-03 6.216088533401489e-01 -7.833265066146851e-01 2.000000000000000e+00
8+
1.617172238184139e-04 7.833271622657776e-01 6.216096282005310e-01 -1.000000000000000e+00
9+
0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00
10+
src volume info
11+
valid = 1 # volume info valid
12+
filename =
13+
volume = 57 67 56
14+
voxelsize = 2.750000000000000e+00 2.750000000000000e+00 2.750000000000000e+00
15+
xras = -1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
16+
yras = 0.000000000000000e+00 -1.000000000000000e+00 0.000000000000000e+00
17+
zras = 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00
18+
cras = -2.375000000000000e+00 -1.625000000000000e+00 -1.400000000000000e+01
19+
dst volume info
20+
valid = 1 # volume info valid
21+
filename =
22+
volume = 57 67 56
23+
voxelsize = 2.750000000000000e+00 2.750000000000000e+00 2.750000000000000e+00
24+
xras = -1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
25+
yras = 0.000000000000000e+00 -1.000000000000000e+00 0.000000000000000e+00
26+
zras = 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00
27+
cras = -2.375000000000000e+00 -1.625000000000000e+00 -1.400000000000000e+01
28+
subject
29+
fscale 0.000000
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
type = 1 # LINEAR_RAS_TO_RAS
2+
nxforms = 1
3+
mean = 0.0000 0.0000 0.0000
4+
sigma = 1.0000
5+
1 4 4
6+
9.999989867210388e-01 -9.999993490055203e-04 9.999998146668077e-04 4.000000000000000e+00
7+
1.404936308972538e-03 6.216088533401489e-01 -7.833265066146851e-01 2.000000000000000e+00
8+
1.617172238184139e-04 7.833271622657776e-01 6.216096282005310e-01 -1.000000000000000e+00
9+
0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00
10+
src volume info
11+
valid = 1 # volume info valid
12+
filename =
13+
volume = 57 67 56
14+
voxelsize = 2.750000000000000e+00 2.750000000000000e+00 2.750000000000000e+00
15+
xras = 1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
16+
yras = 0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
17+
zras = 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00
18+
cras = 3.750000000000000e-01 1.125000000000000e+00 -1.400000000000000e+01
19+
dst volume info
20+
valid = 1 # volume info valid
21+
filename =
22+
volume = 57 67 56
23+
voxelsize = 2.750000000000000e+00 2.750000000000000e+00 2.750000000000000e+00
24+
xras = 1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
25+
yras = 0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
26+
zras = 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00
27+
cras = 3.750000000000000e-01 1.125000000000000e+00 -1.400000000000000e+01
28+
subject
29+
fscale 0.000000

nitransforms/tests/test_transform.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
'afni': """\
2828
3dAllineate -base {reference} -input {moving} \
2929
-prefix resampled.nii.gz -1Dmatrix_apply {transform} -final NN\
30-
""".format,
30+
""".format,-
3131
}
3232

3333

3434
@pytest.mark.xfail(reason="Not fully implemented")
3535
@pytest.mark.parametrize('image_orientation', [
3636
'RAS', 'LAS', 'LPS', # 'oblique',
3737
])
38-
@pytest.mark.parametrize('sw_tool', ['itk', 'fsl', 'afni'])
38+
@pytest.mark.parametrize('sw_tool', ['itk', 'fsl', 'afni', 'fs'])
3939
def test_linear_load(tmpdir, data_path, get_data, image_orientation, sw_tool):
4040
"""Check implementation of loading affines from formats."""
4141
tmpdir.chdir()
@@ -51,6 +51,8 @@ def test_linear_load(tmpdir, data_path, get_data, image_orientation, sw_tool):
5151
ext = ''
5252
if sw_tool == 'itk':
5353
ext = '.tfm'
54+
elif sw_tool == 'fs':
55+
ext = '.lta'
5456

5557
fname = 'affine-%s.%s%s' % (image_orientation, sw_tool, ext)
5658
xfm_fname = os.path.join(data_path, fname)
@@ -74,14 +76,16 @@ def test_linear_load(tmpdir, data_path, get_data, image_orientation, sw_tool):
7476
loaded = nbl.load(xfm_fname, fmt=fmt, reference='img.nii.gz')
7577
elif sw_tool == 'itk':
7678
loaded = nbl.load(xfm_fname, fmt=fmt)
79+
elif sw_tool == 'fs':
80+
loaded = nbl.load(xfm_fname, fmt=fmt)
7781

7882
assert loaded == xfm
7983

8084

8185
@pytest.mark.parametrize('image_orientation', [
8286
'RAS', 'LAS', 'LPS', # 'oblique',
8387
])
84-
@pytest.mark.parametrize('sw_tool', ['itk', 'fsl', 'afni'])
88+
@pytest.mark.parametrize('sw_tool', ['itk', 'fsl', 'afni', 'fs'])
8589
def test_linear_save(data_path, get_data, image_orientation, sw_tool):
8690
"""Check implementation of exporting affines to formats."""
8791
img = get_data[image_orientation]
@@ -93,6 +97,8 @@ def test_linear_save(data_path, get_data, image_orientation, sw_tool):
9397
ext = ''
9498
if sw_tool == 'itk':
9599
ext = '.tfm'
100+
elif sw_tool == 'fs':
101+
ext = '.lta'
96102

97103
with InTemporaryDirectory():
98104
xfm_fname1 = 'M.%s%s' % (sw_tool, ext)

0 commit comments

Comments
 (0)