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

Function _hemi_morph

mne/morph.py:1227–1261  ·  view source on GitHub ↗
(tris, vertices_to, vertices_from, smooth, maps, warn)

Source from the content-addressed store, hash-verified

1225
1226
1227def _hemi_morph(tris, vertices_to, vertices_from, smooth, maps, warn):
1228 _validate_type(smooth, (str, None, "int-like"), "smoothing steps")
1229 if len(vertices_from) == 0:
1230 return sparse.csr_array((len(vertices_to), 0))
1231 e = mesh_edges(tris)
1232 e.data[e.data == 2] = 1
1233 n_vertices = e.shape[0]
1234 e += _eye_array(n_vertices, format="csr")
1235 if isinstance(smooth, str):
1236 _check_option("smooth", smooth, ("nearest",), extra=" when used as a string.")
1237 mm = _surf_nearest(vertices_from, e).tocsr()
1238 elif smooth == 0:
1239 mm = sparse.csc_array(
1240 (
1241 np.ones(len(vertices_from)), # data, indices, indptr
1242 vertices_from,
1243 np.arange(len(vertices_from) + 1),
1244 ),
1245 shape=(e.shape[0], len(vertices_from)),
1246 ).tocsr()
1247 else:
1248 mm, n_missing, n_iter = _surf_upsampling_mat(vertices_from, e, smooth)
1249 if n_missing and warn:
1250 warn_(
1251 f"{n_missing}/{e.shape[0]} vertices not included in "
1252 "smoothing, consider increasing the number of steps"
1253 )
1254 logger.info(f" {n_iter} smooth iterations done.")
1255 assert mm.shape == (n_vertices, len(vertices_from))
1256 if maps is not None:
1257 mm = maps[vertices_to] @ mm
1258 else: # to == from
1259 mm = mm[vertices_to]
1260 assert mm.shape == (len(vertices_to), len(vertices_from))
1261 return mm
1262
1263
1264@verbose

Callers 3

_compute_morph_matrixFunction · 0.85
_smooth_plotFunction · 0.85
set_data_smoothingMethod · 0.85

Calls 7

_validate_typeFunction · 0.85
mesh_edgesFunction · 0.85
_eye_arrayFunction · 0.85
_check_optionFunction · 0.85
_surf_nearestFunction · 0.85
_surf_upsampling_matFunction · 0.85
infoMethod · 0.80

Tested by

no test coverage detected