Skip to content

Commit de078f6

Browse files
committed
fix: for .PAR headers, avoid the assumption of 4D shape in get_bvals_vecs
For example, post-processed ADC maps will be marked as diffusion scans but only have 3D data. The b-values and vectors from the original scan are not available in the header in this case.
1 parent d5494f3 commit de078f6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

nibabel/parrec.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,13 @@ def get_bvals_bvecs(self):
784784
if self.general_info['diffusion'] == 0:
785785
return None, None
786786
reorder = self.get_sorted_slice_indices()
787-
n_slices, n_vols = self.get_data_shape()[-2:]
787+
if len(self.get_data_shape()) == 3:
788+
# Any original diffusion scans will have >=2 volumes. However, a
789+
# single dynamic is possible for a post-processed difusion volume
790+
# such as an ADC map. The b-values are unavailble in this case.
791+
return None, None
792+
else:
793+
n_slices, n_vols = self.get_data_shape()[-2:]
788794
bvals = self.image_defs['diffusion_b_factor'][reorder].reshape(
789795
(n_slices, n_vols), order='F')
790796
# All bvals within volume should be the same

0 commit comments

Comments
 (0)