mne.simulation.SourceSimulator

class mne.simulation.SourceSimulator(src, tstep=0.001, duration=None, first_samp=0)[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.

first_sampint

First sample from which the simulation takes place, as an integer. Comparable to the first_samp property of Raw objects. Default is 0.

Attributes
durationfloat

Duration of the simulation in same units as tstep.

n_timesint

Number of time samples in the simulation.

Methods

__hash__(/)

Return hash(self).

__iter__()

Iterate over 1 second STCs.

add_data(label, waveform, events)

Add data to the simulation.

get_stc([start_sample, stop_sample])

Simulate a SourceEstimate from the provided data.

get_stim_channel([start_sample, stop_sample])

Get the stim channel from the provided data.

__iter__()[source]

Iterate over 1 second STCs.

add_data(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
labelinstance of Label

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.

eventsarray 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 in same units as tstep.

get_stc(start_sample=None, 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 | None

First sample in chunk. If None the value of the first_samp attribute is used. Defaults to None.

stop_sampleint | None

The final sample of the returned STC. If None, then all samples past start_sample are returned.

Returns
stcSourceEstimate object

The generated source time courses.

Examples using get_stc:

get_stim_channel(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 the add_data method. If both start_sample and stop_sample are not specified, the entire duration is used.

Parameters
start_sampleint

First sample in chunk. Default is the value of the first_samp attribute.

stop_sampleint | None

The final sample of the returned stc. If None, then all samples from start_sample onward are returned.

Returns
stim_datandarray of int, shape (n_samples,)

The stimulation channel data.

property n_times

Number of time samples in the simulation.

Examples using mne.simulation.SourceSimulator