|
9 | 9 | from numpy import array as npa |
10 | 10 |
|
11 | 11 | from .. import load as top_load |
12 | | -from ..nifti1 import Nifti1Image, Nifti1Extension |
| 12 | +from ..nifti1 import Nifti1Image, Nifti1Extension, Nifti1Header |
13 | 13 | from .. import parrec |
14 | 14 | from ..parrec import (parse_PAR_header, PARRECHeader, PARRECError, vol_numbers, |
15 | 15 | vol_is_full, PARRECImage, PARRECArrayProxy, exts2pars) |
@@ -549,6 +549,18 @@ def test_epi_params(): |
549 | 549 | assert_almost_equal(epi_hdr.get_zooms()[-1], 2.0) |
550 | 550 |
|
551 | 551 |
|
| 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 | + |
552 | 564 | def test_truncations(): |
553 | 565 | # Test tests for truncation |
554 | 566 | par = pjoin(DATA_PATH, 'T2_.PAR') |
|
0 commit comments