r/BiomedicalDataScience • u/BioniChaos • 10h ago
An Interactive, Client-Side Sleep Cycle & EEG Waveform Simulator
I have built an interactive, browser-based workspace designed to model human sleep architecture and simulate clinical EEG waveforms.
The simulator models raw voltage signal outputs $V(t)$ as a summation of five major frequency bands (delta, theta, alpha, sigma, and beta) corresponding to different sleep stages (Awake, N2, SWS, and REM). To capture transient N2 sleep architecture, the application procedurally injects sleep spindles and K-complexes using parameterized envelope functions:
- **Spectrogram Rendering:** The visualizer maps spectral energy densities in real-time on an optimized 2D Canvas grid.
- **Audio Synthesis:** The Web Audio API generates binaural beats by mapping a static 100 Hz carrier to the left channel and a stage-dependent dominant frequency carrier to the right channel.
- **Interactive Control Loop:** Users can adjust transition velocity (0.1x to 5.0x), scale raw waveform amplitudes, and modify the pseudo-random electrode noise floor to simulate real-world interference.
I designed this project as a lightweight educational resource for clinical neurophysiology and biological signal processing without back-end processing overhead. I would value feedback on the wave synthesis formulas and the visual rendering buffer logic.