For the NeuroSkill real-time EEG API · v0.0.1

NeuroSkill™ 🧠

A command-line interface for the NeuroSkill real-time EEG analysis API. WebSocket & HTTP transport, 20+ EEG indices, sleep staging, GPU-accelerated HNSW search.

⚠ Research Use Only — not a clinical tool, not FDA/CE-cleared.

terminal
$ neuroskill status
Muse-A1B2 · battery 73% · session 30m 47s
Focus0.70
Cognitive Load0.33
Relaxation0.40
Drowsiness0.10
Meditation0.52
Heart Rate68 bpm
δ ▓▓▓▓▓▓ θ ▓▓▓▓ α ▓▓▓▓▓▓▓ β ▓▓▓▓ γ
$ neuroskill status --json | jq '.scores.focus'
0.70
$
20+ EEG IndicesWebSocket & HTTPHNSW SearchGPU UMAPSleep StagingSemantic LabelsHRV / PPGConsciousness Metrics
Install
npm npm install -g neuroskill
npx npx neuroskill <command>

Getting Started

Quick Start

Install via npm or build from source. Requires a locally running NeuroSkill server — NeuroSkill™ auto-discovers the port via mDNS or lsof.

01
Install
npm install -g neuroskill or build from source
02
Connect
Start NeuroSkill server. NeuroSkill™ auto-discovers via mDNS.
03
Query
Run NeuroSkill™ status for a full EEG snapshot.
terminal
# Install globally
npm install -g neuroskill

# Or run from source
git clone https://github.com/NeuroSkill-com/neuroskill neuroskill && cd neuroskill
npm install && npm run build

# First command: full snapshot
neuroskill status

# Pipe scores to jq
neuroskill status --json | jq '.scores.focus'

# Live neurological correlates
neuroskill neurological

# Stream events for 10 seconds
neuroskill listen

Port Discovery Order

  1. 1--port <n> flag — skips all discovery
  2. 2mDNS _skill._tcp — 5 s timeout
  3. 3lsof / pgrep fallback — probes TCP LISTEN ports

Output Modes

default human-readable colored summary
--json raw JSON · pipe-safe
--full summary + colorized JSON
--dot Graphviz DOT (interactive only)

Architecture

How It Works

From raw EEG µV to semantic brain-state search — the full signal processing pipeline.

signal-pipeline.txt
Muse BLE (256 Hz raw µV)
        │
        ▼
  High-pass filter  (0.5 Hz — removes DC drift)
        │
        ▼
  Low-pass filter   (50 Hz — removes high-freq noise)
        │
        ▼
  Notch filter      (50/60 Hz + harmonics — powerline)
        │
        ▼
  GPU overlap-save convolution  (gpu-fft, ~125 ms latency)
        │
        ▼
  Hann-windowed FFT  (512-sample window, ≈2 s epoch)
        │
        ▼
  Band-power integration  (Welch-style per-band PSD)
        │
        ▼
  ZUNA encoder → 128-dim EEG embedding (5-sec epochs)
        │
        ▼
  HNSW index  (approximate nearest-neighbor search)
        │
        ▼
  All indices, ratios, composite scores, WebSocket/HTTP
🧠

Muse EEG Hardware

Muse 2 / Muse S — 4 dry electrodes, 256 Hz BLE streaming.

CH1 TP9
Left mastoid
Temporal, reference-like
CH2 AF7
Left prefrontal
Executive, approach, FAA
CH3 AF8
Right prefrontal
Withdrawal, emotion, FAA
CH4 TP10
Right mastoid
Temporal, reference-like

Transport Layer

Dual transport — NeuroSkill™ picks the best one automatically.

WebSocket default

Full-duplex, low-latency. Live event streaming. Auto-selected when server is reachable.

HTTP REST fallback

POST to http://127.0.0.1:<port>/. curl-friendly. No streaming.

🔮

ZUNA Neural Encoder

GPU-accelerated deep neural encoder. Converts each 5-second EEG epoch into a 128-dimensional vector.

input: 4 channels × 1280 samples @ 256 Hz
output: 128-dim embedding vector
backend: burn + wgpu compute shaders
metric: cosine distance in embedding space
🔍

HNSW Similarity Search

Hierarchical Navigable Small World graph for approximate nearest-neighbor search over millions of embeddings.

Distance metric cosine (0=identical)
Latency sub-millisecond
Storage eeg.sqlite per day
3D Projection GPU UMAP (fast-umap)
🕸️

4-Layer Interactive Graph Search

Cross-modal search combining semantic text embeddings with EEG similarity in a directed graph.

query
Layer 0 · Your search term embedded
text_label
Layer 1 · Semantically similar annotations
eeg_point
Layer 2 · Raw EEG moments from label windows
found_label
Layer 3 · Labels near those EEG moments
# 4-layer cross-modal graph search
neuroskill interactive "deep focus" --k-text 5 --k-eeg 5 --k-labels 3

# Layer 0: query embedding
# Layer 1: semantically similar text labels
# Layer 2: EEG moments from label time windows  
# Layer 3: labels discovered near those EEG moments

# Get the graph as JSON
neuroskill interactive "focus" --json | jq '.nodes | length'

# Extract found labels from layer 3
neuroskill interactive "meditation" --json \
  | jq '[.nodes[] | select(.kind == "found_label") | .text]'

# Render as SVG with graphviz
neuroskill interactive "anxiety" --dot | dot -Tsvg > graph.svg
search-examples.sh
# ANN similarity search: find past moments like now
neuroskill search                        # auto: last session, k=5
neuroskill search --k 20                 # more neighbors
neuroskill search --start 1740412800 --end 1740415500

# Search over 14,000+ embeddings in milliseconds
# Results include distance, timestamp, and metrics:
# {
#   "distance": 0.0231,
#   "timestamp_unix": 1740320040,
#   "metrics": { "focus": 0.73, "hr": 66.2 }
# }

# Search labels semantically
neuroskill search-labels "meditation" --mode both --k 10

# Available modes: text | context | both

CLI Reference

Commands

All commands work over WebSocket and HTTP. Use --json for pipe-safe output.

neuroskill status
core

Full device / session / scores snapshot

neuroskill neurological
core

EEG correlate indices + consciousness metrics (0–100)

neuroskill session [index]
core

All metrics + trends for one session (0 = latest)

neuroskill sessions
core

List all recording sessions across all days

neuroskill label "text"
annotation

Create a timestamped annotation on the current moment

neuroskill search-labels "query"
search

Semantic vector search across all your EEG annotations

neuroskill interactive "keyword"
search

Cross-modal 4-layer graph search (labels → EEG → labels)

neuroskill search
search

ANN EEG-similarity search (auto: last session, k=5)

neuroskill compare
analysis

Side-by-side A/B metrics (auto: last 2 sessions)

neuroskill sleep [index]
analysis

Sleep staging — index selects session (0 = latest)

neuroskill umap
analysis

3D UMAP projection with GPU acceleration + live progress

neuroskill listen
stream

Stream broadcast events (EEG packets, scores, labels)

neuroskill calibrate
control

Open calibration window and start immediately

neuroskill timer
control

Open focus-timer window and start work phase

neuroskill notify "title"
control

Show a native OS notification

neuroskill say "text"
control

Speak text aloud via on-device TTS

neuroskill raw '{"command":"..."}'
dev

Send arbitrary JSON and print full response

Global Options

--port <n> Connect to explicit port (skips mDNS)
--ws Force WebSocket transport
--http Force HTTP REST transport
--json Raw JSON only — no summary, no colors
--full Human-readable + colorized JSON below
--dot Graphviz DOT to stdout (interactive only)
--k <n> Number of nearest neighbors
--k-text <n> (interactive) k for text-label search
--k-eeg <n> (interactive) k for EEG-similarity search
--k-labels <n> (interactive) k for label-proximity
--reach <n> (interactive) temporal reach in minutes
--mode <m> search-labels: text | context | both
--poll <n> (status) Re-poll every N seconds
--seconds <n> (listen) Duration in seconds
--no-color Disable ANSI colors

Signal Science

EEG Metrics

Every metric is derived from peer-reviewed neuroscience research. Each 5-second epoch is processed at ~4 Hz update rate.

Frequency Bands

δ
Delta
1–4 Hz
Deep sleep (N3), motivational processes
θ
Theta
4–8 Hz
Drowsiness, working memory, creativity
α
Alpha
8–13 Hz
Relaxed wakefulness, idle cortex
β
Beta
13–30 Hz
Active thinking, focus, alertness
γ
Gamma
30–50 Hz
Higher cognition, perceptual binding

Brain State Scores 0–100 scale, updated at ~4 Hz

score
Focus
β / (α + θ)
Relaxation
α / (β + θ)
Engagement
β / (α + θ)
Meditation
α/β · stillness · HRV
Cognitive Load
θ_frontal / α_temporal
Drowsiness
TAR + TBR + (1−BAR)
Mood
50 + 50·tanh(FAA·k)

EEG Indices & Ratios

TAR Theta/Alpha Ratio
AF7, AF8
P_θ / P_α

Drowsiness, mind-wandering, inward attention. > 1.5 = theta dominant.

BAR Beta/Alpha Ratio
AF7, AF8
P_β / P_α

Alert vs. relaxed. High = engaged cognition, Low = drowsy.

TBR Theta/Beta Ratio
AF7, AF8
P_θ / P_β

Most replicated ADHD biomarker in research. > 3 = elevated.

FAA Frontal Alpha Asymmetry
AF7, AF8
ln(P_α_AF8) − ln(P_α_AF7)

Approach (positive) vs. withdrawal (negative) motivation and emotional valence.

PSE Power Spectral Entropy
All 4
-Σ p_i·log₂(p_i)

Uniformity of power distribution. Near 1 = white noise, Low = dominant frequency.

APF Alpha Peak Frequency
AF7, AF8
argmax PSD(f), f∈[7.5,12.5]

Cognitive speed marker. ~10 Hz typical; slows with age, fatigue, pathology.

HFD Higuchi Fractal Dimension
AF7, AF8
slope of log L(m) vs log(1/m)

Time-domain complexity. Higher = more irregular (awake). Lower = sleep/anesthesia.

PAC Phase-Amplitude Coupling
AF7
|(1/N)Σ A_γ·e^{iφ_θ}|

θ–γ coupling: working memory encoding mechanism. Strong during demanding tasks.

DFA Detrended Fluctuation Analysis
AF7
slope of log F(n) vs log(n)

Long-range temporal correlations. α≈0.6–0.9 = healthy waking EEG.

PE Permutation Entropy
All 4
-Σ p(π)·log p(π)

Ordinal complexity. High = maximal irregularity. Consciousness marker.

Coherence Inter-hemispheric Alpha Coherence
AF7↔AF8
|C_xy(f)|², f∈[8-13Hz]

Phase sync between hemispheres. High = bilateral coordination, meditation.

SEF95 Spectral Edge Frequency 95%
All 4
min f: ∫PSD ≥ 0.95·∫total

Frequency below which 95% of power lies. Decreases with drowsiness.

PPG / Cardiac & Autonomic Metrics

From the Muse forehead PPG sensor (64 Hz, red + infrared LEDs). IBI series extracted via peak detection.

metricunit
Heart Ratebpm
RMSSDms
SDNNms
pNN50%
LF/HFratio
SpO₂%
Baevsky SIa.u.

Sleep Staging

Simplified AASM heuristics applied per 5-second epoch. Auto-generated for sessions ≥ 30 minutes.

0
Wake
Alpha-dominant, active beta
P_α > P_θ and BAR > 0.8
1
N1
Alpha fades, theta emerges
TAR > 1.0, SEF95 < 15 Hz
2
N2
Sleep spindles, K-complexes
P_θ dominant; P_δ rising; P_β low
3
N3
High-amplitude delta dominates
P_δ > P_θ + P_α; DTR > 2
4
REM
Active EEG, muscle atonia
P_θ high; P_δ low; BAR moderate

Developer Reference

API Reference

Every NeuroSkill™ command maps directly to a JSON API. Use the CLI, HTTP POST, or WebSocket — all return the same payload.

HTTP — curl compatible

http-api.sh
# Every command works over plain HTTP POST
curl -s -X POST http://127.0.0.1:8375/ \
  -H "Content-Type: application/json" \
  -d '{"command":"status"}' | jq '.scores.focus'

# Neurological indices
curl -s -X POST http://127.0.0.1:8375/ \
  -H "Content-Type: application/json" \
  -d '{"command":"neurological"}' | jq '.neurological'

# Search labels
curl -s -X POST http://127.0.0.1:8375/ \
  -H "Content-Type: application/json" \
  -d '{"command":"search_labels","query":"deep focus","k":5}'

# Interactive graph search
curl -s -X POST http://127.0.0.1:8375/ \
  -H "Content-Type: application/json" \
  -d '{
    "command":       "interactive_search",
    "query":         "deep focus",
    "k_text":        5,
    "k_eeg":         5,
    "k_labels":      3,
    "reach_minutes": 10
  }'

WebSocket — full duplex

websocket.js
// WebSocket — full duplex, low latency
const ws = new WebSocket('ws://127.0.0.1:8375');

ws.onopen = () => {
  ws.send(JSON.stringify({ command: 'status' }));
};

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  console.log('Focus:', data.scores?.focus);
};

// Stream live events
ws.send(JSON.stringify({ command: 'listen' }));

// wscat from terminal:
// wscat -c ws://127.0.0.1:8375
// > {"command":"status"}

status response shape

status-response.json
{
  "command": "status",
  "ok": true,
  "device": {
    "state": "connected",
    "name": "Muse-A1B2",
    "battery": 73,
    "firmware": "1.3.4"
  },
  "session": {
    "start_utc": 1740412800,
    "duration_secs": 1847,
    "n_epochs": 369
  },
  "signal_quality": {
    "tp9": 0.95, "af7": 0.88,
    "af8": 0.91, "tp10": 0.97
  },
  "scores": {
    "focus": 0.70,
    "relaxation": 0.40,
    "engagement": 0.60,
    "meditation": 0.52,
    "mood": 0.55,
    "cognitive_load": 0.33,
    "drowsiness": 0.10,
    "hr": 68.2,
    "snr": 14.3,
    "stillness": 0.88,
    "bands": {
      "rel_delta": 0.28,
      "rel_theta": 0.18,
      "rel_alpha": 0.32,
      "rel_beta":  0.17,
      "rel_gamma": 0.05
    },
    "faa": 0.042,
    "tar": 0.56,
    "bar": 0.53,
    "tbr": 1.06,
    "apf": 10.1,
    "coherence": 0.614
  }
}

Automation Recipes

recipes.sh
# Poll focus every 5 seconds
while true; do
  neuroskill status --json | jq '.scores.focus'
  sleep 5
done

# Alert when focus drops below 40%
while true; do
  FOCUS=$(neuroskill status --json | jq '.scores.focus')
  if (( $(echo "$FOCUS < 0.4" | bc -l) )); then
    neuroskill notify "Focus dropped" "Current: $FOCUS"
  fi
  sleep 10
done

# Label then immediately search
neuroskill label "deep work block"
neuroskill search-labels "deep work" --mode both

# Render interactive graph as SVG
neuroskill interactive "focus" --dot | dot -Tsvg > graph.svg

# Compare last two sessions
neuroskill compare --json | jq '.insights.deltas.focus'

# Sleep staging for last night
neuroskill sleep 0 --json | jq '.summary'

Key JSON Paths — jq Cheatsheet

.scores.focus — Current focus score (0–1)
.scores.bands.rel_alpha — Relative alpha power (0–1)
.scores.faa — Frontal Alpha Asymmetry
.scores.tbr — Theta/Beta Ratio (ADHD proxy)
.device.battery — Battery percentage
.session.n_epochs — Number of 5-s epochs recorded
.signal_quality.af7 — AF7 channel quality (0–1)
.neurological.adhd_index — ADHD correlate (0–100)
.consciousness.lzc — Lempel-Ziv complexity proxy
.sleep.n3_epochs — Deep sleep epoch count
.history.current_streak_days — Recording streak in days
.embeddings.total — Total embeddings in database

Use Cases

Use-Case Recipes

🎯

Focus & Productivity

neuroskill status --json | jq '.scores.focus'neuroskill label "focus block start"neuroskill search-labels "deep work"neuroskill compare --json | jq '.insights.improved'
😤

Stress & Anxiety

neuroskill neurological --json | jq '.neurological.anxiety_index'neuroskill status --json | jq '.scores.{"bar":.scores.bar}'neuroskill label "feeling stressed"neuroskill interactive "anxiety"
😴

Sleep Quality

neuroskill sleep 0 --json | jq '.summary'neuroskill sleep --json | jq '.analysis.efficiency_pct'neuroskill session 0 --json | jq '.metrics.drowsiness'neuroskill umap # visualize sleep vs wake
🧘

Meditation

neuroskill status --json | jq '.scores.meditation'neuroskill neurological --json | jq '.consciousness'neuroskill label "meditation start"neuroskill search-labels "meditation" --mode both
🧠

Cognitive Load

neuroskill status --json | jq '.scores.cognitive_load'neuroskill neurological --json | jq '.neurological.adhd_index'neuroskill session 0 --json | jq '.trends.cognitive_load'neuroskill compare --json | jq '.insights.deltas.tbr'

Automation

neuroskill status --json | jq '.scores.focus'neuroskill notify "Focus Alert" "Low focus detected"neuroskill timer # start focus timerneuroskill raw '{"command":"status"}'
🧠

Start reading your brain

Install NeuroSkill™, connect your Muse headset, and get EEG data straight in your terminal in under a minute.

npm install -g neuroskill
Visit neuroskill.com ↗
🧠 NeuroSkill™ · v0.0.1 · GPLv3 · © 2026 NeuroSkill.com ·Patent Pending
neuroskill.com · Discord · GitHub · 74 peer-reviewed references · Not FDA/CE-cleared