mne.simulation.simulate_raw(info, stc=None, trans=None, src=None, bem=None, head_pos=None, mindist=1.0, interp='cos2', n_jobs=1, use_cps=True, forward=None, first_samp=0, max_iter=10000, verbose=None)[source]

Simulate raw data.

Head movements can optionally be simulated using the head_pos parameter.

infoinstance of Info

The channel information to use for simulation.

Changed in version 0.18: Support for mne.Info.

stciterable | SourceEstimate | SourceSimulator

The source estimates to use to simulate data. Each must have the same sample rate as the raw data, and the vertices of all stcs in the iterable must match. Each entry in the iterable can also be a tuple of (SourceEstimate, ndarray) to allow specifying the stim channel (e.g., STI001) data accompany the source estimate. See Notes for details.

Changed in version 0.18: Support for tuple, iterable of tuple or SourceEstimate, or SourceSimulator.

transdict | str | None

Either a transformation filename (usually made using mne_analyze) or an info dict (usually opened using read_trans()). If string, an ending of .fif or .fif.gz will be assumed to be in FIF format, any other ending will be assumed to be a text file with a 4x4 transformation matrix (like the --trans MNE-C option). If trans is None, an identity transform will be used.

srcstr | instance of SourceSpaces | None

Source space corresponding to the stc. If string, should be a source space filename. Can also be an instance of loaded or generated SourceSpaces. Can be None if forward is provided.

bemstr | dict | None

BEM solution corresponding to the stc. If string, should be a BEM solution filename (e.g., “sample-5120-5120-5120-bem-sol.fif”). Can be None if forward is provided.

head_posNone | str | dict | tuple | array

Name of the position estimates file. Should be in the format of the files produced by MaxFilter. If dict, keys should be the time points and entries should be 4x4 dev_head_t matrices. If None, the original head position (from info['dev_head_t']) will be used. If tuple, should have the same format as data returned by head_pos_to_trans_rot_t. If array, should be of the form returned by mne.chpi.read_head_pos(). See for example 1.


Minimum distance between sources and the inner skull boundary to use during forward calculation.


Either ‘hann’, ‘cos2’ (default), ‘linear’, or ‘zero’, the type of forward-solution interpolation to use between forward solutions at different head positions.


The number of jobs to run in parallel (default 1). Requires the joblib package.


Whether to use cortical patch statistics to define normal orientations for surfaces (default True).

forwardinstance of Forward | None

The forward operator to use. If None (default) it will be computed using bem, trans, and src. If not None, bem, trans, and src are ignored.

New in version 0.17.


The first_samp property in the output Raw instance.

New in version 0.18.


The maximum number of STC iterations to allow. This is a sanity parameter to prevent accidental blowups.

New in version 0.18.

verbosebool, str, int, or None

If not None, override default verbose level (see mne.verbose() and Logging documentation for more). If used, it should be passed as a keyword-argument only.

rawinstance of Raw

The simulated raw file.


Stim channel encoding

By default, the stimulus channel will have the head position number (starting at 1) stored in the trigger channel (if available) at the t=0 point in each repetition of the stc. If stc is a tuple of (SourceEstimate, ndarray) the array values will be placed in the stim channel aligned with the mne.SourceEstimate.

Data simulation

In the most advanced case where stc is an iterable of tuples the output will be concatenated in time as:

Data alignment and stim channel encoding




fwd @ stc[0][0].data

fwd @ stc[1][0].data






time →

New in version 0.10.0.



Eric Larson and Samu Taulu. The importance of properly compensating for head movements during MEG acquisition across different age groups. Brain Topography, 30(2):172–181, 2017. doi:10.1007/s10548-016-0523-1.

Examples using mne.simulation.simulate_raw