Skip to content

Commit 7759954

Browse files
committed
TEST: Verify that header conversion preserves units
1 parent 8333780 commit 7759954

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

nibabel/tests/test_parrec.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from numpy import array as npa
1010

1111
from .. import load as top_load
12-
from ..nifti1 import Nifti1Image, Nifti1Extension
12+
from ..nifti1 import Nifti1Image, Nifti1Extension, Nifti1Header
1313
from .. import parrec
1414
from ..parrec import (parse_PAR_header, PARRECHeader, PARRECError, vol_numbers,
1515
vol_is_full, PARRECImage, PARRECArrayProxy, exts2pars)
@@ -549,6 +549,18 @@ def test_epi_params():
549549
assert_almost_equal(epi_hdr.get_zooms()[-1], 2.0)
550550

551551

552+
def test_xyzt_unit_conversion():
553+
# Check conversion to NIfTI-like has sensible units
554+
for par_root in ('T2_-interleaved', 'T2_', 'phantom_EPI_asc_CLEAR_2_1'):
555+
epi_par = pjoin(DATA_PATH, par_root + '.PAR')
556+
with open(epi_par, 'rt') as fobj:
557+
epi_hdr = PARRECHeader.from_fileobj(fobj)
558+
nifti_hdr = Nifti1Header.from_header(epi_hdr)
559+
assert len(nifti_hdr.get_data_shape()) == 4
560+
assert_almost_equal(nifti_hdr.get_zooms()[-1], 2.0)
561+
assert nifti_hdr.get_xyzt_units() == ('mm', 'sec')
562+
563+
552564
def test_truncations():
553565
# Test tests for truncation
554566
par = pjoin(DATA_PATH, 'T2_.PAR')

0 commit comments

Comments
 (0)