MCPcopy
hub / github.com/mne-tools/mne-python / _compute_sparse_morph

Function _compute_sparse_morph

mne/morph.py:325–345  ·  view source on GitHub ↗

Get nearest vertices from one subject to another.

(vertices_from, subject_from, subject_to, subjects_dir=None)

Source from the content-addressed store, hash-verified

323
324
325def _compute_sparse_morph(vertices_from, subject_from, subject_to, subjects_dir=None):
326 """Get nearest vertices from one subject to another."""
327 from scipy import sparse
328
329 maps = read_morph_map(subject_to, subject_from, subjects_dir)
330 cnt = 0
331 vertices = list()
332 cols = list()
333 for verts, map_hemi in zip(vertices_from, maps):
334 vertno_h = _sparse_argmax_nnz_row(map_hemi[verts])
335 order = np.argsort(vertno_h)
336 cols.append(cnt + order)
337 vertices.append(vertno_h[order])
338 cnt += len(vertno_h)
339 cols = np.concatenate(cols)
340 rows = np.arange(len(cols))
341 data = np.ones(len(cols))
342 morph_mat = sparse.coo_array(
343 (data, (rows, cols)), shape=(len(cols), len(cols))
344 ).tocsr()
345 return vertices, morph_mat
346
347
348_SOURCE_MORPH_ATTRIBUTES = [ # used in writing

Callers 1

compute_source_morphFunction · 0.85

Calls 3

read_morph_mapFunction · 0.85
_sparse_argmax_nnz_rowFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected