pyntbci.eeg.generate_c_vep

pyntbci.eeg.generate_c_vep(n_trials: int, n_channels: int, n_samples: int, fs: int, n_classes: int = None, y: NDArray = None, stimulus: NDArray = None, cycle_size: float = None, impulse_response: NDArray = None, primary_channels: int | list[int] = None, snr: float = 1.0, white_noise: float = 1.0, pink_noise: float = 0.0, line_noise: float = 0.0, line_freq: float = 50.0, line_harmonics: int = 1, random_state: int | Generator = None, dtype: str | dtype = 'float32') tuple[NDArray, NDArray, NDArray][source]

Generate a synthetic multi-channel c-VEP EEG dataset. Each trial consists of a c-VEP source signal (the convolution of a binary stimulus and a VEP impulse response), projected to channel space with a mixing matrix that is strongest at primary_channels (e.g., occipital channels), plus background noise. The result can be passed directly to, e.g., eCCA or rCCA in classifiers.

Parameters:
  • n_trials (int) – The number of trials to generate.

  • n_channels (int) – The number of channels to generate.

  • n_samples (int) – The number of samples per trial.

  • fs (int) – The sampling frequency in Hz.

  • n_classes (int (default: None)) – The number of classes. Required if both y and stimulus are None.

  • y (NDArray (default: None)) – The vector of ground-truth labels of shape (n_trials), i.e., the index in stimulus of the class of each trial. If None, trials are assigned to classes as evenly and randomly as possible.

  • stimulus (NDArray (default: None)) – The (single-cycle) binary stimulus of shape (n_classes, n_bits), e.g. as generated with functions from stimulus. Sampled at fs. If None, a random binary stimulus is generated.

  • cycle_size (float (default: None)) – The duration of one stimulus cycle in seconds, used only to generate a random stimulus (i.e., only used if stimulus is None). If None, defaults to n_samples / fs (i.e., a single non-repeating cycle).

  • impulse_response (NDArray (default: None)) – The impulse response of shape (n_response_samples,) to convolve the stimulus with, see generate_c_vep_source. If None, a default impulse response is generated using generate_impulse_response(fs).

  • primary_channels (int | list[int] (default: None)) – The channel indexes at which the c-VEP is strongest (e.g., occipital channels). See generate_mixing_matrix. If None, all channels are equally strong.

  • snr (float (default: 1.0)) – The amplitude of the (unit standard deviation, channel-weighted) c-VEP signal relative to the noise.

  • white_noise (float (default: 1.0)) – The standard deviation of the white sensor noise. See generate_noise.

  • pink_noise (float (default: 0.0)) – The standard deviation of the 1/f pink noise. See generate_noise.

  • line_noise (float (default: 0.0)) – The amplitude of the electrical line noise. See generate_noise.

  • line_freq (float (default: 50.0)) – The line noise frequency in Hz. See generate_noise.

  • line_harmonics (int (default: 1)) – The number of line noise harmonics to include. See generate_noise.

  • random_state (int | np.random.Generator (default: None)) – A seed or numpy random number generator to draw the stimulus, labels, mixing matrix, and noise from. If None, a new one is used.

  • dtype (str | np.dtype (default: "float32")) – The dtype of the returned EEG data X. Computation is always done in float64 internally; this only controls the precision of the final result. The returned stimulus is always float64, as it represents a binary code.

Returns:

  • X (NDArray) – The EEG data of shape (n_trials, n_channels, n_samples).

  • y (NDArray) – The vector of ground-truth labels of shape (n_trials).

  • stimulus (NDArray) – The (single-cycle) binary stimulus of shape (n_classes, n_bits) that was used to generate the c-VEP.