Politecnico di Milano · NAML 2025-26 · PyANNOW v2.0.0

The Worm Dances to Chopin

The 302-neuron nervous system of C. elegans, simulated by OpenWorm, wired into a physical piano model — each body wall muscle contraction triggers a hammer strike. NAML algorithms close the gap to F1 = 0.933 matching Chopin.

302 neurons PyANNOW v2.0.0 F1=0.933 10 NAML steps
v2.0.0 Python 3.10-3.13 NAML 2025-26 AppStat 2026 Politecnico di Milano OpenWorm · C. elegans MIT
🐛 Watch the worm dance 📊 NAML Presentation v2 ⭐ GitHub 📓 Notebooks
The project

Biology + Mathematics + Music — two directions

C. elegans has exactly 302 neurons and 96 body wall muscles — the simplest animal with a fully mapped connectome (White et al. 1986). v1.x turns that connectome into a composer: NAML algorithms align the worm's body wave to Chopin's nocturne (best F1 = 0.933). v2.0.0 inverts the pipeline: Chopin's patterns are extracted via RSVD + K-means, ranked by Pearson excitability, and mapped onto 96 muscles — the worm dances to the music in real time in your browser.

302
C. elegans neurons
(complete connectome)
96
body wall muscles
= 96 piano pitches
8
Chopin musical states
(K-means K*=8)
0.933
best musical F1
(v1 Step 9 Worm+Time)
229 s
Chopin nocturne
fully covered (v1 + v2)
7
NAML methods
in v2 pipeline
v2.0.0 — Live demo

The Worm Dances to Chopin

Chopin's Nocturne in C# minor is decomposed into K*=8 recurring patterns via RSVD (Eckart-Young) + K-means (silhouette criterion), ranked by biological Pearson excitability, and mapped to 96 body-wall muscles via least-squares regression. Body wave, neural circuit panel, locomotion trail, and pattern timeline — all live.

Step 1 · L06–L09
RSVD — Eckart-Young
M ∈ ℝ^{56×11711} → U_k Σ_k V_k^T, k=12 (90% variance)
Step 2–3 · L10 · Lab02
K-means + Silhouette
Cluster V_k time frames → K*=8 musical states
Step 4 · AppStat
Pearson Excitability
max|r(V_p[:,i], Z_worm[:,j])| ranks patterns by biological resonance
Step 5 · L07/L09 · Lab03
Least Squares W_nm
lstsq(Z_worm, V_mus) → neural→96-muscle map
Step 6
Synthetic body wave
4 piano modes → synthMusFromVp → locomotion (FORWARD/TURN/HALT)
📊 Full NAML presentation 📓 Notebook 06 ↗ Full-screen demo
Sub-projects

Modules & Presentations

Each module targets a different PoliMi course and a different layer of the pipeline. Presentations open in-browser (Reveal.js · CDN-only · works anywhere). Notebooks open in nbviewer — no install required.

🧠
NAML 2025-26 · Prof. Miglio

PyANNOW

v2.0.0 (inverse): Chopin → RSVD (Eckart-Young, k=12) → K-means (K*=8) → Pearson excitability → lstsq → 96-muscle worm dance. Live browser demo above ↑

v1.x (forward): 10-step Worm→Music journey: SVD → K-means → Ridge → MLP → Adam → L-BFGS → RF → PINN → Worm+Time hybrid MLP (F1=0.933) → full-piece 229 s WAV.

Boyle 4×24 model · 96-cell simulation · Karplus-Strong piano synthesis.

📊
AppStat 2026 · Profs. Beraha & Andre

wormuse-analytics

Applied Statistics pipeline for worm-music data:
PCA + t-SNE + UMAP on neural activity → K-means / DBSCAN / GMM clustering of motor states → OLS + Ridge diagnostics (VIF · Breusch-Pagan · Durbin-Watson) → Logistic regression + Random Forest classification → ROC/AUC for onset detection quality → Statistical validation of the NAML pipeline.

🔧
AMSC · Prof. Formaggia

wormuse-sim

C++ Sibernetic wrapper (RAII · shared-library ABI) → OpenWorm Docker integration (Sibernetic SPH + C302 neural) → MPI distributed parameter search → Azure NC24-A100 GPU acceleration of the PINN training loop → Piano FEM modal synthesis upgrade (Chabassier 2014).

Presentation and notebooks in a future release.

Note on audio: The NAML presentation includes HTML5 audio players that stream directly from GitHub Releases v1.0.0 — no download required. To generate the audio locally, run Step 10 in 03_pyannow_naml_progression.ipynb which produces step_outputs/worm_mlp_full.wav and chopin_synth_full.wav. All slides, equations, and code are fully functional online.

Algorithm progression

PyANNOW — 10 NAML Steps

Each step introduces one new method from the NAML course and measures its impact on musical F1 (onset timing accuracy, ±50 ms tolerance). Step 0 deterministic body-wave is the floor; Step 9 Worm+Time MLP is the best.

STEP 0
Body-wave baseline
F1 = 0.217
Deterministic · IOI=0.447
STEP 1a/b · L06/L09
SVD + Procrustes
F1 = 0.095 – 0.186
302-D → k=4 PCs · Eckart-Young theorem
STEP 2 · L08/L10
K-means clustering
F1 = 0.109
Motor primitives · unsupervised
STEP 3 · L07/L11
Ridge regression
F1 = 0.286
▲ first supervised · beats baseline
STEPS 4-6 · L14-22
MLP + Adam + L-BFGS
F1 ≈ 0.25
JAX autodiff · tanh · 2-stage optimiser
STEP 7 · AppStat Lec07
Random Forest
F1 = 0.872
▲▲ 100 trees · OOB=0.829 · huge leap
STEP 8a/b · L14+L27
ODE + PDE PINN
Physics focus
Locomotion ODE · 1D wave eq. along body
STEP 9 · NB04 + AppStat ★
Worm+Time hybrid MLP
F1 = 0.933 ★ BEST
Fourier(27-D) + worm PCA · 10s window
+8.7pp above NB04 time-only ceiling
STEP 9b · L27
Physics-residual MLP
F1 ≈ 0.933
+ ODE residual feature · tied with Step 9
STEP 10 · NB04+Step9b
Full-piece 229s generalization
Full-length WAV 🎵
Train on full piece · t/T∈[0,1] always · no extrapolation
All notebooks

Jupyter Notebooks — v1.x forward + v2.0 inverse

Open in nbviewer (rendered, no install needed) or view directly on GitHub (native .ipynb rendering). Run locally: clone the repo and pip install pyannow && jupyter lab

Notebook Module Key topics Open
06_chopin_patterns_worm_dance_v2
v2.0.0 inverse pipeline · Chopin → worm dance · fully executed
NAML Piano-roll M∈ℝ^{56×11711} · RSVD (Eckart-Young, k=12) · K-means K*=8 · Pearson excitability · lstsq W_nm · synthetic body wave · worm dance JS viz
03_pyannow_naml_progression
Main PyANNOW notebook · Steps 0-10 · fully executed
NAML SVD · K-means · Ridge · MLP · Adam · L-BFGS · RF · PINN (ODE+PDE) · Worm+Time MLP · NB04+Step9b full-piece · F1=0.933
05_pyannow_step9b_audio
Step 9b · full 229s Chopin piece · Karplus-Strong piano synthesis
NAML Step 9b · full-piece (229 s) · Karplus-Strong piano · physics-residual MLP · audio render pipeline · F1=0.933
04_chopin_score_net
NB04 · pure Fourier time-net · F1=0.858 ceiling
NAML Fourier positional encoding · full-piece training · NB04 recipe · onset detection · worm biology headroom proof
02_chopin_worm_optimizer
Parameter optimiser for the Boyle worm model
NAML Boyle 4×24 model · ion-channel parameters · Nelder-Mead · Adam · onset loss surface
01_appstat_lecture_audit
AppStat methods applied to worm-music data
AppStat PCA · t-SNE · UMAP · clustering (K-means/DBSCAN/GMM) · OLS + VIF · RF · ROC/AUC · statistical validation
scientific_foundation_demo
Mathematical foundations · cross-system equivalence
docs Worm ODE ↔ piano PDE structural correspondence · PINN residual · Boyle model derivation · 20-row equivalence table