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

Method fill

mne/label.py:456–524  ·  view source on GitHub ↗

Fill the surface between sources for a source space label. Parameters ---------- src : SourceSpaces Source space in which the label was defined. If a source space is provided, the label is expanded to fill in surface vertices that lie betw

(self, src, name=None)

Source from the content-addressed store, hash-verified

454 return cp.deepcopy(self)
455
456 def fill(self, src, name=None):
457 """Fill the surface between sources for a source space label.
458
459 Parameters
460 ----------
461 src : SourceSpaces
462 Source space in which the label was defined. If a source space is
463 provided, the label is expanded to fill in surface vertices that
464 lie between the vertices included in the source space. For the
465 added vertices, ``pos`` is filled in with positions from the
466 source space, and ``values`` is filled in from the closest source
467 space vertex.
468 name : None | str
469 Name for the new Label (default is self.name).
470
471 Returns
472 -------
473 label : Label
474 The label covering the same vertices in source space but also
475 including intermediate surface vertices.
476
477 See Also
478 --------
479 Label.restrict
480 Label.smooth
481 """
482 # find source space patch info
483 if len(self.vertices) == 0:
484 return self.copy()
485 hemi_src = _get_label_src(self, src)
486
487 if not np.all(np.isin(self.vertices, hemi_src["vertno"])):
488 msg = "Source space does not contain all of the label's vertices"
489 raise ValueError(msg)
490
491 if hemi_src["nearest"] is None:
492 warn(
493 "Source space is being modified in place because patch "
494 "information is needed. To avoid this in the future, run "
495 "mne.add_source_space_distances() on the source space "
496 "and save it to disk."
497 )
498 dist_limit = 0
499 add_source_space_distances(src, dist_limit=dist_limit)
500 nearest = hemi_src["nearest"]
501
502 # find new vertices
503 include = np.isin(nearest, self.vertices, False)
504 vertices = np.nonzero(include)[0]
505
506 # values
507 nearest_in_label = np.digitize(nearest[vertices], self.vertices, True)
508 values = self.values[nearest_in_label]
509 # pos
510 pos = hemi_src["rr"][vertices]
511
512 name = self.name if name is None else name
513 label = Label(

Callers 15

stc_to_labelFunction · 0.95
test_label_fill_restrictFunction · 0.95
_compute_aggregateMethod · 0.80
_minimize_time_diffFunction · 0.80
average_movementsFunction · 0.80
stc_near_sensorsFunction · 0.80
_auto_low_rank_modelFunction · 0.80
_prep_maxwell_filterFunction · 0.80
estimate_snrFunction · 0.80
_compute_eloretaFunction · 0.80

Calls 5

copyMethod · 0.95
_get_label_srcFunction · 0.85
warnFunction · 0.85
LabelClass · 0.85

Tested by 12

test_label_fill_restrictFunction · 0.76
test_projFunction · 0.64
test_find_topomap_coordsFunction · 0.64
test_morphFunction · 0.64
test_expandFunction · 0.64
test_simulate_raw_bemFunction · 0.64
test_add_noiseFunction · 0.64
test_simulate_sparse_stcFunction · 0.64
test_plot_topomap_basicFunction · 0.64
test_process_clim_plotFunction · 0.64