mne.simulation.simulate_raw

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.

Parameters
infomne.Info

The mne.Info object with information about the sensors and methods of measurement. Used 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.

mindistfloat

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

interpstr

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

n_jobsint

The number of jobs to run in parallel (default 1). If -1, it is set to the number of CPU cores. Requires the joblib package.

use_cpsbool

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.

first_sampint

The first_samp property in the output Raw instance.

New in version 0.18.

max_iterint

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 | None

Control verbosity of the logging output. If None, use the default verbosity level. See the logging documentation and mne.verbose() for details. Should only be passed as a keyword argument.

Returns
rawinstance of Raw

The simulated raw file.

Notes

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

Channel

Data

M/EEG

fwd @ stc[0][0].data

fwd @ stc[1][0].data

...

STIM

stc[0][1]

stc[1][1]

...

time →

New in version 0.10.0.

References

1

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