Simulate
Namespace: RTPROCESSINGLIB · Library: DSP Library
This page documents a header-level module — a collection of free functions that share an algorithmic topic. There is no enclosing C++ class; the functions live directly in the library namespace.
mne.simulation.simulate_stc / simulate_evoked in MNE-Python.
#include <dsp/simulate.h>
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2026 MNE-CPP Authors.
Provides functions equivalent to MNE-Python's mne.simulation module:
- simulateStc(): create synthetic source time courses
- simulateEvoked(): generate synthetic evoked data from forward model
const VectorXi vertices = VectorXi::LinSpaced(5, 100, 104);
MatrixXd waveforms(2, 4);
waveforms << 1.0, 2.0, 3.0, 4.0,
-1.0, 0.0, 1.0, 0.0;
const INVLIB::InvSourceEstimate stc = simulateStcFromWaveforms(waveforms, (VectorXi(2) << 101, 104).finished(), vertices, 0.0f, 0.01f);
SimulateStcParams gaussians; // one Gaussian bump per active vertex, seeded
gaussians.sfreq = 200.0f;
gaussians.duration = 0.5f;
const INVLIB::InvSourceEstimate random = simulateStc((VectorXi(1) << 102).finished(), vertices, gaussians);
Functions
simulateStc(activeVertices, allVertices, params)
[InvSourceEstimate](/docs/api/inv/inv-source-estimate) simulateStc(const Eigen::VectorXi & activeVertices, const Eigen::VectorXi & allVertices, const [SimulateStcParams](/docs/api/dsp/simulate-stc-params) & params);
Create a synthetic source time course.
Generates an InvSourceEstimate with Gaussian-envelope waveforms at specified source vertices. Each active source has a Gaussian temporal profile centered at different times.
Parameters:
-
activeVertices : const Eigen::VectorXi & Vertex indices for active sources.
-
allVertices : const Eigen::VectorXi & Full vertex index vector for the source space.
-
params : const SimulateStcParams & Simulation parameters (sfreq, tmin, duration).
Returns:
- InvSourceEstimate — Simulated source estimate.
simulateStcFromWaveforms(waveforms, activeVertices, allVertices, tmin, tstep)
[InvSourceEstimate](/docs/api/inv/inv-source-estimate) simulateStcFromWaveforms(const Eigen::MatrixXd & waveforms, const Eigen::VectorXi & activeVertices, const Eigen::VectorXi & allVertices, float tmin, float tstep);
Create a synthetic source time course from custom waveforms.
Parameters:
-
waveforms : const Eigen::MatrixXd & Waveform data (n_active_sources x n_times).
-
activeVertices : const Eigen::VectorXi & Vertex indices for the active sources.
-
allVertices : const Eigen::VectorXi & Full vertex index vector.
-
tmin : float Start time (s).
-
tstep : float Time step (s).
Returns:
- InvSourceEstimate — Simulated source estimate with zeros at inactive vertices.
simulateEvoked(fwd, stc, info, noiseCov, nave, seed)
[FiffEvoked](/docs/api/fiff/fiff-evoked) simulateEvoked(const [MNEForwardSolution](/docs/api/mne/mne-forward-solution) & fwd, const [InvSourceEstimate](/docs/api/inv/inv-source-estimate) & stc, const [FiffInfo](/docs/api/fiff/fiff-info) & info, const [FiffCov](/docs/api/fiff/fiff-cov) & noiseCov, int nave, int seed);
Simulate evoked data from a source estimate and forward model.
Projects the source estimate with INVLIB::applyForward and optionally adds noise from a noise covariance. As in MNE-Python the noise follows the prepared covariance (SSP applied, MEG and EEG decomposed separately), so MEG and EEG noise are independent.
Equivalent to MNE-Python's mne.simulation.simulate_evoked().
Parameters:
-
fwd : const MNEForwardSolution & Forward solution (gain matrix).
-
stc : const InvSourceEstimate & Source time course.
-
info : const FiffInfo & Measurement info (for output channel info).
-
noiseCov : const FiffCov & Noise covariance for additive noise (optional).
-
nave : int Number of averages (noise scaled by 1/sqrt(nave)).
-
seed : int Random seed for noise generation.
Returns:
- FiffEvoked — Simulated evoked data.
simulateEvokedNoiseless(fwd, stc, info)
[FiffEvoked](/docs/api/fiff/fiff-evoked) simulateEvokedNoiseless(const [MNEForwardSolution](/docs/api/mne/mne-forward-solution) & fwd, const [InvSourceEstimate](/docs/api/inv/inv-source-estimate) & stc, const [FiffInfo](/docs/api/fiff/fiff-info) & info);
Simulate evoked data without noise.
Projects the source estimate through the forward model (no noise added); INVLIB::applyForward.
Parameters:
-
fwd : const MNEForwardSolution & Forward solution.
-
stc : const InvSourceEstimate & Source time course.
-
info : const FiffInfo & Measurement info.
Returns:
- FiffEvoked — Simulated noiseless evoked data.
Example
- Full source:
src/examples/ex_dsp_analysis/main.cpp - Build target:
ex_dsp_analysis(runs under CTest)
Authors of this file
- Christoph Dinh <christoph.dinh@mne-cpp.org>