@@ -707,15 +707,15 @@ def get_data_shape(self):
707
707
'''
708
708
shape = super (Nifti1Header , self ).get_data_shape ()
709
709
# Apply freesurfer hack for vector
710
- if shape == (- 1 , 1 , 1 ):
710
+ if shape [: 3 ] == (- 1 , 1 , 1 ):
711
711
vec_len = int (self ._structarr ['glmin' ])
712
712
if vec_len == 0 :
713
713
raise HeaderDataError ('-1 in dim[1] but 0 in glmin; '
714
714
'inconsistent freesurfer type header?' )
715
- return (vec_len , 1 , 1 )
715
+ return (vec_len , 1 , 1 ) + shape [ 3 :]
716
716
# Apply freesurfer hack for ico7 surface
717
- elif shape == (27307 , 1 , 6 ):
718
- return (163842 , 1 , 1 )
717
+ elif shape [: 3 ] == (27307 , 1 , 6 ):
718
+ return (163842 , 1 , 1 ) + shape [ 3 :]
719
719
else : # Normal case
720
720
return shape
721
721
@@ -746,10 +746,10 @@ def set_data_shape(self, shape):
746
746
shape = tuple (shape )
747
747
748
748
# Apply freesurfer hack for ico7 surface
749
- if shape == (163842 , 1 , 1 ):
750
- shape = (27307 , 1 , 6 )
749
+ if shape [: 3 ] == (163842 , 1 , 1 ):
750
+ shape = (27307 , 1 , 6 ) + shape [ 3 :]
751
751
# Apply freesurfer hack for vector
752
- elif (len (shape ) == 3 and shape [1 :] == (1 , 1 ) and
752
+ elif (len (shape ) >= 3 and shape [1 :3 ] == (1 , 1 ) and
753
753
shape [0 ] > np .iinfo (hdr ['dim' ].dtype .base ).max ):
754
754
try :
755
755
hdr ['glmin' ] = shape [0 ]
@@ -762,7 +762,7 @@ def set_data_shape(self, shape):
762
762
shape [0 ])
763
763
warnings .warn ('Using large vector Freesurfer hack; header will '
764
764
'not be compatible with SPM or FSL' , stacklevel = 2 )
765
- shape = (- 1 , 1 , 1 )
765
+ shape = (- 1 , 1 , 1 ) + shape [ 3 :]
766
766
super (Nifti1Header , self ).set_data_shape (shape )
767
767
768
768
def get_qform_quaternion (self ):
0 commit comments