PythonNeurotech 1120 9.8k
Python SciPy Welch Power Spectral Density (PSD) Band Power Extractor
EEG frequency domain analysis script. Applies Welch periodogram PSD estimation to compute spectral power ratios for cognitive state assessment.
SciPy welch periodogram estimation
Relative band power ratios
Interactive Prompt & Options
Fully Editable
Appended directly to the LLM system prompt for tailored code output.
✨ OpenRouter LLM Engine (Llama-3.3-70B) Active
Generated Code
⚡ Instant Boilerplatepython-scipy-eeg-power-spectral-density.py
| 1 | import numpy as np |
| 2 | from scipy.signal import welch |
| 3 | |
| 4 | def compute_band_powers(data: np.ndarray, fs: float = 250.0): |
| 5 | freqs, psd = welch(data, fs=fs, nperseg=fs*2) |
| 6 | alpha = np.trapz(psd[(freqs >= 8) & (freqs <= 12)]) |
| 7 | beta = np.trapz(psd[(freqs >= 13) & (freqs <= 30)]) |
| 8 | return {"alpha": alpha, "beta": beta} |
| 9 |
9 lines • 317 bytespython
Automated Sandbox
Deploy this boilerplate automatically in 1 click.
Related Generators
View AllPython
Python Real-Time EEG & BCI Signal WebSocket Streaming Service
High-throughput asyncio WebSocket receiver for multi-channel BCI EEG raw telemetry streaming, FIR bandpass filtering, and power spectral density (PSD) computing.
PythonMNE & Scikit-Learn Common Spatial Pattern (CSP) EEG Classifier
Machine learning pipeline for Motor Imagery EEG classification using MNE-Python Common Spatial Patterns (CSP) and Linear Discriminant Analysis (LDA).
PythonPyTorch EEGNet Neural Network for BCI Signal Decoding
PyTorch deep learning implementation of EEGNet: a compact convolutional neural network engineered for EEG-based Brain-Computer Interfaces.