Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfa73ad4

Browse files
committed
TEST: Test MGHHeader._HeaderData fully
1 parent3f62445 commitfa73ad4

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

‎nibabel/freesurfer/tests/test_mghformat.py‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,12 @@ def test_mghheader_default_structarr():
340340

341341
deftest_deprecated_fields():
342342
hdr=MGHHeader()
343+
hdr_data=MGHHeader._HeaderData(hdr.structarr)
343344

344345
# mrparams is the only deprecated field at the moment
346+
# Accessing hdr_data is equivalent to accessing hdr, so double all checks
345347
assert_array_equal(hdr['mrparams'],0)
348+
assert_array_equal(hdr_data['mrparams'],0)
346349

347350
hdr['mrparams']= [1,2,3,4]
348351
assert_array_almost_equal(hdr['mrparams'], [1,2,3,4])
@@ -351,12 +354,26 @@ def test_deprecated_fields():
351354
assert_equal(hdr['te'],3)
352355
assert_equal(hdr['ti'],4)
353356
assert_equal(hdr['fov'],0)
357+
assert_array_almost_equal(hdr_data['mrparams'], [1,2,3,4])
358+
assert_equal(hdr_data['tr'],1)
359+
assert_equal(hdr_data['flip_angle'],2)
360+
assert_equal(hdr_data['te'],3)
361+
assert_equal(hdr_data['ti'],4)
362+
assert_equal(hdr_data['fov'],0)
354363

355364
hdr['tr']=5
356365
hdr['flip_angle']=6
357366
hdr['te']=7
358367
hdr['ti']=8
359368
assert_array_almost_equal(hdr['mrparams'], [5,6,7,8])
369+
assert_array_almost_equal(hdr_data['mrparams'], [5,6,7,8])
370+
371+
hdr_data['tr']=9
372+
hdr_data['flip_angle']=10
373+
hdr_data['te']=11
374+
hdr_data['ti']=12
375+
assert_array_almost_equal(hdr['mrparams'], [9,10,11,12])
376+
assert_array_almost_equal(hdr_data['mrparams'], [9,10,11,12])
360377

361378

362379
classTestMGHImage(tsi.TestSpatialImage,tsi.MmapImageMixin):
@@ -379,7 +396,7 @@ def _set_something_into_hdr(self, hdr):
379396
hdr['dims']= [4,3,2,1]
380397

381398
defget_bad_bb(self):
382-
returnb'\xff'+bytes(self.header_class._hdrdtype.itemsize)
399+
returnb'\xff'+b'\x00'*self.header_class._hdrdtype.itemsize
383400

384401
# Update tests to account for big-endian requirement
385402
deftest_general_init(self):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp