mne.simulation.simulate_sparse_stc#

mne.simulation.simulate_sparse_stc(src, n_dipoles, times, data_fun=<function <lambda>>, labels=None, location='random', subject=None, subjects_dir=None, surf='sphere', *, rng=None, random_state=None)[source]#

Generate sparse (n_dipoles) sources time courses from data_fun.

This function randomly selects n_dipoles vertices in the whole cortex or one single vertex (randomly in or in the center of) each label if labels is not None. It uses data_fun to generate waveforms for each vertex.

Parameters:
srcinstance of SourceSpaces

The source space.

n_dipolesint

Number of dipoles to simulate.

timesarray

Time array.

data_funcallable()

Function to generate the waveforms. The default is a 100 nAm, 10 Hz sinusoid as 1e-7 * np.sin(20 * pi * t). The function should take as input the array of time samples in seconds and return an array of the same length containing the time courses.

labelsNone | list of Label

The labels. The default is None, otherwise its size must be n_dipoles.

locationstr

The label location to choose. Can be 'random' (default) or 'center' to use mne.Label.center_of_mass(). Note that for 'center' mode the label values are used as weights.

New in v0.13.

subjectstr | None

The subject the label is defined for. Only used with location='center'.

New in v0.13.

subjects_dirpath-like | None

The path to the directory containing the FreeSurfer subjects reconstructions. If None, defaults to the SUBJECTS_DIR environment variable.

New in v0.13.

surfstr

The surface to use for Euclidean distance center of mass finding. The default here is “sphere”, which finds the center of mass on the spherical surface to help avoid potential issues with cortical folding.

New in v0.13.

rngNone | int | instance of Generator | RandomState

The random number generator (RNG). If None (default), a new numpy.random.Generator seeded from entropy is used. Pass an int or a numpy.random.Generator for reproducible results, or a legacy RandomState to control the random-number stream or for interoperability with third-party code such as scikit-learn that does not accept generators. An integer seed uses numpy.random.default_rng() and therefore produces a different stream than the same integer passed to a legacy random_state or seed parameter.

New in v1.13.

random_stateNone | int | instance of RandomState

Supported for compatibility. New code should use rng. If None, NumPy’s global RandomState is used.

Returns:
stcSourceEstimate

The generated source time courses.

Notes

New in v0.10.0.

Examples using mne.simulation.simulate_sparse_stc#

Cortical Signal Suppression (CSS) for removal of cortical signals

Cortical Signal Suppression (CSS) for removal of cortical signals

Generate simulated evoked data

Generate simulated evoked data

Generate simulated raw data

Generate simulated raw data