Skip to content

Commit 832f584

Browse files
committed
TEST: Footer; FIX: Simplify defaults
1 parent 2b4c7cd commit 832f584

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

nibabel/freesurfer/mghformat.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,9 @@ def default_structarr(klass, endianness=None):
328328
structarr['type'] = 3
329329
structarr['ras_good'] = 1
330330
structarr['voxelsize'] = 1
331-
structarr['x_ras'] = [[-1], [0], [0]]
332-
structarr['y_ras'] = [[0], [0], [1]]
333-
structarr['z_ras'] = [[0], [-1], [0]]
334-
structarr['c_ras'] = 0
335-
structarr['mrparms'] = 0
331+
structarr['x_ras'][0] = -1
332+
structarr['y_ras'][2] = 1
333+
structarr['z_ras'][1] = -1
336334
return structarr
337335

338336
def _set_affine_default(self):

nibabel/freesurfer/tests/test_mghformat.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,11 @@ def test_read_mgh():
5555
assert_equal(h['dof'], 0)
5656
assert_equal(h['ras_good'], 1)
5757
assert_array_equal(h['dims'], [3, 4, 5, 2])
58-
assert_array_almost_equal(h['mrparms'], [2.0, 0.0, 0.0, 0.0])
59-
assert_array_almost_equal(h.get_zooms(), 1)
58+
assert_almost_equal(h['tr'], 2.0)
59+
assert_almost_equal(h['flip_angle'], 0.0)
60+
assert_almost_equal(h['te'], 0.0)
61+
assert_almost_equal(h['ti'], 0.0)
62+
assert_array_almost_equal(h.get_zooms(), [1, 1, 1, 2])
6063
assert_array_almost_equal(h.get_vox2ras(), v2r)
6164
assert_array_almost_equal(h.get_vox2ras_tkr(), v2rtkr)
6265

@@ -86,7 +89,11 @@ def test_write_mgh():
8689
assert_equal(h['dof'], 0)
8790
assert_equal(h['ras_good'], 1)
8891
assert_array_equal(h['dims'], [5, 4, 3, 2])
89-
assert_array_almost_equal(h['mrparms'], [0.0, 0.0, 0.0, 0.0])
92+
assert_almost_equal(h['tr'], 0.0)
93+
assert_almost_equal(h['flip_angle'], 0.0)
94+
assert_almost_equal(h['te'], 0.0)
95+
assert_almost_equal(h['ti'], 0.0)
96+
assert_almost_equal(h['fov'], 0.0)
9097
assert_array_almost_equal(h.get_vox2ras(), v2r)
9198
# data
9299
assert_almost_equal(dat, v, 7)
@@ -112,7 +119,11 @@ def test_write_noaffine_mgh():
112119
assert_equal(h['dof'], 0)
113120
assert_equal(h['ras_good'], 1)
114121
assert_array_equal(h['dims'], [7, 13, 3, 22])
115-
assert_array_almost_equal(h['mrparms'], [0.0, 0.0, 0.0, 0.0])
122+
assert_almost_equal(h['tr'], 0.0)
123+
assert_almost_equal(h['flip_angle'], 0.0)
124+
assert_almost_equal(h['te'], 0.0)
125+
assert_almost_equal(h['ti'], 0.0)
126+
assert_almost_equal(h['fov'], 0.0)
116127
# important part -- whether default affine info is stored
117128
assert_array_almost_equal(h['x_ras'].T, [[-1, 0, 0]])
118129
assert_array_almost_equal(h['y_ras'].T, [[0, 0, 1]])

0 commit comments

Comments
 (0)