braindecode 1.2.0.dev184328194__py3-none-any.whl → 1.3.0.dev168496007__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of braindecode might be problematic. Click here for more details.

Files changed (80) hide show
  1. braindecode/augmentation/base.py +1 -1
  2. braindecode/augmentation/functional.py +154 -54
  3. braindecode/augmentation/transforms.py +2 -2
  4. braindecode/datasets/__init__.py +10 -2
  5. braindecode/datasets/base.py +116 -152
  6. braindecode/datasets/bcicomp.py +4 -4
  7. braindecode/datasets/bids.py +3 -3
  8. braindecode/datasets/experimental.py +218 -0
  9. braindecode/datasets/mne.py +3 -5
  10. braindecode/datasets/moabb.py +2 -2
  11. braindecode/datasets/nmt.py +2 -2
  12. braindecode/datasets/sleep_physio_challe_18.py +4 -3
  13. braindecode/datasets/sleep_physionet.py +2 -2
  14. braindecode/datasets/tuh.py +2 -2
  15. braindecode/datasets/xy.py +2 -2
  16. braindecode/datautil/serialization.py +18 -13
  17. braindecode/eegneuralnet.py +2 -0
  18. braindecode/functional/functions.py +6 -2
  19. braindecode/functional/initialization.py +2 -3
  20. braindecode/models/__init__.py +12 -8
  21. braindecode/models/atcnet.py +156 -17
  22. braindecode/models/attentionbasenet.py +148 -16
  23. braindecode/models/{sleep_stager_eldele_2021.py → attn_sleep.py} +14 -2
  24. braindecode/models/base.py +280 -2
  25. braindecode/models/bendr.py +469 -0
  26. braindecode/models/biot.py +3 -1
  27. braindecode/models/contrawr.py +2 -0
  28. braindecode/models/ctnet.py +9 -4
  29. braindecode/models/deep4.py +6 -2
  30. braindecode/models/deepsleepnet.py +127 -5
  31. braindecode/models/eegconformer.py +114 -15
  32. braindecode/models/eeginception_erp.py +82 -7
  33. braindecode/models/eeginception_mi.py +2 -0
  34. braindecode/models/eegitnet.py +2 -0
  35. braindecode/models/eegminer.py +2 -0
  36. braindecode/models/eegnet.py +64 -177
  37. braindecode/models/eegnex.py +113 -6
  38. braindecode/models/eegsimpleconv.py +2 -0
  39. braindecode/models/eegtcnet.py +3 -1
  40. braindecode/models/fbcnet.py +5 -1
  41. braindecode/models/fblightconvnet.py +2 -0
  42. braindecode/models/fbmsnet.py +20 -6
  43. braindecode/models/ifnet.py +2 -0
  44. braindecode/models/labram.py +193 -87
  45. braindecode/models/msvtnet.py +2 -0
  46. braindecode/models/patchedtransformer.py +640 -0
  47. braindecode/models/sccnet.py +81 -8
  48. braindecode/models/shallow_fbcsp.py +2 -0
  49. braindecode/models/signal_jepa.py +111 -27
  50. braindecode/models/sinc_shallow.py +12 -9
  51. braindecode/models/sleep_stager_blanco_2020.py +2 -0
  52. braindecode/models/sleep_stager_chambon_2018.py +2 -0
  53. braindecode/models/sparcnet.py +2 -0
  54. braindecode/models/sstdpn.py +869 -0
  55. braindecode/models/summary.csv +42 -41
  56. braindecode/models/syncnet.py +2 -0
  57. braindecode/models/tcn.py +2 -0
  58. braindecode/models/tidnet.py +2 -0
  59. braindecode/models/tsinception.py +15 -3
  60. braindecode/models/usleep.py +108 -9
  61. braindecode/models/util.py +8 -5
  62. braindecode/modules/attention.py +10 -10
  63. braindecode/modules/blocks.py +3 -3
  64. braindecode/modules/filter.py +2 -9
  65. braindecode/modules/layers.py +18 -17
  66. braindecode/preprocessing/__init__.py +24 -0
  67. braindecode/preprocessing/eegprep_preprocess.py +1202 -0
  68. braindecode/preprocessing/preprocess.py +42 -39
  69. braindecode/preprocessing/util.py +166 -0
  70. braindecode/preprocessing/windowers.py +26 -20
  71. braindecode/samplers/base.py +8 -8
  72. braindecode/version.py +1 -1
  73. {braindecode-1.2.0.dev184328194.dist-info → braindecode-1.3.0.dev168496007.dist-info}/METADATA +12 -3
  74. braindecode-1.3.0.dev168496007.dist-info/RECORD +106 -0
  75. braindecode/models/eegresnet.py +0 -362
  76. braindecode-1.2.0.dev184328194.dist-info/RECORD +0 -101
  77. {braindecode-1.2.0.dev184328194.dist-info → braindecode-1.3.0.dev168496007.dist-info}/WHEEL +0 -0
  78. {braindecode-1.2.0.dev184328194.dist-info → braindecode-1.3.0.dev168496007.dist-info}/licenses/LICENSE.txt +0 -0
  79. {braindecode-1.2.0.dev184328194.dist-info → braindecode-1.3.0.dev168496007.dist-info}/licenses/NOTICE.txt +0 -0
  80. {braindecode-1.2.0.dev184328194.dist-info → braindecode-1.3.0.dev168496007.dist-info}/top_level.txt +0 -0
@@ -1,41 +1,42 @@
1
- Model,Paradigm,Type,Freq(Hz),Hyperparameters,#Parameters,get_#Parameters
2
- ATCNet,General,Classification,250,"n_chans, n_outputs, n_times",113732,"ATCNet(n_chans=22, n_outputs=4, n_times=1000)"
3
- AttentionBaseNet,Motor Imagery,Classification,250,"n_chans, n_outputs, n_times",3692,"AttentionBaseNet(n_chans=22, n_outputs=4, n_times=1000)"
4
- BDTCN,Normal/Abnormal,Classification,100,"n_chans, n_outputs, n_times",456502,"BDTCN(n_chans=21, n_outputs=2, n_times=6000, n_blocks=5, n_filters=55, kernel_size=16)"
5
- BIOT,"Sleep Staging, Epilepsy",Classification,200,"n_chans, n_outputs",3183879,"BIOT(n_chans=2, n_outputs=5, n_times=6000)"
6
- ContraWR,Sleep Staging,"Classification, Embedding",125,"n_chans, n_outputs, sfreq",1160165,"ContraWR(n_chans=2, n_outputs=5, n_times=3750, emb_size=256, sfreq=125)"
7
- CTNet,Motor Imagery,Classification,250,"n_chans, n_outputs, n_times",26900,"CTNet(n_chans=22, n_outputs=4, n_times=1000, n_filters_time=8, kernel_size=16, heads=2, emb_size=16)"
8
- Deep4Net,Motor Imagery,Classification,250,"n_chans, n_outputs, n_times",282879,"Deep4Net(n_chans=22, n_outputs=4, n_times=1000)"
9
- DeepSleepNet,Sleep Staging,Classification,256,"n_chans, n_outputs",24744837,"DeepSleepNet(n_chans=1, n_outputs=5, n_times=7680, sfreq=256)"
10
- EEGConformer,General,Classification,250,"n_chans, n_outputs, n_times",789572,"EEGConformer(n_chans=22, n_outputs=4, n_times=1000)."
11
- EEGInceptionERP,"ERP, SSVEP",Classification,128,"n_chans, n_outputs",14926,"EEGInceptionERP(n_chans=8, n_outputs=2, n_times=128, sfreq=128)"
12
- EEGInceptionMI,Motor Imagery,Classification,250,"n_chans, n_outputs, n_times",558028,"EEGInceptionMI(n_chans=22, n_outputs=4, n_times=1000, n_convs=5, n_filters=12)"
13
- EEGITNet,Motor Imagery,Classification,125,"n_chans, n_outputs, n_times",5212,"EEGITNet(n_chans=22, n_outputs=4, n_times=500)"
14
- EEGNetv1,General,Classification,128,"n_chans, n_outputs, n_times",3052,"EEGNetv1(n_chans=22, n_outputs=4, n_times=512)"
15
- EEGNetv4,General,Classification,128,"n_chans, n_outputs, n_times",2484,"EEGNetv4(n_chans=22, n_outputs=4, n_times=512)"
16
- EEGNeX,Motor Imagery,Classification,125,"n_chans, n_outputs, n_times",55940,"EEGNeX(n_chans=22, n_outputs=4, n_times=500)"
17
- EEGMiner,Emotion Recognition,Classification,128,"n_chans, n_outputs, n_times, sfreq",7572,"EEGMiner(n_chans=62, n_outputs=2, n_times=2560, sfreq=128)"
18
- EEGResNet,General,Classification,250,"n_chans, n_outputs, n_times",247484,"EEGResNet(n_chans=22, n_outputs=4, n_times=1000)"
19
- EEGSimpleConv,Motor Imagery,Classification,80,"n_chans, n_outputs, sfreq",730404,"EEGSimpleConv(n_chans=22, n_outputs=4, n_times=320, sfreq=80)"
20
- EEGTCNet,Motor Imagery,Classification,250,"n_chans, n_outputs",4516,"EEGTCNet(n_chans=22, n_outputs=4, n_times=1000, kern_length=32)"
21
- Labram,General,"Classification, Embedding",200,"n_chans, n_outputs, n_times",5866180,"Labram(n_chans=22, n_outputs=4, n_times=1000, sfreq=250)"
22
- MSVTNet,Motor Imagery,Classification,250,"n_chans, n_outputs, n_times",75494," MSVTNet(n_chans=22, n_outputs=4, n_times=1000)"
23
- SCCNet,Motor Imagery,Classification,125,"n_chans, n_outputs, n_times, sfreq",12070,"SCCNet(n_chans=22, n_outputs=4, n_times=1000, sfreq=125)"
24
- SignalJEPA,"Motor Imagery, ERP, SSVEP",Embedding,128,"n_times, chs_info",3456882,"SignalJEPA(n_times=512, chs_info=Lee2019_MI().get_data(subjects=[1])[1]['0']['1train'].info[""chs""][:62])"
25
- SignalJEPA_Contextual,"Motor Imagery, ERP, SSVEP",Classification,128,"n_outputs, n_times, chs_info",3459184,"SignalJEPA_Contextual(n_outputs=2, input_window_seconds=4.19, sfreq=128, chs_info=Lee2019_MI().get_data(subjects=[1])[1]['0']['1train'].info[""chs""][:62])"
26
- SignalJEPA_PostLocal,"Motor Imagery, ERP, SSVEP",Classification,128,"n_chans, n_outputs, n_times",16142,"SignalJEPA_PostLocal(n_chans=62, n_outputs=2, input_window_seconds=4.19, sfreq=128)"
27
- SignalJEPA_PreLocal,"Motor Imagery, ERP, SSVEP",Classification,128,"n_outputs, n_times, chs_info",16142,"SignalJEPA_PreLocal(n_chans=62, n_outputs=2, input_window_seconds=4.19, sfreq=128)"
28
- SincShallowNet,Motor Imagery,Classification,250,"n_chans, n_outputs, n_times, sfreq",21892,"SincShallowNet(n_chans=22, n_outputs=4, n_times=1000, sfreq=250)"
29
- ShallowFBCSPNet,Motor Imagery,Classification,250,"n_chans, n_outputs, n_times",46084,"ShallowFBCSPNet(n_chans=22, n_outputs=4, n_times=1000, sfreq=250)"
30
- SleepStagerBlanco2020,Sleep Staging,Classification,100,"n_chans, n_outputs, n_times",2845,"SleepStagerBlanco2020(n_chans=2, n_outputs=5, n_times=3000, sfreq=100)"
31
- SleepStagerChambon2018,Sleep Staging,Classification,128,"n_chans, n_outputs, n_times, sfreq",5835,"SleepStagerChambon2018(n_chans=2, n_outputs=5, n_times=3840, sfreq=128)"
32
- SleepStagerEldele2021,Sleep Staging,Classification,100,"n_chans, n_outputs, n_times, sfreq",719925,"SleepStagerEldele2021(n_chans=2, n_outputs=5, n_times=3000, sfreq=100)"
33
- SPARCNet,Epilepsy,Classification,200,"n_chans, n_outputs, n_times",1141921,"SPARCNet(n_chans=16, n_outputs=6, n_times=2000, sfreq=200)"
34
- SyncNet,"Emotion Recognition, Alcoholism",Classification,256,"n_chans, n_outputs, n_times",554,"SyncNet(n_chans=62, n_outputs=3, n_times=5120, sfreq=256)"
35
- TSceptionV1,Emotion Recognition,Classification,256,"n_chans, n_outputs, n_times, sfreq",2187206,"TSceptionV1(n_chans=62, n_outputs=3, n_times=5120, sfreq=256)"
36
- TIDNet,General,Classification,250,"n_chans, n_outputs, n_times",240404,"TIDNet(n_chans=22, n_outputs=4, n_times=1000)"
37
- USleep,Sleep Staging,Classification,128,"n_chans, n_outputs, n_times, sfreq",2482011,"USleep(n_chans=2, n_outputs=5, n_times=3000, sfreq=100)"
38
- FBCNet,Motor Imagery,Classification,250,"n_chans, n_outputs, n_times, sfreq",11812,"FCNet(n_chans=22, n_outputs=4, n_times=1000, sfreq=250)"
39
- FBMSNet,Motor Imagery,Classification,250,"n_chans, n_outputs, n_times, sfreq",16231,"FBMSNet(n_chans=22, n_outputs=4, n_times=1000, sfreq=250)"
40
- FBLightConvNet,Motor Imagery,Classification,250,"n_chans, n_outputs, n_times, sfreq",6596,"FBLightConvNet(n_chans=22, n_outputs=4, n_times=1000, sfreq=250)"
41
- IFNet,Motor Imagery,Classification,250,"n_chans, n_outputs, n_times, sfreq",9860,"IFNet(n_chans=22, n_outputs=4, n_times=1000, sfreq=250)"
1
+ Model,Application,Type,Sampling Frequency (Hz),Hyperparameters,#Parameters,get_#Parameters,Categorization
2
+ ATCNet,General,Classification,250,"n_chans, n_outputs, n_times",113732,"ATCNet(n_chans=22, n_outputs=4, n_times=1000)","Convolution,Recurrent,Small Attention"
3
+ AttentionBaseNet,Motor Imagery,Classification,250,"n_chans, n_outputs, n_times",3692,"AttentionBaseNet(n_chans=22, n_outputs=4, n_times=1000)","Convolution,Small Attention"
4
+ BDTCN,Normal Abnormal,Classification,100,"n_chans, n_outputs, n_times",456502,"BDTCN(n_chans=21, n_outputs=2, n_times=6000, n_blocks=5, n_filters=55, kernel_size=16)","Convolution,Recurrent"
5
+ BIOT,"Sleep Staging, Epilepsy",Classification,200,"n_chans, n_outputs",3183879,"BIOT(n_chans=2, n_outputs=5, n_times=6000)","Large Brain Model"
6
+ ContraWR,Sleep Staging,"Classification, Embedding",125,"n_chans, n_outputs, sfreq",1160165,"ContraWR(n_chans=2, n_outputs=5, n_times=3750, emb_size=256, sfreq=125)",Convolution
7
+ CTNet,Motor Imagery,Classification,250,"n_chans, n_outputs, n_times",26900,"CTNet(n_chans=22, n_outputs=4, n_times=1000, n_filters_time=8, kernel_size=16, heads=2, emb_size=16)","Convolution,Small Attention"
8
+ Deep4Net,General,Classification,250,"n_chans, n_outputs, n_times",282879,"Deep4Net(n_chans=22, n_outputs=4, n_times=1000)","Convolution"
9
+ DeepSleepNet,Sleep Staging,Classification,256,"n_chans, n_outputs",24744837,"DeepSleepNet(n_chans=1, n_outputs=5, n_times=7680, sfreq=256)","Convolution,Recurrent"
10
+ EEGConformer,General,Classification,250,"n_chans, n_outputs, n_times",789572,"EEGConformer(n_chans=22, n_outputs=4, n_times=1000)","Convolution,Small Attention"
11
+ EEGInceptionERP,"ERP, SSVEP",Classification,128,"n_chans, n_outputs",14926,"EEGInceptionERP(n_chans=8, n_outputs=2, n_times=128, sfreq=128)","Convolution"
12
+ EEGInceptionMI,Motor Imagery,Classification,250,"n_chans, n_outputs, n_times",558028,"EEGInceptionMI(n_chans=22, n_outputs=4, n_times=1000, n_convs=5, n_filters=12)","Convolution"
13
+ EEGITNet,Motor Imagery,Classification,125,"n_chans, n_outputs, n_times",5212,"EEGITNet(n_chans=22, n_outputs=4, n_times=500)","Convolution,Recurrent"
14
+ EEGNet,General,Classification,128,"n_chans, n_outputs, n_times",2484,"EEGNet(n_chans=22, n_outputs=4, n_times=512)","Convolution"
15
+ EEGNeX,Motor Imagery,Classification,125,"n_chans, n_outputs, n_times",55940,"EEGNeX(n_chans=22, n_outputs=4, n_times=500)","Convolution"
16
+ EEGMiner,Emotion Recognition,Classification,128,"n_chans, n_outputs, n_times, sfreq",7572,"EEGMiner(n_chans=62, n_outputs=2, n_times=2560, sfreq=128)","Convolution,Interpretability"
17
+ EEGSimpleConv,Motor Imagery,Classification,80,"n_chans, n_outputs, sfreq",730404,"EEGSimpleConv(n_chans=22, n_outputs=4, n_times=320, sfreq=80)","Convolution"
18
+ EEGTCNet,Motor Imagery,Classification,250,"n_chans, n_outputs",4516,"EEGTCNet(n_chans=22, n_outputs=4, n_times=1000, kern_length=32)","Convolution,Recurrent"
19
+ Labram,General,"Classification, Embedding",200,"n_chans, n_outputs, n_times",5866180,"Labram(n_chans=22, n_outputs=4, n_times=1000, sfreq=250)","Convolution,Large Brain Model"
20
+ MSVTNet,Motor Imagery,Classification,250,"n_chans, n_outputs, n_times",75494," MSVTNet(n_chans=22, n_outputs=4, n_times=1000)","Convolution,Recurrent,Small Attention"
21
+ SCCNet,Motor Imagery,Classification,125,"n_chans, n_outputs, n_times, sfreq",12070,"SCCNet(n_chans=22, n_outputs=4, n_times=1000, sfreq=125)","Convolution"
22
+ SignalJEPA,"Motor Imagery, ERP, SSVEP",Embedding,128,"n_times, chs_info",3456882,"SignalJEPA(n_times=512, chs_info=Lee2019_MI().get_data(subjects=[1])[1]['0']['1train'].info[""chs""][:62])","Convolution,Channel,Large Brain Model"
23
+ SignalJEPA_Contextual,"Motor Imagery, ERP, SSVEP",Classification,128,"n_outputs, n_times, chs_info",3459184,"SignalJEPA_Contextual(n_outputs=2, input_window_seconds=4.19, sfreq=128, chs_info=Lee2019_MI().get_data(subjects=[1])[1]['0']['1train'].info[""chs""][:62])","Convolution,Channel,Large Brain Model"
24
+ SignalJEPA_PostLocal,"Motor Imagery, ERP, SSVEP",Classification,128,"n_chans, n_outputs, n_times",16142,"SignalJEPA_PostLocal(n_chans=62, n_outputs=2, input_window_seconds=4.19, sfreq=128)","Convolution,Channel,Large Brain Model"
25
+ SignalJEPA_PreLocal,"Motor Imagery, ERP, SSVEP",Classification,128,"n_outputs, n_times, chs_info",16142,"SignalJEPA_PreLocal(n_chans=62, n_outputs=2, input_window_seconds=4.19, sfreq=128)","Convolution,Channel,Large Brain Model"
26
+ SincShallowNet,Motor Imagery,Classification,250,"n_chans, n_outputs, n_times, sfreq",21892,"SincShallowNet(n_chans=22, n_outputs=4, n_times=1000, sfreq=250)","Convolution,Interpretability"
27
+ ShallowFBCSPNet,General,Classification,250,"n_chans, n_outputs, n_times",46084,"ShallowFBCSPNet(n_chans=22, n_outputs=4, n_times=1000, sfreq=250)","Convolution"
28
+ SleepStagerBlanco2020,Sleep Staging,Classification,100,"n_chans, n_outputs, n_times",2845,"SleepStagerBlanco2020(n_chans=2, n_outputs=5, n_times=3000, sfreq=100)","Convolution"
29
+ SleepStagerChambon2018,Sleep Staging,Classification,128,"n_chans, n_outputs, n_times, sfreq",5835,"SleepStagerChambon2018(n_chans=2, n_outputs=5, n_times=3840, sfreq=128)","Convolution"
30
+ AttnSleep,Sleep Staging,Classification,100,"n_chans, n_outputs, n_times, sfreq",719925,"AttnSleep(n_chans=2, n_outputs=5, n_times=3000, sfreq=100)","Convolution, Small Attention"
31
+ SPARCNet,Epilepsy,Classification,200,"n_chans, n_outputs, n_times",1141921,"SPARCNet(n_chans=16, n_outputs=6, n_times=2000, sfreq=200)","Convolution"
32
+ SyncNet,"Emotion Recognition, Alcoholism",Classification,256,"n_chans, n_outputs, n_times",554,"SyncNet(n_chans=62, n_outputs=3, n_times=5120, sfreq=256)","Interpretability"
33
+ TSception,Emotion Recognition,Classification,256,"n_chans, n_outputs, n_times, sfreq",2187206,"TSception(n_chans=62, n_outputs=3, n_times=5120, sfreq=256)","Convolution"
34
+ TIDNet,General,Classification,250,"n_chans, n_outputs, n_times",240404,"TIDNet(n_chans=22, n_outputs=4, n_times=1000)","Convolution"
35
+ USleep,Sleep Staging,Classification,128,"n_chans, n_outputs, n_times, sfreq",2482011,"USleep(n_chans=2, n_outputs=5, n_times=3000, sfreq=100)","Convolution"
36
+ FBCNet,Motor Imagery,Classification,250,"n_chans, n_outputs, n_times, sfreq",11812,"FCNet(n_chans=22, n_outputs=4, n_times=1000, sfreq=250)","Convolution,FilterBank"
37
+ FBMSNet,Motor Imagery,Classification,250,"n_chans, n_outputs, n_times, sfreq",16231,"FBMSNet(n_chans=22, n_outputs=4, n_times=1000, sfreq=250)","Convolution,FilterBank"
38
+ FBLightConvNet,Motor Imagery,Classification,250,"n_chans, n_outputs, n_times, sfreq",6596,"FBLightConvNet(n_chans=22, n_outputs=4, n_times=1000, sfreq=250)","Convolution,FilterBank"
39
+ IFNet,Motor Imagery,Classification,250,"n_chans, n_outputs, n_times, sfreq",9860,"IFNet(n_chans=22, n_outputs=4, n_times=1000, sfreq=250)","Convolution,FilterBank"
40
+ PBT,General,Classification,250,"n_chans, n_outputs, n_times",818948,"PBT(n_chans=22, n_outputs=4, n_times=1000, sfreq=250)","Large Brain Model"
41
+ SSTDPN,Motor Imagery,Classification,250,"n_chans, n_outputs, n_times",19502,"SSTDPN(n_chans=22, n_outputs=4, n_times=1000)","Convolution,Small Attention"
42
+ BENDR,General,"Classification,Embedding",250,"n_chans, n_times, n_outputs",157141049,"BENDR(n_chans=22, n_outputs=4, n_times=1000)","Large Brain Model,Convolution"
@@ -10,6 +10,8 @@ from braindecode.models.base import EEGModuleMixin
10
10
  class SyncNet(EEGModuleMixin, nn.Module):
11
11
  """Synchronization Network (SyncNet) from Li, Y et al (2017) [Li2017]_.
12
12
 
13
+ :bdg-warning:`Interpretability`
14
+
13
15
  .. figure:: https://braindecode.org/dev/_static/model/SyncNet.png
14
16
  :align: center
15
17
  :alt: SyncNet Architecture
braindecode/models/tcn.py CHANGED
@@ -14,6 +14,8 @@ from braindecode.modules import Chomp1d, Ensure4d, SqueezeFinalOutput
14
14
  class BDTCN(EEGModuleMixin, nn.Module):
15
15
  """Braindecode TCN from Gemein, L et al (2020) [gemein2020]_.
16
16
 
17
+ :bdg-success:`Convolution` :bdg-secondary:`Recurrent`
18
+
17
19
  .. figure:: https://ars.els-cdn.com/content/image/1-s2.0-S1053811920305073-gr3_lrg.jpg
18
20
  :align: center
19
21
  :alt: Braindecode TCN Architecture
@@ -13,6 +13,8 @@ from braindecode.modules import Ensure4d
13
13
  class TIDNet(EEGModuleMixin, nn.Module):
14
14
  """Thinker Invariance DenseNet model from Kostas et al. (2020) [TIDNet]_.
15
15
 
16
+ :bdg-success:`Convolution`
17
+
16
18
  .. figure:: https://content.cld.iop.org/journals/1741-2552/17/5/056008/revision3/jneabb7a7f1_hr.jpg
17
19
  :align: center
18
20
  :alt: TIDNet Architecture
@@ -7,19 +7,21 @@ from __future__ import annotations
7
7
  import torch
8
8
  import torch.nn as nn
9
9
  from einops.layers.torch import Rearrange
10
- from mne.utils import warn
10
+ from mne.utils import deprecated, warn
11
11
 
12
12
  from braindecode.models.base import EEGModuleMixin
13
13
 
14
14
 
15
- class TSceptionV1(EEGModuleMixin, nn.Module):
15
+ class TSception(EEGModuleMixin, nn.Module):
16
16
  """TSception model from Ding et al. (2020) from [ding2020]_.
17
17
 
18
+ :bdg-success:`Convolution`
19
+
18
20
  TSception: A deep learning framework for emotion detection using EEG.
19
21
 
20
22
  .. figure:: https://user-images.githubusercontent.com/58539144/74716976-80415e00-526a-11ea-9433-02ab2b753f6b.PNG
21
23
  :align: center
22
- :alt: TSceptionV1 Architecture
24
+ :alt: TSception Architecture
23
25
 
24
26
  The model consists of temporal and spatial convolutional layers
25
27
  (Tception and Sception) designed to learn temporal and spatial features
@@ -281,3 +283,13 @@ class TSceptionV1(EEGModuleMixin, nn.Module):
281
283
  activation(),
282
284
  nn.AvgPool2d(kernel_size=(1, pool_size), stride=(1, pool_size)),
283
285
  )
286
+
287
+
288
+ @deprecated(
289
+ "`TSceptionV1` was renamed to `TSception` in v1.12; "
290
+ "this alias will be removed in v1.14."
291
+ )
292
+ class TSceptionV1(TSception):
293
+ """Deprecated alias for TSception."""
294
+
295
+ pass
@@ -15,22 +15,121 @@ class USleep(EEGModuleMixin, nn.Module):
15
15
  """
16
16
  Sleep staging architecture from Perslev et al. (2021) [1]_.
17
17
 
18
+ :bdg-success:`Convolution`
19
+
18
20
  .. figure:: https://media.springernature.com/full/springer-static/image/art%3A10.1038%2Fs41746-021-00440-5/MediaObjects/41746_2021_440_Fig2_HTML.png
19
21
  :align: center
20
22
  :alt: USleep Architecture
21
23
 
22
- U-Net (autoencoder with skip connections) feature-extractor for sleep
23
- staging described in [1]_.
24
+ Figure: U-Sleep consists of an encoder (left) which encodes the input signals into dense feature representations, a decoder (middle) which projects
25
+ the learned features into the input space to generate a dense sleep stage representation, and finally a specially designed segment
26
+ classifier (right) which generates sleep stages at a chosen temporal resolution.
27
+
28
+ .. rubric:: Architectural Overview
29
+
30
+ U-Sleep is a **fully convolutional**, feed-forward encoder-decoder with a *segment classifier* head for
31
+ time-series **segmentation** (sleep staging). It maps multi-channel PSG (EEG+EOG) to a *dense, high-frequency*
32
+ per-sample representation, then aggregates it into fixed-length stage labels (e.g., 30 s). The network
33
+ processes arbitrarily long inputs in **one forward pass** (resampling to 128 Hz), allowing whole-night
34
+ hypnograms in seconds.
35
+
36
+ - (i). :class:`_EncoderBlock` extracts progressively deeper temporal features at lower resolution;
37
+ - (ii). :class:`_Decoder` upsamples and fuses encoder features via U-Net-style skips to recover a per-sample stage map;
38
+ - (iii). Segment Classifier mean-pools over the target epoch length and applies two pointwise convs to yield
39
+ per-epoch probabilities. Integrates into the USleep class.
40
+
41
+ .. rubric:: Macro Components
42
+
43
+ - Encoder :class:`_EncoderBlock` **(multi-scale temporal feature extractor; downsampling x2 per block)**
44
+
45
+ - *Operations.*
46
+ - **Conv1d** (:class:`torch.nn.Conv1d`) with kernel ``9`` (stride ``1``, no dilation)
47
+ - **ELU** (:class:`torch.nn.ELU`)
48
+ - **Batch Norm** (:class:`torch.nn.BatchNorm1d`)
49
+ - **Max Pool 1d**, :class:`torch.nn.MaxPool1d` (``kernel=2, stride=2``).
50
+
51
+ Filters grow with depth by a factor of ``sqrt(2)`` (start ``c_1=5``); each block exposes a **skip**
52
+ (pre-pooling activation) to the matching decoder block.
53
+ *Role.* Slow, uniform downsampling preserves early information while expanding the effective temporal
54
+ context over minutes—foundational for robust cross-cohort staging.
55
+
56
+ The number of filters grows with depth (capacity scaling); each block also exposes a **skip** (pre-pool)
57
+ to the matching decoder block.
58
+
59
+ **Rationale.**
60
+ - Slow, uniform downsampling (x2 each level) preserves information in early layers while expanding the temporal receptive field over the minutes.
61
+
62
+ - Decoder :class:`_DecoderBlock` **(progressive upsampling + skip fusion to high-frequency map, 12 blocks; upsampling x2 per block)**
63
+
64
+ - *Operations.*
65
+
66
+ - **Nearest-neighbor upsample**, :class:`nn.Upsample` (x2)
67
+ - **Convolution2d** (k=2), :class:`torch.nn.Conv2d`
68
+ - ELU, :class:`torch.nn.ELU`
69
+ - Batch Norm, :class:`torch.nn.BatchNorm2d`
70
+ - **Concatenate** with the encoder skip at the same temporal scale, ``torch.cat``
71
+ - **Convolution**, :class:`torch.nn.Conv2d`
72
+ - ELU, :class:`torch.nn.ELU`
73
+ - Batch Norm, :class:`torch.nn.BatchNorm2d`.
74
+
75
+ **Output**: A multi-class, **high-frequency** per-sample representation aligned to the input rate (128 Hz).
76
+
77
+ - **Segment Classifier incorporate into :class:`braindecode.models.USleep` (aggregation to fixed epochs)**
78
+
79
+ - *Operations.*
80
+
81
+ - **Mean-pool**, :class:`torch.nn.AvgPool2d` per class with kernel = epoch length *i* and stride *i*
82
+ - **1x1 conv**, :class:`torch.nn.Conv2d`
83
+ - ELU, :class:`torch.nn.ELU`
84
+ - **1x1 conv**, :class:`torch.nn.Conv2d` with ``(T, K)`` (epochs x stages).
85
+
86
+ **Role**: Learns a **non-linear** weighted combination over each 30-s window (unlike U-Time's linear combiner).
87
+
88
+ .. rubric:: Convolutional Details
89
+
90
+ - **Temporal (where time-domain patterns are learned).**
91
+
92
+ All convolutions are **1-D along time**; depth (12 levels) plus pooling yields an extensive receptive field
93
+ (reported sensitivity to ±6.75 min around each epoch; theoretical field ≈ 9.6 min at the deepest layer).
94
+ The decoder restores sample-level resolution before epoch aggregation.
95
+
96
+ - **Spatial (how channels are processed).**
97
+
98
+ Convolutions mix across the *channel* dimension jointly with time (no separate spatial operator). The system
99
+ is **montage-agnostic** (any reasonable EEG/EOG pair) and was trained across diverse cohorts/protocols,
100
+ supporting robustness to channel placement and hardware differences.
101
+
102
+ - **Spectral (how frequency content is captured).**
103
+
104
+ No explicit Fourier/wavelet transform is used; the **stack of temporal convolutions** acts as a learned
105
+ filter bank whose effective bandwidth grows with depth. The high-frequency decoder output (128 Hz)
106
+ retains fine temporal detail for the segment classifier.
107
+
108
+
109
+ .. rubric:: Attention / Sequential Modules
110
+
111
+ U-Sleep contains **no attention or recurrent units**; it is a *pure* feed-forward, fully convolutional
112
+ segmentation network inspired by U-Net/U-Time, favoring training stability and cross-dataset portability.
113
+
114
+
115
+ .. rubric:: Additional Mechanisms
116
+
117
+ - **U-Net lineage with task-specific head.** U-Sleep extends U-Time by being **deeper** (12 vs. 4 levels),
118
+ switching ReLU→**ELU**, using uniform pooling (2) at all depths, and replacing the linear combiner with a
119
+ **two-layer** pointwise head—improving capacity and resilience across datasets.
120
+ - **Arbitrary-length inference.** Thanks to full convolutionality and tiling-free design, entire nights can be
121
+ staged in a single pass on commodity hardware. Inputs shorter than ≈ 17.5 min may reduce performance by
122
+ limiting long-range context.
123
+ - **Complexity scaling (alpha).** Filter counts can be adjusted by a global **complexity factor** to trade accuracy
124
+ and memory (as described in the paper's topology table).
125
+
24
126
 
25
- For the encoder ('down'):
26
- - the temporal dimension shrinks (via maxpooling in the time-domain)
27
- - the spatial dimension expands (via more conv1d filters in the time-domain)
127
+ .. rubric:: Usage and Configuration
28
128
 
29
- For the decoder ('up'):
30
- - the temporal dimension expands (via upsampling in the time-domain)
31
- - the spatial dimension shrinks (via fewer conv1d filters in the time-domain)
129
+ - **Practice.** Resample PSG to **128 Hz** and provide at least two channels (one EEG, one EOG). Choose epoch
130
+ length *i* (often 30 s); ensure windows long enough to exploit the model's receptive field (e.g., training on
131
+ 17.5 min chunks).
32
132
 
33
- Both do so at exponential rates.
34
133
 
35
134
  Parameters
36
135
  ----------
@@ -22,6 +22,8 @@ def _init_models_dict():
22
22
  issubclass(m[1], models.base.EEGModuleMixin)
23
23
  and m[1] != models.base.EEGModuleMixin
24
24
  ):
25
+ if m[1].__name__ == "EEGNetv4":
26
+ continue
25
27
  models_dict[m[0]] = m[1]
26
28
 
27
29
 
@@ -55,9 +57,7 @@ models_mandatory_parameters = [
55
57
  ("EEGInceptionERP", ["n_chans", "n_outputs", "n_times", "sfreq"], None),
56
58
  ("EEGInceptionMI", ["n_chans", "n_outputs", "n_times", "sfreq"], None),
57
59
  ("EEGITNet", ["n_chans", "n_outputs", "n_times"], None),
58
- ("EEGNetv1", ["n_chans", "n_outputs", "n_times"], None),
59
- ("EEGNetv4", ["n_chans", "n_outputs", "n_times"], None),
60
- ("EEGResNet", ["n_chans", "n_outputs", "n_times"], None),
60
+ ("EEGNet", ["n_chans", "n_outputs", "n_times"], None),
61
61
  ("ShallowFBCSPNet", ["n_chans", "n_outputs", "n_times"], None),
62
62
  (
63
63
  "SleepStagerBlanco2020",
@@ -66,7 +66,7 @@ models_mandatory_parameters = [
66
66
  ),
67
67
  ("SleepStagerChambon2018", ["n_chans", "n_outputs", "n_times", "sfreq"], None),
68
68
  (
69
- "SleepStagerEldele2021",
69
+ "AttnSleep",
70
70
  ["n_outputs", "n_times", "sfreq"],
71
71
  dict(sfreq=100.0, n_times=3000, chs_info=[dict(ch_name="C1", kind="eeg")]),
72
72
  ), # 1 channel
@@ -79,7 +79,7 @@ models_mandatory_parameters = [
79
79
  ("SPARCNet", ["n_chans", "n_outputs", "n_times"], None),
80
80
  ("ContraWR", ["n_chans", "n_outputs", "sfreq", "n_times"], dict(sfreq=200.0)),
81
81
  ("EEGNeX", ["n_chans", "n_outputs", "n_times"], None),
82
- ("TSceptionV1", ["n_chans", "n_outputs", "n_times", "sfreq"], dict(sfreq=200.0)),
82
+ ("TSception", ["n_chans", "n_outputs", "n_times", "sfreq"], dict(sfreq=200.0)),
83
83
  ("EEGTCNet", ["n_chans", "n_outputs", "n_times"], None),
84
84
  ("SyncNet", ["n_chans", "n_outputs", "n_times"], None),
85
85
  ("MSVTNet", ["n_chans", "n_outputs", "n_times"], None),
@@ -95,6 +95,9 @@ models_mandatory_parameters = [
95
95
  ("FBMSNet", ["n_chans", "n_outputs", "n_times", "sfreq"], dict(sfreq=200.0)),
96
96
  ("FBLightConvNet", ["n_chans", "n_outputs", "n_times", "sfreq"], dict(sfreq=200.0)),
97
97
  ("IFNet", ["n_chans", "n_outputs", "n_times", "sfreq"], dict(sfreq=200.0)),
98
+ ("PBT", ["n_chans", "n_outputs", "n_times"], None),
99
+ ("SSTDPN", ["n_chans", "n_outputs", "n_times", "sfreq"], None),
100
+ ("BENDR", ["n_chans", "n_outputs", "n_times"], None),
98
101
  ]
99
102
 
100
103
  ################################################################
@@ -38,7 +38,7 @@ class SqueezeAndExcitation(nn.Module):
38
38
  References
39
39
  ----------
40
40
  .. [Hu2018] Hu, J., Albanie, S., Sun, G., Wu, E., 2018.
41
- Squeeze-and-Excitation Networks. CVPR 2018.
41
+ Squeeze-and-Excitation Networks. CVPR 2018.
42
42
  """
43
43
 
44
44
  def __init__(self, in_channels: int, reduction_rate: int, bias: bool = False):
@@ -93,7 +93,7 @@ class GSoP(nn.Module):
93
93
  References
94
94
  ----------
95
95
  .. [Gao2018] Gao, Z., Jiangtao, X., Wang, Q., Li, P., 2018.
96
- Global Second-order Pooling Convolutional Networks. CVPR 2018.
96
+ Global Second-order Pooling Convolutional Networks. CVPR 2018.
97
97
  """
98
98
 
99
99
  def __init__(self, in_channels: int, reduction_rate: int, bias: bool = True):
@@ -149,7 +149,7 @@ class FCA(nn.Module):
149
149
  References
150
150
  ----------
151
151
  .. [Qin2021] Qin, Z., Zhang, P., Wu, F., Li, X., 2021.
152
- FcaNet: Frequency Channel Attention Networks. ICCV 2021.
152
+ FcaNet: Frequency Channel Attention Networks. ICCV 2021.
153
153
  """
154
154
 
155
155
  def __init__(
@@ -233,7 +233,7 @@ class EncNet(nn.Module):
233
233
  References
234
234
  ----------
235
235
  .. [Zhang2018] Zhang, H. et al. 2018.
236
- Context Encoding for Semantic Segmentation. CVPR 2018.
236
+ Context Encoding for Semantic Segmentation. CVPR 2018.
237
237
  """
238
238
 
239
239
  def __init__(self, in_channels: int, n_codewords: int):
@@ -290,7 +290,7 @@ class ECA(nn.Module):
290
290
  References
291
291
  ----------
292
292
  .. [Wang2021] Wang, Q. et al., 2021. ECA-Net: Efficient Channel Attention
293
- for Deep Convolutional Neural Networks. CVPR 2021.
293
+ for Deep Convolutional Neural Networks. CVPR 2021.
294
294
  """
295
295
 
296
296
  def __init__(self, in_channels: int, kernel_size: int):
@@ -341,8 +341,8 @@ class GatherExcite(nn.Module):
341
341
  References
342
342
  ----------
343
343
  .. [Hu2018b] Hu, J., Albanie, S., Sun, G., Vedaldi, A., 2018.
344
- Gather-Excite: Exploiting Feature Context in Convolutional Neural Networks.
345
- NeurIPS 2018.
344
+ Gather-Excite: Exploiting Feature Context in Convolutional Neural Networks.
345
+ NeurIPS 2018.
346
346
  """
347
347
 
348
348
  def __init__(
@@ -410,7 +410,7 @@ class GCT(nn.Module):
410
410
  References
411
411
  ----------
412
412
  .. [Yang2020] Yang, Z. Linchao, Z., Wu, Y., Yang, Y., 2020.
413
- Gated Channel Transformation for Visual Recognition. CVPR 2020.
413
+ Gated Channel Transformation for Visual Recognition. CVPR 2020.
414
414
  """
415
415
 
416
416
  def __init__(self, in_channels: int):
@@ -455,7 +455,7 @@ class SRM(nn.Module):
455
455
  References
456
456
  ----------
457
457
  .. [Lee2019] Lee, H., Kim, H., Nam, H., 2019. SRM: A Style-based
458
- Recalibration Module for Convolutional Neural Networks. ICCV 2019.
458
+ Recalibration Module for Convolutional Neural Networks. ICCV 2019.
459
459
  """
460
460
 
461
461
  def __init__(
@@ -520,7 +520,7 @@ class CBAM(nn.Module):
520
520
  References
521
521
  ----------
522
522
  .. [Woo2018] Woo, S., Park, J., Lee, J., Kweon, I., 2018.
523
- CBAM: Convolutional Block Attention Module. ECCV 2018.
523
+ CBAM: Convolutional Block Attention Module. ECCV 2018.
524
524
  """
525
525
 
526
526
  def __init__(self, in_channels: int, reduction_rate: int, kernel_size: int):
@@ -37,8 +37,8 @@ class MLP(nn.Sequential):
37
37
  :math:`a_i` are called activation functions. The trainable parameters of an
38
38
  MLP are its weights and biases :math:`\\phi = \{W_i, b_i | i = 1, \dots, L\}`.
39
39
 
40
- Parameters:
41
- -----------
40
+ Parameters
41
+ ----------
42
42
  in_features: int
43
43
  Number of input features.
44
44
  hidden_features: Sequential[int] (default=None)
@@ -49,7 +49,7 @@ class MLP(nn.Sequential):
49
49
  out_features: int (default=None)
50
50
  Number of output features, if None, set to in_features.
51
51
  act_layer: nn.GELU (default)
52
- The activation function constructor. If :py:`None`, use
52
+ The activation function constructor. If ``None``, use
53
53
  :class:`torch.nn.GELU` instead.
54
54
  drop: float (default=0.0)
55
55
  Dropout rate.
@@ -17,9 +17,8 @@ class FilterBankLayer(nn.Module):
17
17
  It uses MNE's `create_filter` function to create the band-specific filters and
18
18
  applies them to multi-channel time-series data. Each filter in the bank corresponds to a
19
19
  specific frequency band and is applied to all channels of the input data. The filtering is
20
- performed using FFT-based convolution via the `fftconvolve` function from
21
- :func:`torchaudio.functional if the method is FIR, and `filtfilt` function from
22
- :func:`torchaudio.functional if the method is IIR.
20
+ performed using FFT-based convolution via the ``torchaudio.functional`` if the method is FIR,
21
+ and ``torchaudio.functional`` if the method is IIR.
23
22
 
24
23
  The default configuration creates 9 non-overlapping frequency bands with a 4 Hz bandwidth,
25
24
  spanning from 4 Hz to 40 Hz (i.e., 4-8 Hz, 8-12 Hz, ..., 36-40 Hz). This setup is based on the
@@ -110,11 +109,6 @@ class FilterBankLayer(nn.Module):
110
109
  or "firwin2" to use :func:`scipy.signal.firwin2`. "firwin" uses
111
110
  a time-domain design technique that generally gives improved
112
111
  attenuation using fewer samples than "firwin2".
113
- pad : str, default='reflect_limited'
114
- The type of padding to use. Supports all func:`numpy.pad()` mode options.
115
- Can also be "reflect_limited", which pads with a reflected version of
116
- each vector mirrored on the first and last values of the vector,
117
- followed by zeros. Only used for ``method='fir'``.
118
112
  verbose: bool | str | int | None, default=True
119
113
  Control verbosity of the logging output. If ``None``, use the default
120
114
  verbosity level. See the func:`mne.verbose` for details.
@@ -184,7 +178,6 @@ class FilterBankLayer(nn.Module):
184
178
  "The band_filters items should be splitable in 2 values."
185
179
  )
186
180
 
187
- # and we accepted as
188
181
  self.band_filters = band_filters
189
182
  self.n_bands = len(band_filters)
190
183
  self.phase = phase
@@ -70,26 +70,27 @@ class TimeDistributed(nn.Module):
70
70
  class DropPath(nn.Module):
71
71
  """Drop paths, also known as Stochastic Depth, per sample.
72
72
 
73
- When applied in main path of residual blocks.
73
+ When applied in main path of residual blocks.
74
74
 
75
- Parameters:
76
- -----------
77
- drop_prob: float (default=None)
78
- Drop path probability (should be in range 0-1).
75
+ Parameters
76
+ ----------
77
+ drop_prob: float (default=None)
78
+ Drop path probability (should be in range 0-1).
79
79
 
80
- Notes
81
- -----
82
- Code copied and modified from VISSL facebookresearch:
80
+ Notes
81
+ -----
82
+ Code copied and modified from VISSL facebookresearch:
83
83
  https://github.com/facebookresearch/vissl/blob/0b5d6a94437bc00baed112ca90c9d78c6ccfbafb/vissl/models/model_helpers.py#L676
84
- All rights reserved.
85
-
86
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
87
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
88
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
89
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
90
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
91
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
92
- SOFTWARE.
84
+
85
+ All rights reserved.
86
+
87
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
88
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
89
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
90
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
91
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
92
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
93
+ SOFTWARE.
93
94
  """
94
95
 
95
96
  def __init__(self, drop_prob=None):
@@ -1,3 +1,16 @@
1
+ from .eegprep_preprocess import (
2
+ EEGPrep,
3
+ ReinterpolateRemovedChannels,
4
+ RemoveBadChannels,
5
+ RemoveBadChannelsNoLocs,
6
+ RemoveBadWindows,
7
+ RemoveBursts,
8
+ RemoveCommonAverageReference,
9
+ RemoveDCOffset,
10
+ RemoveDrifts,
11
+ RemoveFlatChannels,
12
+ Resampling,
13
+ )
1
14
  from .mne_preprocess import ( # type: ignore[attr-defined]
2
15
  Crop,
3
16
  DropChannels,
@@ -31,6 +44,17 @@ __all__ = [
31
44
  "Filter",
32
45
  "Pick",
33
46
  "Crop",
47
+ "EEGPrep",
48
+ "RemoveDCOffset",
49
+ "Resampling",
50
+ "RemoveFlatChannels",
51
+ "RemoveDrifts",
52
+ "RemoveBadChannels",
53
+ "RemoveBadChannelsNoLocs",
54
+ "RemoveBursts",
55
+ "RemoveBadWindows",
56
+ "ReinterpolateRemovedChannels",
57
+ "RemoveCommonAverageReference",
34
58
  "create_windows_from_events",
35
59
  "create_fixed_length_windows",
36
60
  "create_windows_from_target_channels",