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

Function labels_to_stc

mne/label.py:2473–2545  ·  view source on GitHub ↗

Convert a set of labels and values to a STC. This function is meant to work like the opposite of `extract_label_time_course`. Parameters ---------- %(labels_eltc)s values : ndarray, shape (n_labels, ...) The values in each label. Can be 1D or 2D. tmin : float

(
    labels, values, tmin=0, tstep=1, subject=None, src=None, verbose=None
)

Source from the content-addressed store, hash-verified

2471
2472@verbose
2473def labels_to_stc(
2474 labels, values, tmin=0, tstep=1, subject=None, src=None, verbose=None
2475):
2476 """Convert a set of labels and values to a STC.
2477
2478 This function is meant to work like the opposite of
2479 `extract_label_time_course`.
2480
2481 Parameters
2482 ----------
2483 %(labels_eltc)s
2484 values : ndarray, shape (n_labels, ...)
2485 The values in each label. Can be 1D or 2D.
2486 tmin : float
2487 The tmin to use for the STC.
2488 tstep : float
2489 The tstep to use for the STC.
2490 %(subject)s
2491 %(src_eltc)s
2492 Can be omitted if using a surface source space, in which case
2493 the label vertices will determine the output STC vertices.
2494 Required if using a volumetric source space.
2495
2496 .. versionadded:: 0.22
2497 %(verbose)s
2498
2499 Returns
2500 -------
2501 stc : instance of SourceEstimate | instance of VolSourceEstimate
2502 The values-in-labels converted to a STC.
2503
2504 See Also
2505 --------
2506 extract_label_time_course
2507
2508 Notes
2509 -----
2510 Vertices that appear in more than one label will be averaged.
2511
2512 .. versionadded:: 0.18
2513 """
2514 values = np.array(values, float)
2515 if values.ndim == 1:
2516 values = values[:, np.newaxis]
2517 if values.ndim != 2:
2518 raise ValueError(f"values must have 1 or 2 dimensions, got {values.ndim}")
2519 _validate_type(src, (SourceSpaces, None))
2520 if src is None:
2521 data, vertices, subject = _labels_to_stc_surf(
2522 labels, values, tmin, tstep, subject
2523 )
2524 klass = SourceEstimate
2525 else:
2526 kind = src.kind
2527 subject = _check_subject(
2528 src._subject, subject, first_kind="source space subject", raise_error=False
2529 )
2530 _check_option("source space kind", kind, ("surface", "volume"))

Callers 3

test_labels_to_stcFunction · 0.90
test_scale_morph_labelsFunction · 0.90

Calls 7

_validate_typeFunction · 0.85
_labels_to_stc_surfFunction · 0.85
_check_subjectFunction · 0.85
_check_optionFunction · 0.85
_check_values_labelsFunction · 0.85
copyMethod · 0.45

Tested by 3

test_labels_to_stcFunction · 0.72
test_scale_morph_labelsFunction · 0.72