Skip to content

upsidedownlabs/CortEX

Repository files navigation

πŸ§˜β€β™€οΈ CortEX – Real-Time Neurofeedback Meditation Platform

πŸ“ Project Overview

CortEX is a cutting-edge, real-time web application designed to empower users through neurofeedback during meditation. Built using Next.js and TypeScript, the platform integrates EEG and ECG biopotential signals via Bluetooth Low Energy (BLE) to deliver a personalized, data-driven meditation experience.


πŸ”Œ Hardware Requirement

To use CortEX effectively, you'll need:

A BLE-enabled biopotential signal board designed for:

  • βœ… EEG (Electroencephalogram)
  • βœ… ECG (Electrocardiogram)
  • βœ… EMG (Electromyogram)
  • βœ… EOG (Electrooculogram)

πŸ’‘ CortEX uses the NPG Lite’s BLE stream for real-time brain and heart activity visualization.

πŸ”‘ Core Features

1. Real-Time EEG & ECG Visualization

  • EEG waveforms: Raw EEG data of the Left and Right hemispheres
  • EEG FFT spider plot The Left and Right hemispheres EEG FFT data display Delta, Theta, Alpha, Beta, Gamma brainwave signals.
  • ECG line graphs: Clean, real-time ECG plots to extract heart metrics.
  • Heart Rate Variability chart: Displays real-time heart rate variability.
  • Rendering: Uses WebGL for performance and Recharts for intuitive graphing.

2. Mental & Physical State Classification

EEG-Based States

  • Relaxed: High Alpha, moderate Theta.
  • Focused: High Beta and Gamma.
  • Drowsy: Dominance of Delta/Theta.
  • Meditative: Balanced Alpha and Theta with suppressed Beta.

ECG-Based Physical States

  • HRV Metrics:
    • BPM (Beats Per Minute): Heart rate over time.
    • SDNN (Standard Deviation of NN intervals): General variability (resilience).
    • RMSSD (Root Mean Square of Successive Differences): Short-term parasympathetic activity.
    • pNN50 (Percentage of successive NN intervals differing by >50 ms): % of adjacent NN intervals differing >50ms.
    • High HRV β†’ Relaxed, Low HRV β†’ Stress/Fatigue.

3. Session Management & Analytics

  • Start, pause, and end meditation sessions.
  • Automatically logs:
    • Session duration
    • Time in each mental state
    • Average EEG band power
    • Heart rate trends & HRV indicators
  • Summary dashboard:
    • Radar/pie charts for brainwave distribution
    • State classification timeline
    • Focus and relaxation scores

4. Left/Right Hemisphere Symmetry

  • Tracks brain symmetry for cognitive balance:
    • Separate EEG band power for left vs. right (e.g., F3 vs. F4)
    • Visual meters and difference plots

5. Dynamic Feedback

  • Real-time UI adjustments (e.g., color shift, waveform smoothness)
  • Breathing circle animation synced with heart rate
  • Motivational quotes between sessions

βš™οΈ Technical Architecture

πŸ’‘ Signal Processing Pipeline

Handled in Web Workers to ensure real-time performance:

  • EEG/ECG filtering (bandpass, notch)
  • FFT
  • Band power integration
  • HRV computation (SDNN, RMSSD, pNN50)

🧠 Mental State Detection Algorithm

  • FFT on sliding EEG windows
  • Band power extraction
  • Normalization & ratio calculation
  • Rule-based or ML-based classification

❀️ ECG Analysis Flow

  • Detect R-peaks using threshold and derivative methods

  • Calculate RR intervals (time between successive heartbeats)

  • Derive the following HRV (Heart Rate Variability) metrics:

    • BPM (Beats Per Minute): Average heart rate over time
    • SDNN (Standard Deviation of NN intervals): Reflects overall variability and resilience
    • RMSSD (Root Mean Square of Successive Differences): Measures short-term vagal (parasympathetic) activity
    • pNN50 (Percentage of successive NN intervals differing by >50 ms): Indicator of parasympathetic nervous system strength

πŸ’» Code Structure

🎨 UI/UX Highlights

  • Tailwind CSS for styling
  • Light/Dark modes for comfort
  • Responsive animations for feedback
  • Radar plots, progress bars, symmetry meters for clarity

πŸ“¦ Technologies Used

  • Frontend: Next.js, React, TypeScript
  • Visualization: WebGL (webgl-plot), Recharts
  • Data Streaming: Web Bluetooth API (BLE)
  • Performance: Web Workers
  • Styling: Tailwind CSS

🧩 Credits

Built with great tools and libraries:

  • Next.js, React, TypeScript
  • Tailwind CSS, Framer Motion, Lucide React
  • Radix UI components (accordion, dialog, popover, etc.)
  • Recharts, webgl-plot for visualization
  • Embla Carousel for UI interactions
  • ESLint, PostCSS, and DefinitelyTyped type definitions

Thanks to all the amazing communities!


🧠 Summary Comparison Table

Feature Traditional Apps 🧘 CortEX
EEG/ECG Integration ❌ Uses timers/audio βœ… Real EEG/ECG via BLE
Real-Time Feedback ❌ Post-session only βœ… Live state updates, synced animations
HRV Metrics ❌ BPM at best βœ… Full: BPM, SDNN, RMSSD, pNN50
Open-source Extensibility ❌ Closed-source βœ… Developer-friendly, research-ready
Custom Signal Processing ❌ Black-box/no processing βœ… Built-in FFT, filters, classifiers
Hemisphere Tracking ❌ Not available βœ… Symmetry-based brain analysis

🌈 Why It Matters

  • 🎯 Precision: Quantify your progress, not just guess it.
  • 🧘 Effectiveness: Optimize your meditation with evidence.
  • πŸ§ͺ Science-backed: Built on peer-reviewed methods.
  • πŸ” Transparency: Know how everything works.
  • πŸ› οΈ Flexibility: Ideal for tinkerers, researchers, and biohackers.

πŸ“½οΈ YouTube Demo

Coming soon!

πŸ“ Author

πŸ’« Built with love, neurons, and a sprinkle of curiosity by Ritika Mishra – decoding mindfulness, brainwave and heartwave.

🀝 Contributing

Thank you for your interest in contributing β€” your support helps shape the CortEX. πŸ™Œ

Aman Maheswari
Aman Maheswari
Deepak Khatri
Deepak Khatri
Deepesh Kumar
Deepesh Kumar
Krishnanshu Mittal
Krishnanshu Mittal
Ritika Mishra
Ritika Mishra

At CortEX, we celebrate collaboration, curiosity, and creativity.

Whether you're a neuroscientist, developer, designer, or simply someone deeply fascinated by the mind and inner states β€” there's a place for you here. Let's build meaningful, mindful experiences together.


πŸ“ License

This project is licensed under the MIT License – see the LICENSE file for details.

About

CortEX is a web application for assistive meditation using brain and heart signals recorded using Neuro PlayGround.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •