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.2.tar.gz (10.1 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.2-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for flash_eeg-0.3.2.tar.gz
Algorithm Hash digest
SHA256 c818972c209848edeffd1cc5a875e363d355cd8b9ad538e8ac7f5053fba63a0e
MD5 68c7f93f6eb5693ada303b59be839288
BLAKE2b-256 bb3e7f1d58e8dccd5d16a406fd00a2820a2ba1363ecc511c0cd96ab223990e39

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for flash_eeg-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c39ccf8cef5756ffdaa022b7c57a4b1fc91faa51cd3317173cc7c2cf18a96080
MD5 1ae53af214be9a341c744659ab8b51b1
BLAKE2b-256 5a6215c2303feba6a12c6097735d8db07fb5edc95bb2e348f9e56e0dfc3c4d30

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