braindecode.models.SPARCNet#

class braindecode.models.SPARCNet(n_chans: int | None = None, n_times: int | None = None, n_outputs: int | None = None, block_layers: int = 4, growth_rate: int = 16, bottleneck_size: int = 16, drop_rate: float = 0.5, conv_bias: bool = True, batch_norm: bool = True, activation: ~torch.nn.modules.module.Module = <class 'torch.nn.modules.activation.ELU'>, chs_info: list[dict[~typing.Any, ~typing.Any]] | None = None, input_window_seconds: float | None = None, sfreq: int | None = None)[source]#

Seizures, Periodic and Rhythmic pattern Continuum Neural Network (SPaRCNet) from Jing et al. (2023) [jing2023].

This is a temporal CNN model for biosignal classification based on the DenseNet architecture.

The model is based on the unofficial implementation [Code2023].

Added in version 0.9.

Parameters:
  • n_chans (int) – Number of EEG channels.

  • n_times (int) – Number of time samples of the input window.

  • n_outputs (int) – Number of outputs of the model. This is the number of classes in the case of classification.

  • block_layers (int, optional) – Number of layers per dense block. Default is 4.

  • growth_rate (int, optional) – Growth rate of the DenseNet. Default is 16.

  • bottleneck_size – The description is missing.

  • drop_rate (float, optional) – Dropout rate. Default is 0.5.

  • conv_bias (bool, optional) – Whether to use bias in convolutional layers. Default is True.

  • batch_norm (bool, optional) – Whether to use batch normalization. Default is True.

  • activation (nn.Module, default=nn.ELU) – Activation function class to apply. Should be a PyTorch activation module class like nn.ReLU or nn.ELU. Default is nn.ELU.

  • chs_info (list of dict) – Information about each individual EEG channel. This should be filled with info["chs"]. Refer to mne.Info for more details.

  • input_window_seconds (float) – Length of the input window in seconds.

  • sfreq (float) – Sampling frequency of the EEG recordings.

Raises:
  • ValueError – If some input signal-related parameters are not specified: and can not be inferred.

  • FutureWarning – If add_log_softmax is True, since LogSoftmax final layer: will be removed in the future.

Notes

This implementation is not guaranteed to be correct, has not been checked by original authors.

References

[jing2023]

Jing, J., Ge, W., Hong, S., Fernandes, M. B., Lin, Z., Yang, C., … & Westover, M. B. (2023). Development of expert-level classification of seizures and rhythmic and periodic patterns during eeg interpretation. Neurology, 100(17), e1750-e1762.

[Code2023]

Yang, C., Westover, M.B. and Sun, J., 2023. BIOT Biosignal Transformer for Cross-data Learning in the Wild. GitHub ycq091044/BIOT (accessed 2024-02-13)

Methods

forward(X: Tensor)[source]#

Forward pass of the model.

Parameters:

X (torch.Tensor) – The input tensor of the model with shape (batch_size, n_channels, n_times)

Returns:

The output tensor of the model with shape (batch_size, n_outputs)

Return type:

torch.Tensor