All projects

Research prototype

CerebralFlow

A research prototype for moving physiological signals through validation before they drive coupled-oscillator simulations.

Brain-dynamics digital-twin framework using Hilbert phases, PLI/wPLI connectivity, surrogate testing, and time-varying Kuramoto networks.

PythonSciPyNumPyKuramoto 2025 2 min read
GitHub repo

Problem

Brain-signal pipelines can fool themselves if connectivity estimates are not checked against a null model before driving a simulation.

What I built

I built a pipeline from physiological signals to Hilbert phases, PLI/wPLI connectivity, surrogate null tests, and a time-varying Kuramoto oscillator network.

Proof & verification

Every connectivity estimate is checked against phase-shuffled surrogates with a significance test before it calibrates the Kuramoto model, so structure that survives is non-random rather than assumed.

architecture

System design

The architecture gates each stage: signal → phase extraction → connectivity → statistical null test → generative Kuramoto simulation.

CerebralFlow pipeline raw physiological signal · multi-channel time series eeg / synthetic / openbci hilbert transform instantaneous phase PLI / wPLI connectivity matrix surrogate generator phase-shuffled nulls significance tester p-value · z-score kuramoto oscillator network dφi/dt = ωi + Σ Kij sin(φj − φi) time-varying coupling K(t) data → connectivity → validation → generative simulation
signals become connectivity become a generative model — validated against random nulls before anything is simulated.

hover or tab through any stage to trace the pipeline

deep-dive

System deep-dive & failure modes

Failure mode

The central failure mode is false structure: without surrogate testing, the simulation can faithfully reproduce noise dressed up as connectivity.

WHAT MAKES THIS RIGOROUS

A research-engineering prototype: a pipeline with clear stages (signal → connectivity → validation → generative simulation), each one independently inspectable, with a statistical null model so the output of one stage is not allowed to fool the next.

CerebralFlow is a research-prototype framework for constructing "digital twins" of brain dynamics — pipelines that take physiological signals, extract a functional network from them, validate that network against random null models, and then drive a generative simulation that reproduces the observed activity.

The signal side uses Hilbert transforms to extract instantaneous phase and intrinsic frequency per channel. The connectivity side uses Phase Lag Index and weighted PLI to estimate coupling while suppressing volume-conduction artifacts. The validation side generates phase-shuffled surrogates and runs a significance test — so you know whether the connectivity you measured is real structure or noise dressed up as structure.

DESIGN NOTE

The unglamorous part of neural-signal work is that correlation between two phase-locked sine waves isn't connectivity — volume conduction will fake any structure you want. PLI throws away the zero-lag component on principle. Surrogate testing then proves the remainder is non-random. Without these two steps the simulation is decorative; with them, it's a hypothesis.

The simulation engine is a time-varying Kuramoto network — a coupled-oscillator model whose generative dynamics, calibrated to the data, can be perturbed to ask "what happens if we stimulate node X?" That's the digital-twin promise: you simulate before you intervene.

example pipeline output
step 1   signal data inversion
  extracted phases shape: (10, 1024)
  estimated frequencies:   mean = 10.12 Hz

step 1.5 statistical validation (surrogates)
  generating 20 phase-shuffled surrogates...
  observed mean connectivity: 0.4215
  surrogate mean (N=20):      0.4208
  z-score: 0.15  ·  p-value: 0.4500
  result is NOT statistically significant
   (expected — input was random noise)

step 1.6 advanced connectivity (PLI)
  PLI matrix mean: 0.3805

step 9   closed-loop optimization
  final error: 1.0520

pipeline completed successfully.
            

takeaways

Engineering takeaways

For research software, the most important engineering boundary is often the statistical one: prevent one stage from laundering assumptions into the next.

contact

Open to backend systems, AI infrastructure, and product engineering roles.

↑↓ navigate ↵ open / or Ctrl K anywhere