Code from: Sensory feedback and central neuronal interactions in mouse locomotion
Abstract
Locomotion is a complex process involving specific interactions between the central neural controller and the mechanical components of the system. The basic rhythmic activity generated by locomotor circuits in the spinal cord defines rhythmic limb movements and their central coordination. The operation of these circuits is modulated by sensory feedback from the limbs providing information about the state of the limbs and the body. However, the specific role and contribution of central interactions and sensory feedback in the control of locomotor gait and posture remain poorly understood. We use biomechanical data on quadrupedal locomotion in mice and recent findings on the organization of neural interactions within the spinal locomotor circuitry to create a tractable mathematical model of mouse locomotion. The model includes feedback signals characterizing the load and extension of each limb as well as postural stability. We investigate several model versions and compare their behavior to existing experimental data. Our results highlight specific roles of sensory feedback and some central propriospinal interactions between circuits controlling fore and hind limbs for speed-dependent gait expression. Our models suggest that postural imbalance feedback may be critically involved in the control of swing-to-stance transitions in each limb and the stabilization of walking direction.
Source code and run scripts accompanying:
Molkov YI, Yu G, Ausborn J, Bouvier J, Danner SM, Rybak IA. Sensory feedback and central neuronal interactions in mouse locomotion. Royal Society Open Science 11(8): 240207 (2024). doi:10.1098/rsos.240207
The paper develops a tractable mathematical model of quadrupedal mouse locomotion that combines biomechanics with the spinal locomotor circuitry, and uses it to dissect the contributions of sensory feedback and central neuronal interactions to gait and posture across speeds.
Repository layout
The bundle is distributed as code.zip. Unzip it to get three self-contained model variants, each in its own directory:
code.zip
└── code/
├── model1/
├── model2/
└── model3/
| Directory | Variant |
|---|---|
model1/ |
Model 1 — sensory-feedback-driven swing-to-stance / stance-to-swing transitions only (no central left–right or fore–hind interactions); -w 1e10 1e10 1e10 effectively disables central balance terms. |
model2/ |
Model 2 — adds central interactions (-w 0 10 -1), with a velocity-dependent ramp (second -v argument scales with speed). |
model3/ |
Model 3 — full model with central interactions (-w 0 10 0) plus the duty-factor stability check (-x .02); includes an ini file with a steady-state initial condition. |
Each directory contains the same simulator source and plotting recipe, so the variants differ only in their command-line parameters:
walk.cc— C++ simulator (rigid-body quadruped + four-limb sensory/central controller).walk— pre-built binary (Linux x86-64; rebuild from source for other platforms).do— bash script that compileswalk.ccand sweeps forward velocity from 1 to 40 cm/s in 0.1 cm/s steps, running all points in parallel.data/— per-velocity output files written by the sweep (dur1,dur1.1, …).map.plot— gnuplot script that aggregatesdata/*into a swing-duration × velocity map coloured by duty factor.map.png— pre-rendered figure produced bymap.plot.ini(model 3 only) — initial state used whenwalkis launched with-i.readme— original short run instructions.
Requirements
- Linux (or macOS with minor changes to
do) - bash,
bc, GNU coreutils - Intel oneAPI C++ compiler (
icpx) — replace withg++ -O3 -march=native walk.cc -o walkif you do not haveicpx - gnuplot (with
pngcairoterminal)
Running
Unzip code.zip and cd into any of the three model directories:
unzip code.zip
cd code/model1 # or model2, model3
chmod +x do
./do # compiles walk.cc, clears data/, runs the velocity sweep in parallel
gnuplot map.plot # renders map.png from data/*
The sweep launches one background walk process per velocity point (≈ 391 jobs); each is short. Expect noticeable load — adjust the seq step in do if needed.
Simulator (walk.cc)
A four-limb planar mouse with centre-of-mass dynamics, body rotation, per-leg ground-reaction forces, and a sensory/central controller that decides when each leg switches between stance and swing.
Key constants (top of walk.cc):
g = 1000cm/s² — gravityH = 3cm — COM heightL = 5cm — half body lengthh = 1cm — half body widthtau = 0.25s — momentum time constantF0 = 10cm/s — propulsive force (per leg, scaled by mass)
Command-line flags (see walk.cc argv parsing for the authoritative list):
| Flag | Meaning |
|---|---|
-T <s> |
total simulated time |
-dt <n> |
output decimation (samples per output) |
-v <F1> <F2> |
propulsive force, ramped from F1 to F2 over the run |
-u <Gu1> <Gu2> |
unloading-feedback threshold, ramped |
-w <Gv1> <Gv2> <Gw> |
central-interaction weights (diagonal / non-diagonal / mode switch) |
-s <T1> <T2> |
maximum stance duration, ramped |
-ts <τ> |
swing time constant |
-x <dft> |
duty-factor stability cutoff (model 3) |
-i |
load initial state from ini |
-o <file> |
output filename |
Output columns (per row): t x y h vx vy θ v_heading G1..G4 swing_flags…. Transitions are also logged to the per-leg duty-factor record consumed by map.plot.
Output
Running any of the three sweeps produces a map.png showing the achievable swing-duration × velocity region, coloured by stance/swing duty factor — the figure-style summary used in the paper to compare regimes across the three model variants.
Citation
If you use this code, please cite the paper above.
Sources:
