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
- info
mne.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
, orSourceSimulator
.- trans
dict
|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.- src
str
| instance ofSourceSpaces
|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.- bem
str
|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_pos
None
|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 (frominfo['dev_head_t']
) will be used. If tuple, should have the same format as data returned byhead_pos_to_trans_rot_t
. If array, should be of the form returned bymne.chpi.read_head_pos()
. See for example 1.- mindist
float
Minimum distance between sources and the inner skull boundary to use during forward calculation.
- interp
str
Either ‘hann’, ‘cos2’ (default), ‘linear’, or ‘zero’, the type of forward-solution interpolation to use between forward solutions at different head positions.
- n_jobs
int
The number of jobs to run in parallel (default
1
). If-1
, it is set to the number of CPU cores. Requires thejoblib
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
, andsrc
. If not None,bem
,trans
, andsrc
are ignored.New in version 0.17.
- first_samp
int
The first_samp property in the output Raw instance.
New in version 0.18.
- max_iter
int
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 andmne.verbose()
for details. Should only be passed as a keyword argument.
- info
- Returns
- rawinstance of
Raw
The simulated raw file.
- rawinstance of
See also
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
. Ifstc
is a tuple of(SourceEstimate, ndarray)
the array values will be placed in the stim channel aligned with themne.SourceEstimate
.Data simulation
In the most advanced case where
stc
is an iterable of tuples the output will be concatenated in time as:# 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
#
Simulate raw data using subject anatomy
Generate simulated source data