mne.simulation.simulate_raw¶
-
mne.simulation.
simulate_raw
(info, stc=None, trans=None, src=None, bem=None, cov=None, blink=None, ecg=None, chpi=None, head_pos=None, mindist=1.0, interp='cos2', iir_filter=None, n_jobs=1, random_state=None, use_cps=True, forward=None, first_samp=0, max_iter=10000, raw=None, verbose=None)[source]¶ Simulate raw data.
Head movements can optionally be simulated using the
head_pos
parameter.- Parameters
- infoinstance of
Info
| instance ofRaw
The channel information to use for simulation. Can be an instance of
mne.io.Raw
, but this is deprecated and will be removed in 0.19.Changed in version 0.18: Support for
mne.Info
.- stciterable |
SourceEstimate
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, and iterable of tuple or SourceEstimate.
- 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.- covinstance of
Covariance
|str
|dict
offloat
|None
Deprecated and will be removed in 0.18. Use
mne.simulation.add_noise()
instead. The sensor covariance matrix used to generate noise. If string, should be a filename or ‘simple’. If ‘simple’, an ad hoc covariance matrix will be generated with default values. If dict, an ad hoc covariance matrix will be generated with the values specified by the dict entries. If None, no noise will be added.- blinkbool
Deprecated and will be removed in 0.19, use
add_eog()
instead. If true, add simulated blink artifacts. See Notes for details.- ecgbool
Deprecated and will be removed in 0.19, use
add_ecg()
instead. If true, add simulated ECG artifacts. See Notes for details.- chpibool
Deprecated and will be removed in 0.19, use
add_chpi()
instead. If true, simulate continuous head position indicator information. Valid cHPI information must encoded inraw.info['hpi_meas']
to use this option.- 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 by head_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.
- iir_filter
None
|array
Deprecated and will be removed in 0.19. Use
add_noise()
instead. IIR filter coefficients (denominator) e.g. [1, -1, 0.2].- n_jobs
int
The number of jobs to run in parallel (default 1). Requires the joblib package.
- random_state
int
|None
Deprecated and will be removed in 0.19. Use dedicated noise-generation functions
add_noise()
,add_ecg()
, andadd_eog()
instead.- use_cps
None
| bool (defaultTrue
) Whether to use cortical patch statistics to define normal orientations. Only used when surf_ori and/or force_fixed are 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.
- rawinstance of
Raw
Deprecated and will be removed in 0.18. Pass an instance of :class:
mne.Info
toinfo
instead.- verbosebool,
str
,int
, orNone
If not None, override default verbose level (see
mne.verbose()
and Logging documentation for more).
- infoinstance of
- 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: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
Larson E, Taulu S (2017). “The Importance of Properly Compensating for Head Movements During MEG Acquisition Across Different Age Groups.” Brain Topogr 30:172–181