Skip to main content

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.

Install

pip install flash-eeg

Usage

import flash_eeg as feeg
import torch

x = torch.randn(32, 8, 7500, device="cuda")  # [batch, channels, samples]

# Functional API
spec = feeg.spectrogram(x)     # STFT spectrogram
morlet = feeg.morlet(x)        # Morlet wavelet
conn = feeg.connectivity(x)    # WPLI connectivity
img = feeg.reshape(x)          # Signal to image
filt = feeg.bandpass(x)        # FFT bandpass filter

# Raw spectral output (no normalization / resize)
raw_spec = feeg.spectrogram(x, output="raw")  # [B, C, n_freqs, T_frames]
raw_morlet = feeg.morlet(x, output="raw")     # [B, C, n_freqs, T_decimated]

# Class API (nn.Module, for training loops)
spec_fn = feeg.Spectrogram(device="cuda")
for batch in dataloader:
    out = spec_fn(batch)

# Both APIs have identical performance after first call.
# Functional API uses lru_cache internally - same params reuse the compiled module.

Options

# Output size
feeg.spectrogram(x, output_size=128)

# FFT parameters
feeg.spectrogram(x, n_fft=512, hop_length=64, freq_min=1.0, freq_max=50.0)
feeg.morlet(x, n_freqs=30, freq_min=1.0, freq_max=100.0)
feeg.connectivity(x, n_fft=1024, num_tapers=5)

# Bandpass filter
feeg.bandpass(x, sfreq=250.0, low=0.5, high=45.0)

# Force compile on/off (auto-detects A100/H100/H200 by default)
feeg.spectrogram(x, compile=True)

Benchmarks

Tested on NVIDIA H200 vs CPU baselines (MNE/Scipy with full parallelization).

Transform CPU GPU (compiled) Speedup
STFT Spectrogram 7.17s 6.3ms 1,147x
Morlet Wavelet 59.2s 41.1ms 1,440x
WPLI Connectivity 72.1s 1.1ms 66,731x
Reshape 6.96s 0.86ms 8,085x

Batch size 1024, 8 channels, 7500 samples (30s @ 250Hz). H200 GPU vs parallelized CPU (MNE/Scipy).

Requirements

  • PyTorch >= 2.0
  • CUDA GPU (for acceleration)

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

flash_eeg-0.3.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flash_eeg-0.3.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file flash_eeg-0.3.0.tar.gz.

File metadata

  • Download URL: flash_eeg-0.3.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.6

File hashes

Hashes for flash_eeg-0.3.0.tar.gz
Algorithm Hash digest
SHA256 df4eda33241e91cdf386b56a0f59af66ddd96437de004a8732cacdead45f0383
MD5 84f1fde472be747abacf4bdabfb9b958
BLAKE2b-256 8110b3c536afc575c64f90acee2e16a29d22581912944e492a31effa93ec7da8

See more details on using hashes here.

File details

Details for the file flash_eeg-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: flash_eeg-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.6

File hashes

Hashes for flash_eeg-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f8685b08078d403772975399fdb75bbfa53ed79947e4c8dc5e628b6f8a9a5413
MD5 0b474b5024470fef246b2aa915781315
BLAKE2b-256 e84b3513718eb751395a194f5a1c04a89f29020798869626e177fcb4f73699db

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page