mne.simulation.SourceSimulator

class mne.simulation.SourceSimulator(src, tstep=0.001, duration=None)[source]

Class to generate simulated Source Estimates.

Parameters
srcinstance of SourceSpaces

Source space.

tstepfloat

Time step between successive samples in data. Default is 0.001 sec.

durationfloat | None

Time interval during which the simulation takes place in seconds. If None, it is computed using existing events and waveform lengths.

Attributes
durationfloat

Duration of the simulation

n_timesint

Number of time samples in the simulation

Methods

__hash__(self, /)

Return hash(self).

__iter__(self)

Iterate over 1 second STCs.

add_data(self, label, waveform, events)

Add data to the simulation.

get_stc(self[, start_sample, stop_sample])

Simulate a SourceEstimate from the provided data.

get_stim_channel(self[, start_sample, …])

Get the stim channel from the provided data.

__hash__(self, /)

Return hash(self).

__iter__(self)[source]

Iterate over 1 second STCs.

add_data(self, label, waveform, events)[source]

Add data to the simulation.

Data should be added in the form of a triplet of Label (Where) - Waveform(s) (What) - Event(s) (When)

Parameters
labelLabel

The label (as created for example by mne.read_label). If the label does not match any sources in the SourceEstimate, a ValueError is raised.

waveformarray, shape (n_times,) or (n_events, n_times) | list

The waveform(s) describing the activity on the label vertices. If list, it must have the same length as events

events: array of int, shape (n_events, 3)

Events associated to the waveform(s) to specify when the activity should occur.

Examples using add_data:

property duration

Duration of the simulation

get_stc(self, start_sample=0, stop_sample=None)[source]

Simulate a SourceEstimate from the provided data.

Returns a SourceEstimate object constructed according to the simulation parameters which should be added through function add_data. If both start_sample and stop_sample are not specified, the entire duration is used.

Parameters
start_sampleint

First sample in chunk. Default is 0.

stop_sampleint | None

The stop sample of the returned stc. This sample is not part of the output to follow slicing semantics. If None, then all samples past start_sample is returned.

Returns
stcSourceEstimate object

The generated source time courses.

Examples using get_stc:

get_stim_channel(self, start_sample=0, stop_sample=None)[source]

Get the stim channel from the provided data.

Returns the stim channel data according to the simulation parameters which should be added through function add_data. If both start_sample and stop_sample are not specified, the entire duration is used.

Parameters
start_sampleint

First sample in chunk. Default is 0.

stop_sampleint | None

The stop sample of the returned stc. This sample is not part of the output to follow slicing semantics. If None, then all samples past start_sample is returned.

Returns
stim_datandarray of int, shape (n_samples,)

The stimulation channel data.

property n_times

Number of time samples in the simulation