def morph_data_precomputed(subject_from, subject_to, stc_from, vertices_to, morph_mat):
 if (not sparse.issparse(morph_mat)):
  raise ValueError('morph_mat must be a sparse matrix')
 if ((not isinstance(vertices_to, list)) or (not (len(vertices_to) == 2))):
  raise ValueError('vertices_to must be a list of length 2')
 if (not (sum((len(v) for v in vertices_to)) == morph_mat.shape[0])):
  raise ValueError('number of vertices in vertices_to must match morph_mat.shape[0]')
 if (not (stc_from.data.shape[0] == morph_mat.shape[1])):
  raise ValueError('stc_from.data.shape[0] must be the same as morph_mat.shape[0]')
 if ((stc_from.subject is not None) and (stc_from.subject != subject_from)):
  raise ValueError('stc_from.subject and subject_from must match')
 data = (morph_mat * stc_from.data)
 stc_to = SourceEstimate(data, vertices_to, stc_from.tmin, stc_from.tstep, verbose=stc_from.verbose, subject=subject_to)
 return stc_to

def morph_data_precomputed ( subject_from , subject_to , stc_from , vertices_to , morph_mat ) : if ( not sparse . issparse ( morph_mat ) ) : raise ValueError ( 'morph_mat must be a sparse matrix' ) if ( ( not isinstance ( vertices_to , list ) ) or ( not ( len ( vertices_to ) == 2 ) ) ) : raise ValueError ( 'vertices_to must be a list of length 2' ) if ( not ( sum ( ( len ( v ) for v in vertices_to ) ) == morph_mat . shape [ 0 ] ) ) : raise ValueError ( 'number of vertices in vertices_to must match morph_mat.shape[0]' ) if ( not ( stc_from . data . shape [ 0 ] == morph_mat . shape [ 1 ] ) ) : raise ValueError ( 'stc_from.data.shape[0] must be the same as morph_mat.shape[0]' ) if ( ( stc_from . subject is not None ) and ( stc_from . subject != subject_from ) ) : raise ValueError ( 'stc_from.subject and subject_from must match' ) data = ( morph_mat * stc_from . data ) stc_to = SourceEstimate ( data , vertices_to , stc_from . tmin , stc_from . tstep , verbose = stc_from . verbose , subject = subject_to ) return stc_to
morph source estimate between subjects using a precomputed matrix .