Skip to content

BF: fix repetition time in PARREC header #692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nibabel/parrec.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,11 +897,11 @@ def _calc_zooms(self):
zooms[:2] = self._get_unique_image_prop('pixel spacing')
slice_thickness = self._get_unique_image_prop('slice thickness')
zooms[2] = slice_thickness + slice_gap
# If 4D dynamic scan, convert time from milliseconds to seconds
# If 4D dynamic scan, save repetition time in miliseconds
if len(zooms) > 3 and self.general_info['dyn_scan']:
if len(self.general_info['repetition_time']) > 1:
warnings.warn("multiple TRs found in .PAR file")
zooms[3] = self.general_info['repetition_time'][0] / 1000.
zooms[3] = self.general_info['repetition_time'][0]
return zooms

def get_affine(self, origin='scanner'):
Expand Down
8 changes: 4 additions & 4 deletions nibabel/tests/test_parrec.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
# We disagree with Philips about the right affine, for the moment, so
# use our own affine as determined from a previous load in nibabel
affine=AN_OLD_AFFINE,
zooms=(3.75, 3.75, 8.0, 2.0),
zooms=(3.75, 3.75, 8.0, 2000.0),
data_summary=dict(
min=0.0,
max=2299.4110643863678,
Expand Down Expand Up @@ -179,7 +179,7 @@ def test_header():
hdr = PARRECHeader(HDR_INFO, HDR_DEFS)
assert_equal(hdr.get_data_shape(), (64, 64, 9, 3))
assert_equal(hdr.get_data_dtype(), np.dtype('<u2'))
assert_equal(hdr.get_zooms(), (3.75, 3.75, 8.0, 2.0))
assert_equal(hdr.get_zooms(), (3.75, 3.75, 8.0, 2000.0))
assert_equal(hdr.get_data_offset(), 0)
si = np.array(
[np.unique(x) for x in hdr.get_data_scaling()]).ravel()
Expand Down Expand Up @@ -548,7 +548,7 @@ def test_epi_params():
with open(epi_par, 'rt') as fobj:
epi_hdr = PARRECHeader.from_fileobj(fobj)
assert_equal(len(epi_hdr.get_data_shape()), 4)
assert_almost_equal(epi_hdr.get_zooms()[-1], 2.0)
assert_almost_equal(epi_hdr.get_zooms()[-1], 2000.0)


def test_truncations():
Expand Down Expand Up @@ -832,7 +832,7 @@ def test_dualTR():
assert_array_equal(dualTR_hdr.general_info['repetition_time'],
expected_TRs)
# zoom on 4th dimensions is the first TR (in seconds)
assert_equal(dualTR_hdr.get_zooms()[3], expected_TRs[0]/1000)
assert_equal(dualTR_hdr.get_zooms()[3], expected_TRs[0])


def test_ADC_map():
Expand Down