Skip to main content

GPU-accelerated EEG preprocessing transforms

Project description

flash-eeg

GPU-accelerated EEG preprocessing. Drop-in replacement for MNE/Scipy transforms.

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

# Class API (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)

# 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.1.0.tar.gz (8.2 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.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for flash_eeg-0.1.0.tar.gz
Algorithm Hash digest
SHA256 37e38e051c40503cecbc15ed2bbbb3a3365b2c974f2a42230408c15001764020
MD5 f2ea152b94f030aa353f5329802bd2af
BLAKE2b-256 dfb0b2bad98739c1b15de9c400282d15709c59b730bf1319033a8e13882d547d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for flash_eeg-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e8b8ae0490277cdb6e29654f38f17e6ca391a2bfc9b6ca0d136c21d8d390906
MD5 8a8fbb78c9d364f097cda7544ac7fb17
BLAKE2b-256 59a5cc48c7b3af063fb6e22ba3f9d82af48fa812e80b1c1cd22aafd14af9e05a

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