How omertwelve/neurosense works
NeuroSense captures eight-channel EEG, processes it on a Python backend, and streams signal views and two stress estimates to a React dashboard. The README documents the hardware-to-browser workflow and the offline model-evaluation capabilities; sampled backend excerpts show the main processing and command orchestration. Some subsystem details are documented but not sampled, so those links are marked as documented or left unverified rather than inferred from module names.
Main entry points: main.py FastAPI Backend · App.jsx Dashboard App · model_inference.py Live ML Inference · build_dataset.py Dataset Builder
Components 25
EEG Capture
- Packet Bridge
backend/openbci_bridge.py
Live Processing
- FastAPI Backend
backend/main.py - EEG Configuration
backend/config.py - Filtering & Artifacts
backend/eeg_processor.py - Band Power & FFT
backend/band_power.py - DSP Stress Index
backend/stress_index.py - Live ML Inference
backend/model_inference.py - Baseline Normalizer
backend/baseline_normalizer.py - EEG Recorder
backend/recorder.py - Dashboard WebSockets
backend/ws_manager.py
Dashboard
- WebSocket Client
frontend/src/hooks/useWebSocket.js - Dashboard App
frontend/src/App.jsx - Signals Views
frontend/src/components/SignalsTab.jsx - Channel Chart
frontend/src/components/ChannelChart.jsx - FFT Plot
frontend/src/components/FFTPlot.jsx - Band Power View
frontend/src/components/BandsTab.jsx - Classifier View
frontend/src/components/ClassifierTab.jsx - Stress Gauge
frontend/src/components/StressGauge.jsx
Model Development
- Trained Model Artifacts
models/stress_classifier.pkl - Dataset Builder
ml/build_dataset.py - Random Forest Training
ml/train_model.py - CNN Comparison
ml/train_cnn.py - EEGMAT Conversion
ml/convert_eegmat.py
Other components
- OpenBCI Cyton
- Dashboard User
Connections 26
- OpenBCI Cyton → Packet Bridge: sends EEG
README.md - Packet Bridge → FastAPI Backend: streams packets
README.md - FastAPI Backend → Filtering & Artifacts: filters samples
backend/main.py - FastAPI Backend → EEG Recorder: records samples
backend/main.py - FastAPI Backend → Band Power & FFT: computes spectra
backend/main.py - FastAPI Backend → DSP Stress Index: scores stress
backend/main.py - FastAPI Backend → Live ML Inference: runs prediction
backend/main.py - Live ML Inference → Band Power & FFT: extracts features
backend/model_inference.py - Live ML Inference → Baseline Normalizer: normalizes features
backend/model_inference.py - Live ML Inference → Trained Model Artifacts: loads model
backend/model_inference.py - FastAPI Backend → Dashboard WebSockets: broadcasts payload
backend/main.py - Dashboard WebSockets → WebSocket Client: sends dashboard data
README.md - WebSocket Client → FastAPI Backend: sends commands
README.md - Dashboard User → Dashboard App: views dashboard
README.md - Dashboard App → WebSocket Client: connects
frontend/src/App.jsx - Dashboard App → Signals Views: renders signals
frontend/src/App.jsx - Dashboard App → Band Power View: renders bands
frontend/src/App.jsx - Dashboard App → Classifier View: renders classifier
frontend/src/App.jsx - Signals Views → Channel Chart: renders waveforms
frontend/src/components/SignalsTab.jsx - Signals Views → FFT Plot: renders spectrum
frontend/src/components/SignalsTab.jsx - Classifier View → Stress Gauge: renders gauge
frontend/src/components/ClassifierTab.jsx - Dataset Builder → Band Power & FFT: extracts features
ml/build_dataset.py - EEGMAT Conversion → Dataset Builder: prepares dataset
- Dataset Builder → Random Forest Training: provides features
- Dataset Builder → CNN Comparison: provides features
- Random Forest Training → Trained Model Artifacts: produces artifact