make_meeg_discrete#
- mvpy.dataset.make_meeg_discrete(n_trials: int = 120, n_channels: int = 64, t_padding: float = 1.0, t_baseline: float = 0.25, t_duration: float = 1.0, t_length: float = 2.0, fs: int = 200, n_background: int = 50, n_features: int = 3, n_cycles: int = 2, snr: float = 0.1, gamma: float = 1.0, phi: float = 0.5, poisson: bool = True, variable: bool = True, lambda_min: float = 0.001, lambda_max: float = 0.1, return_Xyß: bool = False, backend: str = 'torch', device: str = 'cpu') tuple[ndarray | Tensor, ndarray | Tensor][source]#
Create an M-EEG dataset based on stimuli defined as discrete events.
- Parameters:
- n_trialsint, default=120
How many trials to simulate?
- n_channelsint, default=64
How many channels to simulate?
- t_paddingfloat, default=1.0
How much padding to use (in seconds)? Padding is cut off before returning, but allows background brain signals to stabilise.
- t_baselinefloat, default=0.25
How much time (in seconds) should pass before stimulus turns on?
- t_durationfloat, default=1.0
How much time (in seconds) should pass before stimulus turns off?
- t_lengthfloat, default=2.0
How much time (in seconds) should we simulate per trial?
- fsint, default=200
Sampling frequency (in Hz).
- n_backgroundint, default=50
How many background sources to simulate?
- n_featuresint, default=3
How many feature sources to simulate?
- n_cyclesint, default=2
How many cycles should each TRF include?
- snrfloat, default=0.1
What should the signal to noise ratio be? Here, SNR is defined as \(\frac{P_{f}}{P_{b}}\) where \(P\) is power and \(f\) and \(b\) refer to features and background, respectively.
- gammafloat, default=1.0
What gamma should we use in the radial basis kernel applied over channels when creating channel covariances?
- phifloat, default=0.5
What phi to use when generating auto-correlated stimulus signals? In the AR1 process, this determines the decay of signals, where \(X[t+1] = \phi X[t] + E[t+1]\) and applies only to background features here.
- poissonbool, default=True
Should we sample impulses from a Poisson distribution? If False, only one impulse is placed at stimulus onset.
- variablebool, default=True
Should each feature be sampled from a different Poisson distribution, allowing for variability in event rates? Only used if Poisson sampling is enabled.
- lambda_minfloat, default=1e-3
Minimum rate for sampling from Poisson distribution.
- lambda_maxfloat, default=0.1
Maximum rate for sampling from Poisson distribution.
- return_Xyßbool, default=False
Should we return X, y and ß?
- backendstr, default=’torch’
Which backend to use (numpy or torch)?
- devicestr, default=’cpu’
What device to use?
- Returns:
- XUnion[np.ndarray, torch.Tensor]
Simulated signals of shape (n_trials, n_features, n_timepoints).
- yUnion[np.ndarray, torch.Tensor]
Simulated neural responses of shape (n_trials, n_channels, n_timepoints).
- ßOptional[Union[np.ndarray, torch.Tensor]]
Simulated temporal response functions of shape (n_channels, n_features, n_trf).
Examples
>>> import torch >>> import matplotlib.pyplot as plt >>> from mvpy.dataset import make_meeg_layout, make_meeg_colours, make_meeg_discrete >>> n_channels = 64 >>> ch_pos = make_meeg_layout(n_channels) >>> ch_col = make_meeg_colours(ch_pos) >>> X, y = make_meeg_discrete(n_channels = n_channels) >>> print(X.shape, y.shape, ch_pos.shape) torch.Size([120, 3, 400]) torch.Size([120, 64, 400]) torch.Size([64, 3]) >>> fig, ax = plt.subplots(1, 2, figsize = (8.0, 4.0)) >>> t = torch.arange(-0.25, 1.75, 1 / 200) >>> for i in range(n_channels): >>> ax[0].plot(t, y[:,i,:].mean(0), c = ch_col[i]) >>> ax[0].set_ylabel(fr'Amplitude (a.u.)') >>> ax[0].set_xlabel(fr'Time ($s$)') >>> ax[0].set_title(fr'M-/EEG signal') >>> ax[1].scatter(ch_pos[:,0], ch_pos[:,1], c = ch_col, marker = 'o', s = 250.0) >>> ax[1].axis('off') >>> ax[1].set_title(fr'Channel positions') >>> fig.tight_layout()