Skip to main content

GPU-accelerated EEG preprocessing transforms

Project description

flash-eeg

GPU-accelerated EEG-to-image transforms for large-scale AI training.

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)
  • scipy (for DPSS tapers in connectivity)

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.2.0.tar.gz (8.6 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.2.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for flash_eeg-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4bac08683e7a30003eeaedb5e6aa0957df835ac564d4082977fa7509277088c9
MD5 69e837260b1f4f59ba0450203dcd76e0
BLAKE2b-256 bb7f5dde5582d91aa6f6cbcddd4b4e0d62eab28d96b4975500181b0e39e5da7e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for flash_eeg-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 790b8a6206ca7e1541e138c4acd887625fc069a900740a6a88448a6f5eb0b2b5
MD5 ecce56f47272f5d89b3c737d9849ce71
BLAKE2b-256 0d8b23ff40564436c14b17f9e32a978241631aac2594b3e79f2ce358fba0c1bd

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