pynetstim/coordinates.py
def map_to_surface(self, surface='white'):
        
        """
        maps the points to a surface ( either pial or white) or an instance of Surf class. 
        """
        
        if len(self.hemi_not_determined)>0:
            raise ValueError('Use set_hemi_manually to assign hemiphere to these points: %s'%(','.join(self.hemi_not_determined)))
        
        lh_coords_ras_tkr = self.coordinates['ras_tkr_coord'][self.hemi=='lh',:]
        rh_coords_ras_tkr = self.coordinates['ras_tkr_coord'][self.hemi=='rh',:]
        
        if surface in ['white','pial']:
            lh_surf = FreesurferSurf('lh', surface,self.subject, self.freesurfer_dir)
            rh_surf = FreesurferSurf('rh', surface, self.subject, self.freesurfer_dir)
            lh_indices = np.argmin(cdist(lh_surf.vertices, lh_coords_ras_tkr), axis=0)
            rh_indices = np.argmin(cdist(rh_surf.vertices, rh_coords_ras_tkr), axis=0)
            lh_mapped_coords_ras_tkr= lh_surf.vertices[lh_indices,:]
            rh_mapped_coords_ras_tkr= rh_surf.vertices[rh_indices,:]
            
        elif isinstance(surface,Surf):
            lh_indices = np.argmin(cdist(surface.vertices, lh_coords_ras_tkr), axis=0)
            rh_indices = np.argmin(cdist(surface.vertices, rh_coords_ras_tkr), axis=0)
            lh_mapped_coords_ras_tkr = surface.vertices[lh_indices,:]
            rh_mapped_coords_ras_tkr = surface.vertices[rh_indices,:]
        
        
        mapped_vertices = np.empty(self.npoints, dtype='int')
        mapped_vertices[self.hemi=='lh']= lh_indices
        mapped_vertices[self.hemi=='rh'] = rh_indices
        
        mapped_coords_ras_tkr = np.zeros((self.npoints,3))
        mapped_coords_ras_tkr[self.hemi=='lh',:] = lh_mapped_coords_ras_tkr
        mapped_coords_ras_tkr[self.hemi=='rh',:] = rh_mapped_coords_ras_tkr
        

        mapped_coords_ras_tkr_affineM = np.hstack((mapped_coords_ras_tkr,np.ones((mapped_coords_ras_tkr.shape[0],1))))
        mapped_coords_ras = np.dot(np.linalg.inv(self.ras2ras_tkr),mapped_coords_ras_tkr_affineM.T).T
        mapped_coords_ras = mapped_coords_ras[:,0:3]
        results = {'vertices': mapped_vertices, 'ras_coord': mapped_coords_ras, 'ras_tkr_coord':mapped_coords_ras_tkr}
        
        return results

        maps the points to a surface ( either pial or white) or an instance of Surf class. 
        
maps the points to a surface ( either pial or white) or an instance of Surf class.
maps the points to a surface ( either pial or white ) or an instance of Surf class .
def map_to_surface(self, surface='white'):
        if len(self.hemi_not_determined)>0:
            raise ValueError('Use set_hemi_manually to assign hemiphere to these points: %s'%(','.join(self.hemi_not_determined)))
        lh_coords_ras_tkr = self.coordinates['ras_tkr_coord'][self.hemi=='lh',:]
        rh_coords_ras_tkr = self.coordinates['ras_tkr_coord'][self.hemi=='rh',:]
        if surface in ['white','pial']:
            lh_surf = FreesurferSurf('lh', surface,self.subject, self.freesurfer_dir)
            rh_surf = FreesurferSurf('rh', surface, self.subject, self.freesurfer_dir)
            lh_indices = np.argmin(cdist(lh_surf.vertices, lh_coords_ras_tkr), axis=0)
            rh_indices = np.argmin(cdist(rh_surf.vertices, rh_coords_ras_tkr), axis=0)
            lh_mapped_coords_ras_tkr= lh_surf.vertices[lh_indices,:]
            rh_mapped_coords_ras_tkr= rh_surf.vertices[rh_indices,:]
        elif isinstance(surface,Surf):
            lh_indices = np.argmin(cdist(surface.vertices, lh_coords_ras_tkr), axis=0)
            rh_indices = np.argmin(cdist(surface.vertices, rh_coords_ras_tkr), axis=0)
            lh_mapped_coords_ras_tkr = surface.vertices[lh_indices,:]
            rh_mapped_coords_ras_tkr = surface.vertices[rh_indices,:]
        mapped_vertices = np.empty(self.npoints, dtype='int')
        mapped_vertices[self.hemi=='lh']= lh_indices
        mapped_vertices[self.hemi=='rh'] = rh_indices
        mapped_coords_ras_tkr = np.zeros((self.npoints,3))
        mapped_coords_ras_tkr[self.hemi=='lh',:] = lh_mapped_coords_ras_tkr
        mapped_coords_ras_tkr[self.hemi=='rh',:] = rh_mapped_coords_ras_tkr
        mapped_coords_ras_tkr_affineM = np.hstack((mapped_coords_ras_tkr,np.ones((mapped_coords_ras_tkr.shape[0],1))))
        mapped_coords_ras = np.dot(np.linalg.inv(self.ras2ras_tkr),mapped_coords_ras_tkr_affineM.T).T
        mapped_coords_ras = mapped_coords_ras[:,0:3]
        results = {'vertices': mapped_vertices, 'ras_coord': mapped_coords_ras, 'ras_tkr_coord':mapped_coords_ras_tkr}
        return results
def map_to_surface ( self , surface = 'white' ) : if len ( self . hemi_not_determined ) > 0 : raise ValueError ( 'Use set_hemi_manually to assign hemiphere to these points: %s' % ( ',' . join ( self . hemi_not_determined ) ) ) lh_coords_ras_tkr = self . coordinates [ 'ras_tkr_coord' ] [ self . hemi == 'lh' , : ] rh_coords_ras_tkr = self . coordinates [ 'ras_tkr_coord' ] [ self . hemi == 'rh' , : ] if surface in [ 'white' , 'pial' ] : lh_surf = FreesurferSurf ( 'lh' , surface , self . subject , self . freesurfer_dir ) rh_surf = FreesurferSurf ( 'rh' , surface , self . subject , self . freesurfer_dir ) lh_indices = np . argmin ( cdist ( lh_surf . vertices , lh_coords_ras_tkr ) , axis = 0 ) rh_indices = np . argmin ( cdist ( rh_surf . vertices , rh_coords_ras_tkr ) , axis = 0 ) lh_mapped_coords_ras_tkr = lh_surf . vertices [ lh_indices , : ] rh_mapped_coords_ras_tkr = rh_surf . vertices [ rh_indices , : ] elif isinstance ( surface , Surf ) : lh_indices = np . argmin ( cdist ( surface . vertices , lh_coords_ras_tkr ) , axis = 0 ) rh_indices = np . argmin ( cdist ( surface . vertices , rh_coords_ras_tkr ) , axis = 0 ) lh_mapped_coords_ras_tkr = surface . vertices [ lh_indices , : ] rh_mapped_coords_ras_tkr = surface . vertices [ rh_indices , : ] mapped_vertices = np . empty ( self . npoints , dtype = 'int' ) mapped_vertices [ self . hemi == 'lh' ] = lh_indices mapped_vertices [ self . hemi == 'rh' ] = rh_indices mapped_coords_ras_tkr = np . zeros ( ( self . npoints , 3 ) ) mapped_coords_ras_tkr [ self . hemi == 'lh' , : ] = lh_mapped_coords_ras_tkr mapped_coords_ras_tkr [ self . hemi == 'rh' , : ] = rh_mapped_coords_ras_tkr mapped_coords_ras_tkr_affineM = np . hstack ( ( mapped_coords_ras_tkr , np . ones ( ( mapped_coords_ras_tkr . shape [ 0 ] , 1 ) ) ) ) mapped_coords_ras = np . dot ( np . linalg . inv ( self . ras2ras_tkr ) , mapped_coords_ras_tkr_affineM . T ) . T mapped_coords_ras = mapped_coords_ras [ : , 0 : 3 ] results = { 'vertices' : mapped_vertices , 'ras_coord' : mapped_coords_ras , 'ras_tkr_coord' : mapped_coords_ras_tkr } return results
maps the points to a surface ( either pial or white) or an instance of Surf class.
maps the points to a surface ( either pial or white ) or an instance of Surf class .
"""
        maps the points to a surface ( either pial or white) or an instance of Surf class. 
        """
self
surface