Overview
This interactive application simulates Electroencephalography (EEG) brain waves and demonstrates how
Fuzzy Logic can be applied to classify human cognitive states. Unlike standard boolean
logic (True/False), Fuzzy Logic deals with degrees of truth, making it highly suitable for noisy, continuous
biological signals like EEG.
How to Use
- Interactive Canvas: The top panel shows the raw simulated EEG signal. The bottom left
shows a frequency spectrum (bands). The bottom right visualizes the Fuzzy Logic membership sets and
inference.
- State Buttons: Click the buttons (Deep Sleep, Relaxed, etc.) to simulate different
mental states. Watch how the frequency composition changes.
- Sonification: Click "Sound Off" to toggle audio. The system maps the dominant EEG
frequencies to a musical chord (Delta=Root, Theta=Third, Alpha=Fifth, Beta=Seventh, Gamma=Octave). The
volume of each note reflects the power of that brainwave band.
- Demo Mode: Click "Play Demo" to automatically cycle through states. Demo mode also
starts automatically after 10 seconds of inactivity. Click anywhere to stop it.
Technical Details: EEG & Frequencies
An EEG signal is a complex waveform representing electrical brain activity. We decompose this signal into
distinct frequency bands:
- Delta (0.5 - 4 Hz): Dominant in deep, dreamless sleep.
- Theta (4 - 8 Hz): Present during drowsiness, light sleep, or
deep meditation.
- Alpha (8 - 13 Hz): Associated with relaxed, calm, lucid states.
Often peaks when eyes are closed.
- Beta (13 - 30 Hz): Active, busy, or anxious thinking and active
concentration.
- Gamma (30+ Hz): High-level cognitive processing, peak focus, and
information synthesis.
Technical Details: Fuzzy Logic Engine
In this simulation, we implement a Fuzzy Inference System (FIS) in JavaScript:
- Fuzzification: We take the crisp normalized power (0.0 to 1.0) of the Alpha and Beta
bands. We pass these values through membership functions (triangles). For example, an Alpha power of 0.6
might be 20% "Medium" and 80% "High".
- Rule Evaluation: We apply logical rules. Example: IF Alpha is High AND Beta is Low
THEN State is Relaxed. In fuzzy logic, AND is typically computed as the minimum of the two
fuzzy values.
- Defuzzification: We aggregate the results of the rules to compute a crisp "Cognitive
Alertness" score (shown as the gauge on the bottom right), using a simplified weighted average.
Future Directions
In real-world Brain-Computer Interfaces (BCIs), Fuzzy Logic is often combined with Neural Networks
(Neuro-Fuzzy Systems like ANFIS) to automatically tune the membership functions based on user-specific
training data. This handles inter-subject variability, as one person's "High Alpha" might look different
from another's.