ln-fitting-procedure
Fitting parametric cascade models — LN, GLM with feedback, and the two-arm cascade —
to retinal stimulus–response recordings, in the parameterization used by
CascadeGraph.
CascadeGraph provides the model nodes. This provides the layer it doesn't: a data contract
each recording must satisfy before it is fitted, the staged fitting pipeline, random restarts,
resolution of the parameterization's exact degeneracies, and a diagnostics block so every fit
reports its own verdict. In MATLAB and Python, cross-checked against each other to ~1e-13.
It is packaged as a Claude Code skill (SKILL.md + references/), but the fitters are
ordinary MATLAB and Python and are useful on their own.
Get started
In your Claude Code terminal:
/plugin marketplace add maxwellsdm1867/ln-fitting-procedure
/plugin install ln-fitting-procedure@ln-fitting-procedure
That's the preferred way in. The skill is then available in every project and triggers on its
own — "fit an LN model to this cell", "my fit gives near-zero variance explained",
"recover the temporal filter". Other install routes are under Install.
Why it exists
This model family is sensitive to initial conditions, and no documentation fixes that. What
documentation can do is stop the sensitivity from costing you attention. The parameterization
has about eight conventions and four exact degeneracies, and getting any of them wrong still
produces a plausible-looking fit with a respectable R². So the design principle here is:
the code handles or reports every mechanical failure mode, so your time goes to the fit
and the data.
Concretely, in a benchmark of 27 independent agent runs against synthetic cells with known
ground truth, runs working from prose alone reported R² values of 0.878, 0.785 and
0.861 whose own parameters, rebuilt independently, actually produce 0.171, 0.353
and −2.958. Nothing about those outputs looked wrong. Runs using this pipeline reproduced
their reported parameters exactly, 6/6.
The same principle covers the recording itself, which is why nothing is fitted until it has
declared what it is. Three facts cannot be read off an array of numbers — no file reveals its
own sample rate, a sub-millivolt AC-coupled trace looks exactly like volts, and a transposed
3×60000 is indistinguishable from a genuine 60000×3 — and getting any of them wrong rescales
the time axis or the amplitudes while leaving R² untouched. So the recording declares its
sampling interval, response units and layout in a meta.json, and the loader checks that
declaration against the array rather than trusting it. cascadePreflight answers "can this
be fitted?" in about a second, before the ten-minute job rather than after it.
Install
As a Claude Code plugin (easiest)
This repo is its own plugin marketplace, so it installs in two commands:
/plugin marketplace add maxwellsdm1867/ln-fitting-procedure
/plugin install ln-fitting-procedure@ln-fitting-procedure
That's it — the skill is now available in every project. Update later with
/plugin marketplace update ln-fitting-procedure, and remove with
/plugin uninstall ln-fitting-procedure.
As a plain skill (no plugin system)
Skills are discovered from ~/.claude/skills/ (every project) and
<project>/.claude/skills/ (that project only). The skill payload lives in
skills/ln-fitting-procedure/, so clone the repo somewhere and link that subdirectory:
git clone https://github.com/maxwellsdm1867/ln-fitting-procedure ~/code/ln-fitting-procedure
ln -s ~/code/ln-fitting-procedure/skills/ln-fitting-procedure \
~/.claude/skills/ln-fitting-procedure
Or copy it, if you would rather not have a symlink:
cp -R ~/code/ln-fitting-procedure/skills/ln-fitting-procedure ~/.claude/skills/
Either way the directory name must stay ln-fitting-procedure — that is the skill name.
Then
Start a new Claude Code session and it should appear in the available-skills list. It
triggers on its own when you are doing this kind of work — "fit an LN model to this cell",
"my fit gives near-zero variance explained", "recover the temporal filter", "the filter
looks wrong", "port this from the MATLAB CascadeGraph code". You do not have to name it.
Wherever it lands, <skill> in the instructions means that directory, so
<skill>/scripts/matlab is ~/.claude/skills/ln-fitting-procedure/scripts/matlab.
Without Claude Code
Nothing here needs it. SKILL.md and references/ are plain markdown and the fitters are
ordinary MATLAB and Python — clone the repo and use the two entry points below.
Check it works before pointing it at real data