dirconn.simulate#
- dirconn.simulate(network: Network, *, sfreq: float, n_times: int, seed: int, n_trials: int = 1, dynamics: Mapping[str, NodeDynamics] | None = None, snr_db: float = 10.0, n_sensors: int | None = None, n_background: int = 10, background_fraction: float = 0.5, leadfield: ndarray | None = None, sensor_channels: Sequence[ChannelMeta] | None = None, node_scale: str = 'none', extra_signal: ndarray | None = None, noise_series: ndarray | None = None, delay_rounding: str = 'error', burn_in: int = 1000) SimulatedData#
Simulate sensor data generated by a directed network.
The sensor SNR is defined as the mean power of the noise-free sensor signal divided by the mean power of the noise, over all sensors, trials and samples, in dB. The noise is made of background 1/f sources (carrying
background_fractionof the noise power, before the joint rescaling) and white sensor noise, and is rescaled so that the realised SNR equalssnr_dbexactly. Direct channels bypass the leadfield; each gets white noise atsnr_dbrelative to its own power.- Parameters:
network (Network) – Needs at least one cortical node.
sfreq (float) – Sampling frequency in Hz.
n_times (int) – Samples per trial.
seed (int) – Random seed (required). Everything, including the default leadfield, derives from it.
n_trials (int) – Number of independent trials; with more than one the data are
"epoched".dynamics (mapping of str to NodeDynamics, optional) – Own dynamics per node name; default
NodeDynamics()(10 Hz oscillator).snr_db (float) – Target sensor SNR in dB.
n_sensors (int, optional) – Number of sensors for the default leadfield (default 16); must agree with
leadfield.n_background (int) – Number of background 1/f sources; 0 turns the background off (all noise is white).
background_fraction (float) – Share of the noise power carried by the background sources, between 0 and 1.
leadfield (ndarray, shape (n_sensors, n_cortical + n_background), optional) – Replaces the artificial leadfield.
sensor_channels (sequence of ChannelMeta, optional) – Names and types of the sensors, one per row of the leadfield; default
S01,S02, … of type"eeg".node_scale ({"none", "unit"}) –
"none"keeps the node powers the dynamics produce, which in a chain grow with every step."unit"rescales every node to unit variance before mixing. Rescaling a node by a positive constant changes neither the structure of the network nor the truth, but the sensor SNR (defined over all sensors) is dominated by the strongest node and a weak node can be buried in noise;"unit"makes nodes comparable.noise_series (ndarray, shape (n_trials, n_sensors, n_times), optional) – A recorded noise (for example an empty-room measurement) used instead of the simulated noise; it is rescaled so that the realised SNR equals
snr_dbexactly, so only its shape in time and across sensors matters, not its size. It replaces the background sources and the white noise of the sensors, son_backgroundmust be 0. The activity of the nodes does not depend on it: the same seed gives the same signal with any noise. Direct channels keep their own white noise.extra_signal (ndarray, shape (n_trials, n_sensors, n_times), optional) – Activity that reaches the sensors besides the nodes, for example the local activity of the regions that is unrelated to the network. It is added to the signal and counted in the SNR, so
signalis the leadfield times the node activity plus this array.delay_rounding ({"error", "round"}) – See
Edge.delay_samples().burn_in (int) – Samples discarded at the start so that the dynamics are stationary.
- Return type: