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.1.tar.gz (8.9 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.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for flash_eeg-0.3.1.tar.gz
Algorithm Hash digest
SHA256 0f316eb356c8ab4c394a92fcb0371ae1ba92c6b46848f8940a87a6245b1881ab
MD5 e29f6a1fe5bcf6311a935dd3f677e4f2
BLAKE2b-256 85b7498d9e776cc67a8e9ad0f5274d8e2e3c3d9a707a62a2beb7945832ee9109

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flash_eeg-0.3.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f2697f1ac3045703c57c6af922e2115d84a9065da7c053099d35d7c32579853
MD5 0ae5123bcb28cee118f780f600fe549a
BLAKE2b-256 097a993e62942d27d50fcad276753047d76efe9a66a05c7c4aa7089938586c91

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