ayna 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ayna-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
ayna-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,322 @@
1
+ Metadata-Version: 2.4
2
+ Name: ayna
3
+ Version: 0.1.0
4
+ Summary: Know whether your inferred neural dynamics are real, before you interpret them. Diagnoses underfitting, feature invention and dynamical misattribution in data-driven dynamics models.
5
+ Author: Aslan Satary Dizaji
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/aslansd/ayna
8
+ Project-URL: Repository, https://github.com/aslansd/ayna
9
+ Project-URL: Issues, https://github.com/aslansd/ayna/issues
10
+ Keywords: neuroscience,neural-dynamics,lfads,dynamical-systems,model-validation,computation-through-dynamics,latent-variable-models
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
15
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: numpy>=1.24
20
+ Requires-Dist: scipy>=1.10
21
+ Requires-Dist: scikit-learn>=1.3
22
+ Provides-Extra: plot
23
+ Requires-Dist: matplotlib>=3.7; extra == "plot"
24
+ Provides-Extra: provenance
25
+ Requires-Dist: daftar>=1.0; extra == "provenance"
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=8; extra == "dev"
28
+ Requires-Dist: matplotlib>=3.7; extra == "dev"
29
+ Provides-Extra: all
30
+ Requires-Dist: matplotlib>=3.7; extra == "all"
31
+ Requires-Dist: daftar>=1.0; extra == "all"
32
+ Dynamic: license-file
33
+
34
+ # ayna
35
+
36
+ **آینه / ayna** — *mirror.* Persian *āyeneh*; *ayna* in Turkish and Azerbaijani.
37
+
38
+ **Know whether your inferred dynamics are real, before you interpret them.**
39
+
40
+ ayna reads the outputs of a fitted data-driven dynamics model (LFADS, a
41
+ sequential autoencoder, a neural ODE, anything that turns spikes into latents
42
+ and rates) and reports *which failure mode it has, and where*. It does not
43
+ train anything. It runs on a CPU in seconds.
44
+
45
+ ```bash
46
+ pip install ayna
47
+ ```
48
+
49
+ Python 3.10+. Apache 2.0. Three dependencies: numpy, scipy, scikit-learn. No
50
+ torch, no GPU, no downloads.
51
+
52
+ ---
53
+
54
+ ## The failure that matters
55
+
56
+ A model can reconstruct held-out neurons almost perfectly and still give you
57
+ the wrong dynamics. The Computation-through-Dynamics Toolkit (CtD; Versteeg et
58
+ al., *PLOS Comput Biol* 2026) names three ways this happens:
59
+
60
+ - **Underfitting** — the model misses latent structure that is really there.
61
+ - **Feature invention** — the model adds latent structure that is not there.
62
+ Because the readout ignores it, it costs nothing in reconstruction. In CtD's
63
+ 3BFF sweep, the models that invent features *win* on co-BPS.
64
+ - **Dynamical misattribution** — the inferred inputs do the work the dynamics
65
+ should do. Latents and rates can both look right. Only the inputs, and the
66
+ dynamics left behind, are wrong.
67
+
68
+ CtD measures all three when ground truth is known: State R², Rate R² and
69
+ Input R². On a real recording there is no ground truth, and reconstruction
70
+ alone points the wrong way. ayna is the checklist for that situation. It runs
71
+ every check the outputs allow, says which ones it could not run, and gets
72
+ sharper when you give it more.
73
+
74
+ ### Where this sits
75
+
76
+ - **CtD** is the research platform. It has the datasets, the training
77
+ pipelines and the ground-truth metrics, and it needs torch, Lightning, Ray,
78
+ Hydra and several GB of pretrained models.
79
+ - **The Neural Latents Benchmark** scores reconstruction on real recordings.
80
+ - **ayna** is the step after training, on your own data. It ports CtD's
81
+ metrics to numpy, adds probes that need no ground truth, turns both into
82
+ named findings, and validates its own detectors wherever ground truth exists.
83
+
84
+ ---
85
+
86
+ ## Quickstart
87
+
88
+ ```bash
89
+ # 1. A model output with known, deliberately injected faults
90
+ ayna synth field --faults feature_invention misattribution=0.8
91
+
92
+ # 2. Diagnose it -- no ground truth used for the verdicts
93
+ ayna scan datasets/field.npz --out reports/field
94
+
95
+ # 3. A latent-size sweep: is the best co-BPS model the one to trust?
96
+ ayna synth sweep --sweep
97
+ ayna select datasets/sweep --out reports/sweep --plot
98
+
99
+ # 4. How often are the detectors right? (compares against ground truth)
100
+ ayna validate
101
+ ```
102
+
103
+ From Python:
104
+
105
+ ```python
106
+ from ayna import load_bundle, scan
107
+
108
+ report = scan(load_bundle("run.npz"))
109
+ for f in report["findings"]:
110
+ if f["tier"] < 2: # tier 2 = ground-truth confirmations
111
+ print(f["severity"], f["id"], f["where"])
112
+ print(" ", f["what"])
113
+ ```
114
+
115
+ What a scan says (abridged):
116
+
117
+ ```
118
+ WARNING (experimental) DYNAMICAL_MISATTRIBUTION [tier 0: outputs only]
119
+ the latent state at the same instant predicts the inferred inputs (R² 0.86) ...
120
+ WARNING FEATURE_INVENTION [tier 0: outputs only]
121
+ where: latent PCs 4, 5 (30% of latent variance)
122
+ Linear cycle-consistency is 0.71: part of the inferred latent activity cannot
123
+ be regenerated from the model's own predicted rates ...
124
+ ground truth says
125
+ DYNAMICAL_MISATTRIBUTION confirmed: Input R² 0.087 (flag if < 0.5)
126
+ FEATURE_INVENTION confirmed: State R² 0.707 (flag if < 0.9)
127
+ not assessed (a check that did not run is not a clean result)
128
+ DYNAMICAL_MISATTRIBUTION tier 1: no dynamics callable attached
129
+ ```
130
+
131
+ `scan` exits with status 1 when a finding from the model's outputs is an
132
+ error, so it can gate a pipeline.
133
+
134
+ ---
135
+
136
+ ## Three tiers of evidence
137
+
138
+ | Tier | You provide | Unlocks |
139
+ |---|---|---|
140
+ | **0** | spikes, predicted rates, latents (+ held-out neurons, + inferred or supplied inputs) | everything below marked tier 0 |
141
+ | **1** | a dynamics callable `f(z, u) -> z_next` (Python API) | autonomous-rollout and zero-input fixed-point probes |
142
+ | **2** | true latents / rates / inputs (synthetic data only) | CtD's Rate R², State R², Input R², and `ayna validate` |
143
+
144
+ Every finding records the tier it came from. A real recording gets tier 0, or
145
+ tier 1 if you attach the dynamics. Tier 2 exists so the tier-0 and tier-1
146
+ verdicts can be checked.
147
+
148
+ ## The detectors
149
+
150
+ | Finding | Question it answers | Tier |
151
+ |---|---|---|
152
+ | `UNDERFITTING` | Do the validation residuals share slow structure beyond chance? Does co-BPS fail to beat a smoothed-spikes Poisson GLM? Reports *when* in the trial and *which* neurons. | 0 |
153
+ | `FEATURE_INVENTION` | Can the latents be regenerated from the model's own rates (cycle-consistency)? Reports *which latent PCs* cannot, and their share of variance. | 0 |
154
+ | `READOUT_NULLSPACE` | Are there latent directions the readout ignores, where invention could hide later? | 0 |
155
+ | `NONLINEAR_READOUT` | Is the latent→log-rate map far from linear? If so, the linear metrics are not trusted and ayna uses a nonlinear cycle-consistency instead. | 0 |
156
+ | `DYNAMICAL_MISATTRIBUTION` *(experimental)* | Do the latents at the same instant predict the inferred inputs (*input leakage*)? With inputs clamped to zero, do the model's own dynamics lose a state that simply holding would keep? | 0 / 1 |
157
+ | `INPUT_INHERITED_STRUCTURE` | With supplied inputs, how much of the latent variance is just a short filter of the inputs (CtD's RandomTarget warning)? | 0 |
158
+ | `RECONSTRUCTION_TRAP` | In a sweep, is the best-co-BPS model off the reconstruction × simplicity Pareto front's knee? (`ayna select`) | 0 |
159
+
160
+ `DYNAMICAL_MISATTRIBUTION` is ayna's own contribution and is labelled
161
+ experimental. CtD lists a ground-truth-free input-accuracy metric as "a major
162
+ focus of future work". The leakage probe tests one idea from CtD Fig 6B:
163
+ badly inferred inputs "resembled the state of the network". In closed-loop
164
+ tasks, true inputs (sensory feedback) can legitimately depend on the state, so
165
+ read that finding with the task in mind.
166
+
167
+ ## Validation
168
+
169
+ `ayna validate` simulates a corpus. Each case is a known system, either a
170
+ 3-bit flip-flop or an input-driven system with no memory, plus simulated model
171
+ outputs with one fault injected at a random severity. Severities run from
172
+ barely there to blatant, and noise and recording size vary too. ayna scans
173
+ each case without ground truth, then compares each verdict with the
174
+ ground-truth verdict on the same bundle.
175
+
176
+ From `ayna validate --n 10 --seed 7` (85 bundles). This corpus was not used
177
+ to set any threshold:
178
+
179
+ | detector | tier | TP | FP | FN | TN | precision | recall |
180
+ |---|---|---|---|---|---|---|---|
181
+ | `FEATURE_INVENTION` | 0 | 14 | 0 | 0 | 71 | 1.00 | 1.00 |
182
+ | `DYNAMICAL_MISATTRIBUTION` | 0 | 5 | 0 | 0 | 30 | 1.00 | 1.00 |
183
+ | `DYNAMICAL_MISATTRIBUTION` | 1 | 5 | 0 | 0 | 30 | 1.00 | 1.00 |
184
+ | `INPUT_INHERITED_STRUCTURE` | 0 | 10 | 0 | 0 | 10 | 1.00 | 1.00 |
185
+ | `NONLINEAR_READOUT` | 0 | 10 | 0 | 0 | 75 | 1.00 | 1.00 |
186
+ | `UNDERFITTING` | 0 | 13 | 2 | 2 | 68 | 0.87 | 0.87 |
187
+
188
+ The `UNDERFITTING` disagreements are informative:
189
+
190
+ - **The two "false positives"** are injected underfits so mild that Rate R²
191
+ stays above the 0.90 truth line. The residual probe still sees the missing
192
+ shared component. On this corpus that is arguably a correct catch, scored as
193
+ wrong by the definition of truth.
194
+ - **The two misses** are clean models on a nonlinear readout, where the
195
+ nonlinearity amplifies rate noise below the truth line without leaving
196
+ shared structure.
197
+
198
+ Where the truth line came from: it was 0.85 in the first run, on seed 42. It
199
+ was raised to 0.90 after that run, because clean models never fall below 0.93
200
+ while injected underfits sat between 0.85 and 0.93. Seed 7 was run only
201
+ afterwards.
202
+
203
+ **Read this as a test that the detectors work as designed, not that they
204
+ transfer.** ayna's own simulator injected these faults, and the same author
205
+ wrote the detectors. The real test is a corpus of *trained* models with ground
206
+ truth. CtD's latent-size and KL-penalty sweeps are the obvious source:
207
+ `ayna export-ctd` writes them as bundles, and `ayna validate DIR` scores the
208
+ detectors on them. That has not been done yet. Until it has, the thresholds
209
+ are calibrated on ayna's synthetic faults only.
210
+
211
+ ---
212
+
213
+ ## The bundle
214
+
215
+ One `.npz` per fitted model. Rates are expected counts **per bin**, in the
216
+ same unit as the spikes.
217
+
218
+ | key | shape | |
219
+ |---|---|---|
220
+ | `spikes` | (R, T, N) | required |
221
+ | `rates` | (R, T, N) | required: predicted, held-in and held-out |
222
+ | `latents` | (R, T, D) | required |
223
+ | `heldout` | (N,) bool | neurons never given to the model (enables co-BPS) |
224
+ | `val` | (R,) bool | validation trials (default: last 20%) |
225
+ | `trial_lens` | (R,) int | for padded trials |
226
+ | `inputs` | (R, T, U) | with `meta["inputs_kind"]` = `supplied` or `inferred` |
227
+ | `true_latents`, `true_rates`, `true_inputs` | | ground truth (tier 2) |
228
+ | `meta` | JSON string | name, model, bin size, anything |
229
+
230
+ ```python
231
+ from ayna import Bundle
232
+ Bundle(spikes=y, rates=r, latents=z, heldout=ho, inputs=u_hat,
233
+ meta={"inputs_kind": "inferred", "name": "lfads_run7"}).save("lfads_run7.npz")
234
+ ```
235
+
236
+ Tier 1 is Python-only, because a callable cannot be stored in a `.npz`:
237
+
238
+ ```python
239
+ report = scan(load_bundle("run.npz", dynamics=lambda z, u: my_model.step(z, u)))
240
+ ```
241
+
242
+ ### From the Computation-through-Dynamics Toolkit
243
+
244
+ Inside the CtD environment:
245
+
246
+ ```bash
247
+ ayna export-ctd content/trained_models/dd/<run>/ run.npz --model-type LFADS \
248
+ --tt content/trained_models/tt/<tt_run>/
249
+ ```
250
+
251
+ The exporter uses only the getters CtD's own `Comparison.compute_metrics`
252
+ uses. It was written against CtD 1.0.2 and tested against stand-in objects,
253
+ **not yet against a live CtD install**, because the pretrained models are Git
254
+ LFS files. Please report any mismatch.
255
+
256
+ ## Provenance
257
+
258
+ ```bash
259
+ pip install "ayna[provenance]"
260
+ ayna scan run.npz --out reports/run --daftar
261
+ ```
262
+
263
+ Each scan becomes a [daftar](https://pypi.org/project/daftar/) run. It records
264
+ the bundle hash, the thresholds, the environment and the headline metrics, so
265
+ `daftar diff` can tell you why two scans disagree.
266
+
267
+ ## Thresholds
268
+
269
+ Every threshold has a name and a default, and every one can be overridden:
270
+
271
+ ```bash
272
+ ayna scan run.npz --set invention_cycle_warning=0.8 leakage_r2=0.6
273
+ ```
274
+
275
+ The defaults come from ayna's synthetic corpus. Absolute values of
276
+ cycle-consistency vary with model class: CtD reports values of 0.3–0.5 for
277
+ well-behaved LFADS models with inferred inputs. Compare models of the same
278
+ class on the same data with `ayna select` before trusting a single scan's
279
+ verdict.
280
+
281
+ ## What ayna does not do
282
+
283
+ - It does not train, fit or tune a model.
284
+ - It cannot prove a model's dynamics are right. It can only rule out specific
285
+ ways they are wrong.
286
+ - It has no DSA or Lyapunov comparison yet. Those need a dynamics callable for
287
+ both the true and the inferred system, and are planned for tier 2.
288
+ - The linear metrics assume CtD's linear-exponential observation model.
289
+ `NONLINEAR_READOUT` tells you when that assumption fails, and a nonlinear
290
+ fallback then runs instead.
291
+
292
+ ## Roadmap
293
+
294
+ - **0.2** — validate on CtD's own sweeps (NODE latent sizes, LFADS KL
295
+ penalty), calibrate the thresholds per model class with leave-one-task-out
296
+ testing, and add a tier-1 dynamics wrapper for CtD models.
297
+ - **0.3** — readers for real recordings (NWB / Neural Latents Benchmark),
298
+ plus multi-seed consistency.
299
+ - **Later** — `ayna design`: how many neurons and trials a recording needs
300
+ before the dynamics become recoverable at all.
301
+
302
+ ## Citation
303
+
304
+ ayna ports metrics and failure-mode definitions from:
305
+
306
+ > Versteeg C, McCart JD, Ostrow M, et al. (2026) Computation-through-Dynamics
307
+ > Toolkit: Simulated datasets and quality metrics for dynamical models of neural
308
+ > activity. *PLOS Comput Biol* 22(10): e1014755.
309
+ > https://doi.org/10.1371/journal.pcbi.1014755
310
+
311
+ If you use ayna, please cite that paper.
312
+
313
+ ## Related
314
+
315
+ Part of a small family of pre-flight tools by the same author:
316
+ [daftar](https://pypi.org/project/daftar/) (provenance),
317
+ [raftaar](https://pypi.org/project/raftaar/) (robot demonstration datasets),
318
+ [miras](https://pypi.org/project/miras/) (identifiability of cultural-evolution
319
+ designs), [tarjuman](https://pypi.org/project/tarjuman/) (NeuroML → Jaxley) and
320
+ [baghban](https://pypi.org/project/baghban/) (Bonsai workflows).
321
+
322
+ Research prototype, alpha. Apache 2.0.