GPU-accelerated EEG preprocessing transforms
Project description
flash-eeg
GPU-accelerated electrophysiology (EEG, iEEG, LFP) transforms for large batch jobs. Built on PyTorch and CUDA (cuFFT) under the hood.
pip install flash-eeg
Benchmarks
Batch=1024, 8 channels, 30s @ 250Hz. GPU: NVIDIA H200 with torch.compile. CPU: MNE-Python / Scipy (fully parallelized, 2x Xeon 8568Y+).
Usage
import flash_eeg as feeg
import torch
x = torch.randn(1024, 8, 7500, device="cuda") # [batch, channels, samples]
# One-line transforms
spec = feeg.spectrogram(x) # STFT spectrogram -> [B, C, 224, 224]
morlet = feeg.morlet(x) # Morlet wavelet -> [B, C, 224, 224]
conn = feeg.connectivity(x) # WPLI connectivity -> [B, 1, 224, 224]
img = feeg.reshape(x) # Signal-to-image -> [B, C, 224, 224]
filt = feeg.bandpass(x) # FFT bandpass filter -> [B, C, T]
# Raw output (no normalization or resize)
raw = feeg.spectrogram(x, output="raw") # [B, C, n_freqs, T_frames]
# Works with float16 / bfloat16 (AMP training)
x_fp16 = x.half()
spec = feeg.spectrogram(x_fp16) # computes in fp32, returns fp16
Class API (for training loops)
spec_fn = feeg.Spectrogram(device="cuda") # nn.Module
for batch in dataloader:
images = spec_fn(batch) # auto-compiles on A100/H100/H200
Both APIs have identical performance. The functional API uses lru_cache internally — same parameters reuse the compiled module.
Options
feeg.spectrogram(x, output_size=128, n_fft=512, hop_length=64)
feeg.morlet(x, n_freqs=30, freq_min=1.0, freq_max=100.0, n_cycles=5)
feeg.connectivity(x, n_fft=1024, num_tapers=5)
feeg.bandpass(x, sfreq=250.0, low=0.5, high=45.0, rolloff=2.0)
feeg.spectrogram(x, compile=True) # force compile on/off
feeg.clear_cache() # free cached GPU modules
Requirements
- PyTorch >= 2.0
- CUDA GPU
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flash_eeg-0.4.0.tar.gz.
File metadata
- Download URL: flash_eeg-0.4.0.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7317341afa7131eb46c52e3182628d5159666fe01fe030059ac3c59016539dcb
|
|
| MD5 |
a8a9324cc07666941c5e5de2b47bd350
|
|
| BLAKE2b-256 |
21396a3603d57d0b4af2554045d141ed1df848a500ea4a057754021587b616c0
|
File details
Details for the file flash_eeg-0.4.0-py3-none-any.whl.
File metadata
- Download URL: flash_eeg-0.4.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9c23fdfcc662dda6729830994aad04fa27bd3d9f01988087c8333a048196f0d
|
|
| MD5 |
9c5f59cc588577b33e338f330102010b
|
|
| BLAKE2b-256 |
068a0827e88c4b33f3176e6eea202625732ddaadcf21bb4aa79ce01312147e65
|