Mentality Pipeline / v0.1

Thesis

Capture the trader,
not just the market.

Every quant system records market data tick by tick. The person pressing the button remains invisible. This project records heart rate, gaze, facial expression, and on-screen context — synchronized on a single monotonic clock with market ticks — so every decision point becomes a structured, queryable row in a multimodal dataset. Runs on a webcam alone; pair a BLE heart-rate strap for clinical-grade HR.

What each stream captures

MediaPipe FaceMesh · 478 pts

01

Webcam Context

The behavioral layer a wearable can never produce. Iris-based gaze, 52 facial blendshapes, head pose, and a cross-validation rPPG pulse — all from a standard laptop camera. Runs entirely in the browser.

  • gaze direction from iris landmarks
  • expression coefficients (browInnerUp · jawOpen · eyeSquint)
  • head yaw / pitch / roll
  • simplified EVM for visible pulse evidence

BLE 0x180D · optional ground truth

02

Wearable HR

Plug in any standard BLE HR strap (Polar H10 / Garmin HRM-Dual / Wahoo TICKR) via Web Bluetooth. Clinical-grade BPM plus raw RR intervals for real-time RMSSD (HRV). When connected, it becomes the baseline and the webcam rPPG serves as validation.

  • ±1 BPM accuracy
  • RR intervals → RMSSD / SDNN
  • contact detection + battery
  • webcam ↔ wearable delta shown live

monotonic ms · IndexedDB

03

Sync Layer

Every sample — biometric, behavioral, and market — is stamped with performance.now() from the same session origin. Nothing leaves the browser. Exported as one CSV ready for pandas.pivot_table across every stream.

  • single origin for all streams
  • 5-stream unified CSV export
  • privacy-first: no frames uploaded
  • Dexie / IndexedDB · local only

One moment, one row

What the pipeline produces at a single decision point. Every column shares the same tsMs — the level of synchronization required to detect patterns that span market state and trader state simultaneously.

tsMs        42517.231
market      symbol=BTCUSDT price=63_420.10 change1m=-3.12%
wearable    bpm=108 rmssd=22ms // baseline 74 → +46%
webcam      rppg_bpm=105 signal_q=0.71 peak_hz=1.78
face_ctx    gaze=left browInnerUp=0.72 jawOpen=0.31 head_pitch=-8°
event       type=warning_breach payload={source:"wearable",dev:46.2}
→ inferable pattern  sharp drop + brow tension + gaze averted + HR spike = panic-response candidate

This row format is what gets persisted per session. Pattern discovery is a downstream task; the pipeline's job is to make that discovery possible by recording the right signals at the right resolution.

Scope

Phase 1

implemented

Real-time collection infrastructure

  • 01MediaPipe FaceMesh 478 — iris + 52 blendshapes + head pose
  • 02Web Bluetooth BLE HR strap integration (Polar, Garmin, Wahoo)
  • 03POS rPPG + Butterworth + FFT — cross-validation pulse
  • 04Simplified EVM (realtime + freeze-compare)
  • 05Multi-stream monotonic sync · Context Timeline
  • 06Unified CSV export (all 5 streams, single tsMs axis)

Phase 2

planned

Behavioral pattern analysis

  • 01Screen capture sync (getDisplayMedia) — what was viewed
  • 02Brokerage API → real trade-log ingestion
  • 03Apple Health / Garmin Connect CSV import (non-BLE watches)
  • 04LLM weekly / monthly multimodal → natural-language report
  • 05Flag suspected emotional-trading transactions vs baseline
→ Launch Live DemoPast Sessions / Export

Honest specs

Wearable HR: clinical-grade (±1 BPM) when connected. Becomes the primary signal.

Webcam rPPG: ±5–10 BPM under good lighting and minimal motion. Used for cross-validation and for demo scenarios with no wearable.

Face context: direction + expression + pose. Not precise gaze-to-screen mapping (no calibration).

Privacy: raw video frames never leave the browser. Only derived metrics persist to local IndexedDB.

Browser support: Web Bluetooth requires Chrome, Edge, or Opera on desktop. Webcam features run everywhere.

What this isn't: not a medical device, not a completed prediction model. It is the data infrastructure that precedes both.