def _morph_sparse(stc, subject_from, subject_to, subjects_dir=None):
 maps = read_morph_map(subject_to, subject_from, subjects_dir)
 stc_morph = stc.copy()
 stc_morph.subject = subject_to
 cnt = 0
 for (k, hemi) in enumerate(['lh', 'rh']):
  if (stc.vertices[k].size > 0):
   map_hemi = maps[k]
   vertno_k = _sparse_argmax_nnz_row(map_hemi[stc.vertices[k]])
   order = np.argsort(vertno_k)
   n_active_hemi = len(vertno_k)
   data_hemi = stc_morph._data[cnt:(cnt + n_active_hemi)]
   stc_morph._data[cnt:(cnt + n_active_hemi)] = data_hemi[order]
   stc_morph.vertices[k] = vertno_k[order]
   cnt += n_active_hemi
  else:
   stc_morph.vertices[k] = np.array([], int)
 return stc_morph

def _morph_sparse ( stc , subject_from , subject_to , subjects_dir = None ) : maps = read_morph_map ( subject_to , subject_from , subjects_dir ) stc_morph = stc . copy ( ) stc_morph . subject = subject_to cnt = 0 for ( k , hemi ) in enumerate ( [ 'lh' , 'rh' ] ) : if ( stc . vertices [ k ] . size > 0 ) : map_hemi = maps [ k ] vertno_k = _sparse_argmax_nnz_row ( map_hemi [ stc . vertices [ k ] ] ) order = np . argsort ( vertno_k ) n_active_hemi = len ( vertno_k ) data_hemi = stc_morph . _data [ cnt : ( cnt + n_active_hemi ) ] stc_morph . _data [ cnt : ( cnt + n_active_hemi ) ] = data_hemi [ order ] stc_morph . vertices [ k ] = vertno_k [ order ] cnt += n_active_hemi else : stc_morph . vertices [ k ] = np . array ( [ ] , int ) return stc_morph
morph sparse source estimates to an other subject .