Editing
Ai Neuroscience
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== <span style="color: #FFFFFF;">Applying</span> == '''EEG motor imagery decoding for BCI:''' <syntaxhighlight lang="python"> import numpy as np import torch import torch.nn as nn from torch.utils.data import DataLoader, TensorDataset class EEGNet(nn.Module): """Compact CNN for EEG classification β widely used in BCI research.""" def __init__(self, n_channels=64, n_classes=4, n_samples=256): super().__init__() # Temporal convolution (learns frequency-specific filters) self.temporal = nn.Conv2d(1, 8, (1, 64), padding=(0, 32), bias=False) self.bn1 = nn.BatchNorm2d(8) # Depthwise spatial convolution (learns spatial filters per temporal filter) self.depthwise = nn.Conv2d(8, 16, (n_channels, 1), groups=8, bias=False) self.bn2 = nn.BatchNorm2d(16) self.avg1 = nn.AvgPool2d((1, 4)) # Separable convolution self.separable = nn.Conv2d(16, 16, (1, 16), padding=(0, 8), bias=False) self.bn3 = nn.BatchNorm2d(16) self.avg2 = nn.AvgPool2d((1, 8)) self.dropout = nn.Dropout(0.5) # Flatten and classify flat_dim = 16 * ((n_samples // 32) // 1) self.classifier = nn.Linear(flat_dim, n_classes) def forward(self, x): # x: (B, 1, C, T) x = self.bn1(self.temporal(x)) x = self.bn2(self.depthwise(x)) x = self.avg1(torch.nn.functional.elu(x)) x = self.dropout(x) x = self.bn3(self.separable(x)) x = self.avg2(torch.nn.functional.elu(x)) x = self.dropout(x) x = x.flatten(1) return self.classifier(x) # Load BCI Competition IV dataset (motor imagery: left hand, right hand, feet, tongue) # X: (n_trials, 1, n_channels, n_samples), y: class labels model = EEGNet(n_channels=64, n_classes=4) optimizer = torch.optim.Adam(model.parameters(), lr=1e-3) criterion = nn.CrossEntropyLoss() </syntaxhighlight> ; Neuroscience AI tools : '''Spike sorting''' β Kilosort4 (GPU spike sorter), MountainSort, SpyKING CIRCUS : '''Calcium imaging''' β Suite2p (fast segmentation + trace extraction), CaImAn, CellPose : '''fMRI analysis''' β Nilearn, FSL, FreeSurfer; deep learning: fastMRI, BrainBERT : '''EEG/BCI''' β MNE-Python, MOABB (benchmarks), EEGLAB; EEGNet, EEG-Conformer : '''Connectomics''' β CAVE (Connectome Annotation Versioning Engine), CloudVolume </div> <div style="background-color: #8B4500; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
Summary:
Please note that all contributions to BloomWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BloomWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information