Skip to content

Commit

Permalink
TEST: Footer; FIX: Simplify defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Oct 28, 2017
1 parent 2b4c7cd commit 832f584
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
8 changes: 3 additions & 5 deletions nibabel/freesurfer/mghformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,9 @@ def default_structarr(klass, endianness=None):
structarr['type'] = 3
structarr['ras_good'] = 1
structarr['voxelsize'] = 1
structarr['x_ras'] = [[-1], [0], [0]]
structarr['y_ras'] = [[0], [0], [1]]
structarr['z_ras'] = [[0], [-1], [0]]
structarr['c_ras'] = 0
structarr['mrparms'] = 0
structarr['x_ras'][0] = -1
structarr['y_ras'][2] = 1
structarr['z_ras'][1] = -1
return structarr

def _set_affine_default(self):
Expand Down
19 changes: 15 additions & 4 deletions nibabel/freesurfer/tests/test_mghformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ def test_read_mgh():
assert_equal(h['dof'], 0)
assert_equal(h['ras_good'], 1)
assert_array_equal(h['dims'], [3, 4, 5, 2])
assert_array_almost_equal(h['mrparms'], [2.0, 0.0, 0.0, 0.0])
assert_array_almost_equal(h.get_zooms(), 1)
assert_almost_equal(h['tr'], 2.0)
assert_almost_equal(h['flip_angle'], 0.0)
assert_almost_equal(h['te'], 0.0)
assert_almost_equal(h['ti'], 0.0)
assert_array_almost_equal(h.get_zooms(), [1, 1, 1, 2])
assert_array_almost_equal(h.get_vox2ras(), v2r)
assert_array_almost_equal(h.get_vox2ras_tkr(), v2rtkr)

Expand Down Expand Up @@ -86,7 +89,11 @@ def test_write_mgh():
assert_equal(h['dof'], 0)
assert_equal(h['ras_good'], 1)
assert_array_equal(h['dims'], [5, 4, 3, 2])
assert_array_almost_equal(h['mrparms'], [0.0, 0.0, 0.0, 0.0])
assert_almost_equal(h['tr'], 0.0)
assert_almost_equal(h['flip_angle'], 0.0)
assert_almost_equal(h['te'], 0.0)
assert_almost_equal(h['ti'], 0.0)
assert_almost_equal(h['fov'], 0.0)
assert_array_almost_equal(h.get_vox2ras(), v2r)
# data
assert_almost_equal(dat, v, 7)
Expand All @@ -112,7 +119,11 @@ def test_write_noaffine_mgh():
assert_equal(h['dof'], 0)
assert_equal(h['ras_good'], 1)
assert_array_equal(h['dims'], [7, 13, 3, 22])
assert_array_almost_equal(h['mrparms'], [0.0, 0.0, 0.0, 0.0])
assert_almost_equal(h['tr'], 0.0)
assert_almost_equal(h['flip_angle'], 0.0)
assert_almost_equal(h['te'], 0.0)
assert_almost_equal(h['ti'], 0.0)
assert_almost_equal(h['fov'], 0.0)
# important part -- whether default affine info is stored
assert_array_almost_equal(h['x_ras'].T, [[-1, 0, 0]])
assert_array_almost_equal(h['y_ras'].T, [[0, 0, 1]])
Expand Down

0 comments on commit 832f584

Please sign in to comment.