GPU-accelerated electrophysiology (EEG, iEEG, LFP) transforms for large batch jobs
Project description
flash-eeg
GPU-accelerated electrophysiology (EEG, iEEG, LFP) transforms for large batch jobs. Built on PyTorch and CUDA (cuFFT) under the hood.
GPU: NVIDIA GH200 with torch.compile. CPU: MNE-Python / Scipy, fully parallelized (2x Xeon 8568Y+). 8 channels, 30s @ 250Hz.
Install
pip install flash-eeg
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
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
Performance
| Transform | CPU (B=1024) | GPU compiled | Speedup |
|---|---|---|---|
| STFT Spectrogram (vs Scipy) | 7.17s | 6.3ms | 1,146x |
| Morlet Wavelet (vs MNE) | 59.2s | 41.1ms | 1,439x |
| WPLI Connectivity (vs MNE) | 72.1s | 1.1ms | 66,870x |
| Reshape + Interpolate | 6.96s | 0.9ms | 8,089x |
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.1.tar.gz.
File metadata
- Download URL: flash_eeg-0.4.1.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8027030e0f671a54cea9686588447037eefbb7f14c93ce68a4bea9fc88455064
|
|
| MD5 |
f9ee12071ef9b56f8c2253fce577004f
|
|
| BLAKE2b-256 |
fd07f72adbaec156f9d3eb33b56f6934f4bd669db312b71e433b658a700cbf4e
|
File details
Details for the file flash_eeg-0.4.1-py3-none-any.whl.
File metadata
- Download URL: flash_eeg-0.4.1-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b7326430f7f9a4fe527c7a7e1df4d08762e80f8c0cde7e5beb8b74aa86e422d
|
|
| MD5 |
009a6bec8bd197b51341fbc9c4c0fba9
|
|
| BLAKE2b-256 |
b7f74dc31f59db41ad58316b061df951d8036b5ef1fcbb82e937e70961933640
|