diff --git a/bin/parrec2nii b/bin/parrec2nii index 09bb1b1b9f..547fb94e01 100755 --- a/bin/parrec2nii +++ b/bin/parrec2nii @@ -185,7 +185,7 @@ def proc_file(infile, opts): bvals, bvecs = pr_hdr.get_bvals_bvecs() if not opts.keep_trace: # discard Philips DTI trace if present - if bvals is not None: + if bvecs is not None: bad_mask = np.logical_and(bvals != 0, (bvecs == 0).all(axis=1)) if bad_mask.sum() > 0: pl = 's' if bad_mask.sum() != 1 else '' @@ -229,6 +229,14 @@ def proc_file(infile, opts): if opts.bvs: if bvals is None and bvecs is None: verbose('No DTI volumes detected, bvals and bvecs not written') + elif bvecs is None: + verbose('DTI volumes detected, but no diffusion direction info was' + 'found. Writing .bvals file only.') + with open(basefilename + '.bvals', 'w') as fid: + # np.savetxt could do this, but it's just a loop anyway + for val in bvals: + fid.write('%s ' % val) + fid.write('\n') else: verbose('Writing .bvals and .bvecs files') # Transform bvecs with reorientation affine diff --git a/nibabel/parrec.py b/nibabel/parrec.py index 5e85c411f5..bf40b0a78f 100644 --- a/nibabel/parrec.py +++ b/nibabel/parrec.py @@ -703,7 +703,7 @@ def get_q_vectors(self): acquisition. """ bvals, bvecs = self.get_bvals_bvecs() - if bvals is None and bvecs is None: + if bvals is None or bvecs is None: return None return bvecs * bvals[:, np.newaxis] @@ -728,6 +728,8 @@ def get_bvals_bvecs(self): # All bvals within volume should be the same assert not np.any(np.diff(bvals, axis=0)) bvals = bvals[0] + if 'diffusion' not in self.image_defs.dtype.names: + return bvals, None bvecs = self.image_defs['diffusion'][reorder].reshape( (n_slices, n_vols, 3), order='F') # All 3 values of bvecs should be same within volume diff --git a/nibabel/tests/data/DTIv40.PAR b/nibabel/tests/data/DTIv40.PAR new file mode 100644 index 0000000000..14238a926d --- /dev/null +++ b/nibabel/tests/data/DTIv40.PAR @@ -0,0 +1,177 @@ +# === DATA DESCRIPTION FILE ====================================================== +# +# CAUTION - Investigational device. +# Limited by Federal Law to investigational use. +# +# Dataset name: H:\Export\05aug14_test_samples_12_1 +# +# CLINICAL TRYOUT Research image export tool V4 +# +# Note: This is a simulated V4 .PAR file created from a V4.2 .PAR file by +# truncating the columns/fields that were not present in V4. +# +# +# === GENERAL INFORMATION ======================================================== +# +. Patient name : 05aug14test +. Examination name : test +. Protocol name : WIP DTI SENSE +. Examination date/time : 2014.08.05 / 11:27:34 +. Series Type : Image MRSERIES +. Acquisition nr : 12 +. Reconstruction nr : 1 +. Scan Duration [sec] : 10.5 +. Max. number of cardiac phases : 1 +. Max. number of echoes : 1 +. Max. number of slices/locations : 10 +. Max. number of dynamics : 1 +. Max. number of mixes : 1 +. Patient position : Head First Supine +. Preparation direction : Right-Left +. Technique : DwiSE +. Scan resolution (x, y) : 76 62 +. Scan mode : MS +. Repetition time [ms] : 1166.614 +. FOV (ap,fh,rl) [mm] : 130.000 120.970 154.375 +. Water Fat shift [pixels] : 9.087 +. Angulation midslice(ap,fh,rl)[degr]: -1.979 0.546 0.019 +. Off Centre midslice(ap,fh,rl) [mm] : -18.805 22.157 -17.977 +. Flow compensation <0=no 1=yes> ? : 0 +. Presaturation <0=no 1=yes> ? : 0 +. Phase encoding velocity [cm/sec] : 0.000000 0.000000 0.000000 +. MTC <0=no 1=yes> ? : 0 +. SPIR <0=no 1=yes> ? : 1 +. EPI factor <0,1=no EPI> : 27 +. Dynamic scan <0=no 1=yes> ? : 0 +. Diffusion <0=no 1=yes> ? : 1 +. Diffusion echo time [ms] : 0.0000 +# +# === PIXEL VALUES ============================================================= +# PV = pixel value in REC file, FP = floating point value, DV = displayed value on console +# RS = rescale slope, RI = rescale intercept, SS = scale slope +# DV = PV * RS + RI FP = DV / (RS * SS) +# +# === IMAGE INFORMATION DEFINITION ============================================= +# The rest of this file contains ONE line per image, this line contains the following information: +# +# slice number (integer) +# echo number (integer) +# dynamic scan number (integer) +# cardiac phase number (integer) +# image_type_mr (integer) +# scanning sequence (integer) +# index in REC file (in images) (integer) +# image pixel size (in bits) (integer) +# scan percentage (integer) +# recon resolution (x y) (2*integer) +# rescale intercept (float) +# rescale slope (float) +# scale slope (float) +# window center (integer) +# window width (integer) +# image angulation (ap,fh,rl in degrees ) (3*float) +# image offcentre (ap,fh,rl in mm ) (3*float) +# slice thickness (in mm ) (float) +# slice gap (in mm ) (float) +# image_display_orientation (integer) +# slice orientation ( TRA/SAG/COR ) (integer) +# fmri_status_indication (integer) +# image_type_ed_es (end diast/end syst) (integer) +# pixel spacing (x,y) (in mm) (2*float) +# echo_time (float) +# dyn_scan_begin_time (float) +# trigger_time (float) +# diffusion_b_factor (float) +# number of averages (integer) +# image_flip_angle (in degrees) (float) +# cardiac frequency (bpm) (integer) +# minimum RR-interval (in ms) (integer) +# maximum RR-interval (in ms) (integer) +# TURBO factor <0=no turbo> (integer) +# Inversion delay (in ms) (float) +# +# === IMAGE INFORMATION ========================================================== +# sl ec dyn ph ty idx pix scan% rec size (re)scale window angulation offcentre thick gap info spacing echo dtime ttime diff avg flip freq RR-int turbo delay + + 1 1 1 1 0 1 0 16 81 80 80 0.00000 22.15092 1.35565e-003 69 120 -1.98 0.55 0.02 -18.79 -33.29 -16.06 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 2 1 1 1 0 1 1 16 81 80 80 0.00000 22.15092 1.35565e-003 322 560 -1.98 0.55 0.02 -18.79 -20.97 -16.49 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 3 1 1 1 0 1 2 16 81 80 80 0.00000 22.15092 1.35565e-003 688 1195 -1.98 0.55 0.02 -18.80 -8.65 -16.91 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 4 1 1 1 0 1 3 16 81 80 80 0.00000 22.15092 1.35565e-003 1407 2447 -1.98 0.55 0.02 -18.80 3.67 -17.34 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 5 1 1 1 0 1 4 16 81 80 80 0.00000 22.15092 1.35565e-003 653 1135 -1.98 0.55 0.02 -18.80 16.00 -17.76 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 6 1 1 1 0 1 5 16 81 80 80 0.00000 22.15092 1.35565e-003 502 873 -1.98 0.55 0.02 -18.81 28.32 -18.19 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 7 1 1 1 0 1 6 16 81 80 80 0.00000 22.15092 1.35565e-003 365 635 -1.98 0.55 0.02 -18.81 40.64 -18.62 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 8 1 1 1 0 1 7 16 81 80 80 0.00000 22.15092 1.35565e-003 301 524 -1.98 0.55 0.02 -18.82 52.96 -19.04 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 9 1 1 1 0 1 8 16 81 80 80 0.00000 22.15092 1.35565e-003 450 783 -1.98 0.55 0.02 -18.82 65.29 -19.47 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 10 1 1 1 0 1 9 16 81 80 80 0.00000 22.15092 1.35565e-003 38 66 -1.98 0.55 0.02 -18.82 77.61 -19.89 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 1 1 1 1 0 1 10 16 81 80 80 0.00000 22.15092 1.35565e-003 65 112 -1.98 0.55 0.02 -18.79 -33.29 -16.06 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 2 1 1 1 0 1 11 16 81 80 80 0.00000 22.15092 1.35565e-003 339 589 -1.98 0.55 0.02 -18.79 -20.97 -16.49 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 3 1 1 1 0 1 12 16 81 80 80 0.00000 22.15092 1.35565e-003 721 1253 -1.98 0.55 0.02 -18.80 -8.65 -16.91 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 4 1 1 1 0 1 13 16 81 80 80 0.00000 22.15092 1.35565e-003 1581 2748 -1.98 0.55 0.02 -18.80 3.67 -17.34 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 5 1 1 1 0 1 14 16 81 80 80 0.00000 22.15092 1.35565e-003 640 1112 -1.98 0.55 0.02 -18.80 16.00 -17.76 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 6 1 1 1 0 1 15 16 81 80 80 0.00000 22.15092 1.35565e-003 471 819 -1.98 0.55 0.02 -18.81 28.32 -18.19 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 7 1 1 1 0 1 16 16 81 80 80 0.00000 22.15092 1.35565e-003 367 638 -1.98 0.55 0.02 -18.81 40.64 -18.62 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 8 1 1 1 0 1 17 16 81 80 80 0.00000 22.15092 1.35565e-003 214 373 -1.98 0.55 0.02 -18.82 52.96 -19.04 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 9 1 1 1 0 1 18 16 81 80 80 0.00000 22.15092 1.35565e-003 436 758 -1.98 0.55 0.02 -18.82 65.29 -19.47 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 10 1 1 1 0 1 19 16 81 80 80 0.00000 22.15092 1.35565e-003 47 82 -1.98 0.55 0.02 -18.82 77.61 -19.89 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 1 1 1 1 0 1 20 16 81 80 80 0.00000 22.15092 1.35565e-003 66 115 -1.98 0.55 0.02 -18.79 -33.29 -16.06 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 2 1 1 1 0 1 21 16 81 80 80 0.00000 22.15092 1.35565e-003 334 581 -1.98 0.55 0.02 -18.79 -20.97 -16.49 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 3 1 1 1 0 1 22 16 81 80 80 0.00000 22.15092 1.35565e-003 746 1297 -1.98 0.55 0.02 -18.80 -8.65 -16.91 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 4 1 1 1 0 1 23 16 81 80 80 0.00000 22.15092 1.35565e-003 1400 2433 -1.98 0.55 0.02 -18.80 3.67 -17.34 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 5 1 1 1 0 1 24 16 81 80 80 0.00000 22.15092 1.35565e-003 631 1096 -1.98 0.55 0.02 -18.80 16.00 -17.76 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 6 1 1 1 0 1 25 16 81 80 80 0.00000 22.15092 1.35565e-003 438 761 -1.98 0.55 0.02 -18.81 28.32 -18.19 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 7 1 1 1 0 1 26 16 81 80 80 0.00000 22.15092 1.35565e-003 374 650 -1.98 0.55 0.02 -18.81 40.64 -18.62 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 8 1 1 1 0 1 27 16 81 80 80 0.00000 22.15092 1.35565e-003 259 450 -1.98 0.55 0.02 -18.82 52.96 -19.04 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 9 1 1 1 0 1 28 16 81 80 80 0.00000 22.15092 1.35565e-003 436 757 -1.98 0.55 0.02 -18.82 65.29 -19.47 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 10 1 1 1 0 1 29 16 81 80 80 0.00000 22.15092 1.35565e-003 50 86 -1.98 0.55 0.02 -18.82 77.61 -19.89 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 1 1 1 1 0 1 30 16 81 80 80 0.00000 22.15092 1.35565e-003 67 116 -1.98 0.55 0.02 -18.79 -33.29 -16.06 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 2 1 1 1 0 1 31 16 81 80 80 0.00000 22.15092 1.35565e-003 312 542 -1.98 0.55 0.02 -18.79 -20.97 -16.49 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 3 1 1 1 0 1 32 16 81 80 80 0.00000 22.15092 1.35565e-003 694 1206 -1.98 0.55 0.02 -18.80 -8.65 -16.91 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 4 1 1 1 0 1 33 16 81 80 80 0.00000 22.15092 1.35565e-003 1422 2471 -1.98 0.55 0.02 -18.80 3.67 -17.34 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 5 1 1 1 0 1 34 16 81 80 80 0.00000 22.15092 1.35565e-003 626 1088 -1.98 0.55 0.02 -18.80 16.00 -17.76 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 6 1 1 1 0 1 35 16 81 80 80 0.00000 22.15092 1.35565e-003 472 820 -1.98 0.55 0.02 -18.81 28.32 -18.19 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 7 1 1 1 0 1 36 16 81 80 80 0.00000 22.15092 1.35565e-003 345 600 -1.98 0.55 0.02 -18.81 40.64 -18.62 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 8 1 1 1 0 1 37 16 81 80 80 0.00000 22.15092 1.35565e-003 312 542 -1.98 0.55 0.02 -18.82 52.96 -19.04 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 9 1 1 1 0 1 38 16 81 80 80 0.00000 22.15092 1.35565e-003 457 794 -1.98 0.55 0.02 -18.82 65.29 -19.47 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 10 1 1 1 0 1 39 16 81 80 80 0.00000 22.15092 1.35565e-003 48 83 -1.98 0.55 0.02 -18.82 77.61 -19.89 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 1 1 1 1 0 1 40 16 81 80 80 0.00000 22.15092 1.35565e-003 55 95 -1.98 0.55 0.02 -18.79 -33.29 -16.06 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 2 1 1 1 0 1 41 16 81 80 80 0.00000 22.15092 1.35565e-003 355 618 -1.98 0.55 0.02 -18.79 -20.97 -16.49 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 3 1 1 1 0 1 42 16 81 80 80 0.00000 22.15092 1.35565e-003 738 1284 -1.98 0.55 0.02 -18.80 -8.65 -16.91 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 4 1 1 1 0 1 43 16 81 80 80 0.00000 22.15092 1.35565e-003 1440 2504 -1.98 0.55 0.02 -18.80 3.67 -17.34 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 5 1 1 1 0 1 44 16 81 80 80 0.00000 22.15092 1.35565e-003 676 1174 -1.98 0.55 0.02 -18.80 16.00 -17.76 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 6 1 1 1 0 1 45 16 81 80 80 0.00000 22.15092 1.35565e-003 502 872 -1.98 0.55 0.02 -18.81 28.32 -18.19 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 7 1 1 1 0 1 46 16 81 80 80 0.00000 22.15092 1.35565e-003 368 639 -1.98 0.55 0.02 -18.81 40.64 -18.62 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 8 1 1 1 0 1 47 16 81 80 80 0.00000 22.15092 1.35565e-003 330 573 -1.98 0.55 0.02 -18.82 52.96 -19.04 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 9 1 1 1 0 1 48 16 81 80 80 0.00000 22.15092 1.35565e-003 483 839 -1.98 0.55 0.02 -18.82 65.29 -19.47 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 10 1 1 1 0 1 49 16 81 80 80 0.00000 22.15092 1.35565e-003 55 95 -1.98 0.55 0.02 -18.82 77.61 -19.89 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 1 1 1 1 0 1 50 16 81 80 80 0.00000 22.15092 1.35565e-003 56 97 -1.98 0.55 0.02 -18.79 -33.29 -16.06 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 2 1 1 1 0 1 51 16 81 80 80 0.00000 22.15092 1.35565e-003 359 624 -1.98 0.55 0.02 -18.79 -20.97 -16.49 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 3 1 1 1 0 1 52 16 81 80 80 0.00000 22.15092 1.35565e-003 818 1422 -1.98 0.55 0.02 -18.80 -8.65 -16.91 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 4 1 1 1 0 1 53 16 81 80 80 0.00000 22.15092 1.35565e-003 1526 2652 -1.98 0.55 0.02 -18.80 3.67 -17.34 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 5 1 1 1 0 1 54 16 81 80 80 0.00000 22.15092 1.35565e-003 645 1121 -1.98 0.55 0.02 -18.80 16.00 -17.76 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 6 1 1 1 0 1 55 16 81 80 80 0.00000 22.15092 1.35565e-003 474 824 -1.98 0.55 0.02 -18.81 28.32 -18.19 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 7 1 1 1 0 1 56 16 81 80 80 0.00000 22.15092 1.35565e-003 386 671 -1.98 0.55 0.02 -18.81 40.64 -18.62 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 8 1 1 1 0 1 57 16 81 80 80 0.00000 22.15092 1.35565e-003 235 409 -1.98 0.55 0.02 -18.82 52.96 -19.04 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 9 1 1 1 0 1 58 16 81 80 80 0.00000 22.15092 1.35565e-003 406 705 -1.98 0.55 0.02 -18.82 65.29 -19.47 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 10 1 1 1 0 1 59 16 81 80 80 0.00000 22.15092 1.35565e-003 50 87 -1.98 0.55 0.02 -18.82 77.61 -19.89 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 1 1 1 1 0 1 60 16 81 80 80 0.00000 22.15092 1.35565e-003 52 90 -1.98 0.55 0.02 -18.79 -33.29 -16.06 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 0.00 1 90.00 0 0 0 27 0.0 + 2 1 1 1 0 1 61 16 81 80 80 0.00000 22.15092 1.35565e-003 691 1201 -1.98 0.55 0.02 -18.79 -20.97 -16.49 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 0.00 1 90.00 0 0 0 27 0.0 + 3 1 1 1 0 1 62 16 81 80 80 0.00000 22.15092 1.35565e-003 1598 2777 -1.98 0.55 0.02 -18.80 -8.65 -16.91 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 0.00 1 90.00 0 0 0 27 0.0 + 4 1 1 1 0 1 63 16 81 80 80 0.00000 22.15092 1.35565e-003 4569 7943 -1.98 0.55 0.02 -18.80 3.67 -17.34 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 0.00 1 90.00 0 0 0 27 0.0 + 5 1 1 1 0 1 64 16 81 80 80 0.00000 22.15092 1.35565e-003 1526 2653 -1.98 0.55 0.02 -18.80 16.00 -17.76 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 0.00 1 90.00 0 0 0 27 0.0 + 6 1 1 1 0 1 65 16 81 80 80 0.00000 22.15092 1.35565e-003 1070 1860 -1.98 0.55 0.02 -18.81 28.32 -18.19 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 0.00 1 90.00 0 0 0 27 0.0 + 7 1 1 1 0 1 66 16 81 80 80 0.00000 22.15092 1.35565e-003 836 1453 -1.98 0.55 0.02 -18.81 40.64 -18.62 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 0.00 1 90.00 0 0 0 27 0.0 + 8 1 1 1 0 1 67 16 81 80 80 0.00000 22.15092 1.35565e-003 562 978 -1.98 0.55 0.02 -18.82 52.96 -19.04 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 0.00 1 90.00 0 0 0 27 0.0 + 9 1 1 1 0 1 68 16 81 80 80 0.00000 22.15092 1.35565e-003 1073 1865 -1.98 0.55 0.02 -18.82 65.29 -19.47 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 0.00 1 90.00 0 0 0 27 0.0 + 10 1 1 1 0 1 69 16 81 80 80 0.00000 22.15092 1.35565e-003 42 72 -1.98 0.55 0.02 -18.82 77.61 -19.89 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 0.00 1 90.00 0 0 0 27 0.0 + 1 1 1 1 0 1 70 16 81 80 80 0.00000 22.15092 1.35565e-003 53 92 -1.98 0.55 0.02 -18.79 -33.29 -16.06 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 2 1 1 1 0 1 71 16 81 80 80 0.00000 22.15092 1.35565e-003 322 561 -1.98 0.55 0.02 -18.79 -20.97 -16.49 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 3 1 1 1 0 1 72 16 81 80 80 0.00000 22.15092 1.35565e-003 718 1248 -1.98 0.55 0.02 -18.80 -8.65 -16.91 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 4 1 1 1 0 1 73 16 81 80 80 0.00000 22.15092 1.35565e-003 1440 2503 -1.98 0.55 0.02 -18.80 3.67 -17.34 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 5 1 1 1 0 1 74 16 81 80 80 0.00000 22.15092 1.35565e-003 636 1105 -1.98 0.55 0.02 -18.80 16.00 -17.76 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 6 1 1 1 0 1 75 16 81 80 80 0.00000 22.15092 1.35565e-003 467 811 -1.98 0.55 0.02 -18.81 28.32 -18.19 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 7 1 1 1 0 1 76 16 81 80 80 0.00000 22.15092 1.35565e-003 355 616 -1.98 0.55 0.02 -18.81 40.64 -18.62 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 8 1 1 1 0 1 77 16 81 80 80 0.00000 22.15092 1.35565e-003 254 441 -1.98 0.55 0.02 -18.82 52.96 -19.04 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 9 1 1 1 0 1 78 16 81 80 80 0.00000 22.15092 1.35565e-003 442 768 -1.98 0.55 0.02 -18.82 65.29 -19.47 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + 10 1 1 1 0 1 79 16 81 80 80 0.00000 22.15092 1.35565e-003 33 57 -1.98 0.55 0.02 -18.82 77.61 -19.89 10.000 2.330 0 1 0 2 1.912 1.912 91.00 0.00 0.00 1000.00 1 90.00 0 0 0 27 0.0 + +# === END OF DATA DESCRIPTION FILE =============================================== diff --git a/nibabel/tests/test_parrec.py b/nibabel/tests/test_parrec.py index 604cefc583..432ec614ae 100644 --- a/nibabel/tests/test_parrec.py +++ b/nibabel/tests/test_parrec.py @@ -340,10 +340,23 @@ def test_diffusion_parameters(): assert_almost_equal(dti_hdr.get_q_vectors(), bvals[:, None] * bvecs) +def test_diffusion_parameters_v4(): + dti_v4_par = pjoin(DATA_PATH, 'DTIv40.PAR') + with open(dti_v4_par, 'rt') as fobj: + dti_v4_hdr = PARRECHeader.from_fileobj(fobj) + assert_equal(dti_v4_hdr.get_data_shape(), (80, 80, 10, 8)) + assert_equal(dti_v4_hdr.general_info['diffusion'], 1) + bvals, bvecs = dti_v4_hdr.get_bvals_bvecs() + assert_almost_equal(bvals, DTI_PAR_BVALS) + # no b-vector info in V4 .PAR files + assert_equal(bvecs, None) + assert_equal(dti_v4_hdr.get_q_vectors(), None) + + def test_null_diffusion_params(): # Test non-diffusion PARs return None for diffusion params for par, fobj in gen_par_fobj(): - if basename(par) in ('DTI.PAR', 'NA.PAR'): + if basename(par) in ('DTI.PAR', 'DTIv40.PAR', 'NA.PAR'): continue gen_info, slice_info = parse_PAR_header(fobj) with suppress_warnings():