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,
)
| 310 | |
| 311 | @verbose |
| 312 | def _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 | # |
no test coverage detected