def close_file(self, left_hemi_file, right_hemi_file, left_curvature_output_file, right_curvature_output_file): ''' ''' m = numpy.ctypeslib.as_array(self.__matrix.get_obj()) m = m.reshape(self.__shape) #here lh_vertices, lh_faces = nibabel.freesurfer.read_geometry( left_hemi_file ) rh_vertices, rh_faces = nibabel.freesurfer.read_geometry( right_hemi_file ) sum_vector = numpy.sum( m, axis=0 ) import sys, os sys.path.append(os.path.join( os.path.dirname( __file__ ),'../')) from utility import Utility # write curvature files Utility.write_freesurfer_curvature( left_curvature_output_file, sum_vector[0:len( lh_vertices )] ) Utility.write_freesurfer_curvature( right_curvature_output_file, sum_vector[len( lh_vertices ):] ) # here we start with the offset # end here print 'crv written!!! FTW!' numpy.save( self.__matrix_file, m) print 'stored matrix'
def create_curvature_files( matrix_file, left_hemi_file, right_hemi_file, left_curvature_output_file, right_curvature_output_file, manual=False ): ''' ''' # load the surfaces to compute the offsets correctly # as a reminder: the offset for the right hemisphere is the number of vertices in the left hemisphere # else-wise the vertex indices for right would start at 0 again lh_vertices, lh_faces = nibabel.freesurfer.read_geometry( left_hemi_file ) rh_vertices, rh_faces = nibabel.freesurfer.read_geometry( right_hemi_file ) # load the connectivity matrix #m = numpy.loadtxt( matrix_file, dtype=numpy.uint16 ) m = numpy.load(matrix_file) sum_vector = numpy.sum( m, axis=0 ) # write curvature files Utility.write_freesurfer_curvature( left_curvature_output_file, sum_vector[0:len( lh_vertices )] ) Utility.write_freesurfer_curvature( right_curvature_output_file, sum_vector[len( lh_vertices ):] ) # here we start with the offset