@@ -698,16 +698,26 @@ def get_data_shape(self):
698
698
Allows for freesurfer hack for large vectors described in
699
699
https://github.com/nipy/nibabel/issues/100 and
700
700
https://code.google.com/p/fieldtrip/source/browse/trunk/external/freesurfer/save_nifti.m?spec=svn5022&r=5022#77
701
+
702
+ Allows for freesurfer hack for 7th order icosahedron surface described
703
+ in
704
+ https://github.com/nipy/nibabel/issues/309
705
+ https://code.google.com/p/fieldtrip/source/browse/trunk/external/freesurfer/load_nifti.m?r=8776#86
706
+ https://code.google.com/p/fieldtrip/source/browse/trunk/external/freesurfer/save_nifti.m?r=8776#50
701
707
'''
702
708
shape = super (Nifti1Header , self ).get_data_shape ()
703
709
# Apply freesurfer hack for vector
704
- if shape != (- 1 , 1 , 1 ): # Normal case
710
+ if shape == (- 1 , 1 , 1 ):
711
+ vec_len = int (self ._structarr ['glmin' ])
712
+ if vec_len == 0 :
713
+ raise HeaderDataError ('-1 in dim[1] but 0 in glmin; '
714
+ 'inconsistent freesurfer type header?' )
715
+ return (vec_len , 1 , 1 )
716
+ # Apply freesurfer hack for ico7 surface
717
+ elif shape == (27307 , 1 , 6 ):
718
+ return (163842 , 1 , 1 )
719
+ else : # Normal case
705
720
return shape
706
- vec_len = int (self ._structarr ['glmin' ])
707
- if vec_len == 0 :
708
- raise HeaderDataError ('-1 in dim[1] but 0 in glmin; inconsistent '
709
- 'freesurfer type header?' )
710
- return (vec_len , 1 , 1 )
711
721
712
722
def set_data_shape (self , shape ):
713
723
''' Set shape of data
@@ -725,12 +735,22 @@ def set_data_shape(self, shape):
725
735
Applies freesurfer hack for large vectors described in
726
736
https://github.com/nipy/nibabel/issues/100 and
727
737
https://code.google.com/p/fieldtrip/source/browse/trunk/external/freesurfer/save_nifti.m?spec=svn5022&r=5022#77
738
+
739
+ Allows for freesurfer hack for 7th order icosahedron surface described
740
+ in
741
+ https://github.com/nipy/nibabel/issues/309
742
+ https://code.google.com/p/fieldtrip/source/browse/trunk/external/freesurfer/load_nifti.m?r=8776#86
743
+ https://code.google.com/p/fieldtrip/source/browse/trunk/external/freesurfer/save_nifti.m?r=8776#50
728
744
'''
729
- # Apply freesurfer hack for vector
730
745
hdr = self ._structarr
731
746
shape = tuple (shape )
732
- if (len (shape ) == 3 and shape [1 :] == (1 , 1 ) and
733
- shape [0 ] > np .iinfo (hdr ['dim' ].dtype .base ).max ): # Freesurfer case
747
+
748
+ # Apply freesurfer hack for ico7 surface
749
+ if shape == (163842 , 1 , 1 ):
750
+ shape = (27307 , 1 , 6 )
751
+ # Apply freesurfer hack for vector
752
+ elif (len (shape ) == 3 and shape [1 :] == (1 , 1 ) and
753
+ shape [0 ] > np .iinfo (hdr ['dim' ].dtype .base ).max ):
734
754
try :
735
755
hdr ['glmin' ] = shape [0 ]
736
756
except OverflowError :
0 commit comments