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

Function _make_surface_mapping

mne/forward/_field_interpolation.py:312–437  ·  view source on GitHub ↗

Re-map M/EEG data to a surface. Parameters ---------- %(info_not_none)s surf : dict The surface to map the data to. The required fields are `'rr'`, `'nn'`, and `'coord_frame'`. Must be in head coordinates. ch_type : str Must be either `'meg'` or `'eeg'`,

(
    info,
    surf,
    ch_type="meg",
    trans=None,
    mode="fast",
    n_jobs=None,
    *,
    origin,
    verbose=None,
)

Source from the content-addressed store, hash-verified

310
311@verbose
312def _make_surface_mapping(
313 info,
314 surf,
315 ch_type="meg",
316 trans=None,
317 mode="fast",
318 n_jobs=None,
319 *,
320 origin,
321 verbose=None,
322):
323 """Re-map M/EEG data to a surface.
324
325 Parameters
326 ----------
327 %(info_not_none)s
328 surf : dict
329 The surface to map the data to. The required fields are `'rr'`,
330 `'nn'`, and `'coord_frame'`. Must be in head coordinates.
331 ch_type : str
332 Must be either `'meg'` or `'eeg'`, determines the type of field.
333 trans : None | dict
334 If None, no transformation applied. Should be a Head<->MRI
335 transformation.
336 mode : str
337 Either `'accurate'` or `'fast'`, determines the quality of the
338 Legendre polynomial expansion used. `'fast'` should be sufficient
339 for most applications.
340 %(n_jobs)s
341 origin : array-like, shape (3,) | str
342 Origin of the sphere in the head coordinate frame and in meters.
343 %(verbose)s
344
345 Returns
346 -------
347 mapping : array
348 A n_vertices x n_sensors array that remaps the MEG or EEG data,
349 as `new_data = np.dot(mapping, data)`.
350 """
351 assert origin is not None # should be assured elsewhere
352
353 if not all(key in surf for key in ["rr", "nn"]):
354 raise KeyError('surf must have both "rr" and "nn"')
355 if "coord_frame" not in surf:
356 raise KeyError(
357 'The surface coordinate frame must be specified in surf["coord_frame"]'
358 )
359 _check_option("mode", mode, ["accurate", "fast"])
360
361 # deal with coordinate frames here -- always go to "head" (easiest)
362 orig_surf = surf
363 surf = transform_surface_to(deepcopy(surf), "head", trans)
364 origin = _check_origin(origin, info)
365
366 #
367 # Step 1. Prepare the coil definitions
368 # Do the dot products, assume surf in head coords
369 #

Callers 1

make_field_mapFunction · 0.85

Calls 13

_check_optionFunction · 0.85
transform_surface_toFunction · 0.85
_check_originFunction · 0.85
pick_typesFunction · 0.85
pick_infoFunction · 0.85
_simplify_infoFunction · 0.85
_create_meg_coilsFunction · 0.85
_create_eeg_elsFunction · 0.85
_setup_dotsFunction · 0.85
_do_self_dotsFunction · 0.85
_do_surface_dotsFunction · 0.85
_compute_mapping_matrixFunction · 0.85

Tested by

no test coverage detected