Skip to content

Commit d800abb

Browse files
committed
ENH: support multiple TR values in PARREC headers
1 parent 23bc068 commit d800abb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

nibabel/parrec.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
'Technique': ('tech',),
149149
'Scan resolution (x, y)': ('scan_resolution', int, (2,)),
150150
'Scan mode': ('scan_mode',),
151-
'Repetition time [ms]': ('repetition_time', float),
151+
'Repetition time [ms]': ('repetition_time', float, None),
152152
'FOV (ap,fh,rl) [mm]': ('fov', float, (3,)),
153153
'Water Fat shift [pixels]': ('water_fat_shift', float),
154154
'Angulation midslice(ap,fh,rl)[degr]': ('angulation', float, (3,)),
@@ -295,7 +295,9 @@ def _process_gen_dict(gen_dict):
295295
elif len(props) == 3:
296296
# array with dtype and shape
297297
value = np.fromstring(value, props[1], sep=' ')
298-
value.shape = props[2]
298+
# if shape is None, allow arbitrary length
299+
if props[2] is not None:
300+
value.shape = props[2]
299301
general_info[props[0]] = value
300302
return general_info
301303

@@ -842,7 +844,9 @@ def _calc_zooms(self):
842844
zooms[2] = slice_thickness + slice_gap
843845
# If 4D dynamic scan, convert time from milliseconds to seconds
844846
if len(zooms) > 3 and self.general_info['dyn_scan']:
845-
zooms[3] = self.general_info['repetition_time'] / 1000.
847+
if len(self.general_info['repetition_time']) > 1:
848+
warnings.warn("multiple TRs found in .PAR file")
849+
zooms[3] = self.general_info['repetition_time'][0] / 1000.
846850
return zooms
847851

848852
def get_affine(self, origin='scanner'):

0 commit comments

Comments
 (0)