wormbench 1.0.1__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.
Files changed (47) hide show
  1. wormbench-1.0.1/.gitignore +54 -0
  2. wormbench-1.0.1/CITATION.cff +44 -0
  3. wormbench-1.0.1/LICENSE +201 -0
  4. wormbench-1.0.1/NOTICE +20 -0
  5. wormbench-1.0.1/PKG-INFO +168 -0
  6. wormbench-1.0.1/README.md +140 -0
  7. wormbench-1.0.1/pyproject.toml +58 -0
  8. wormbench-1.0.1/tests/wormbench_tests/__init__.py +0 -0
  9. wormbench-1.0.1/tests/wormbench_tests/conftest.py +34 -0
  10. wormbench-1.0.1/tests/wormbench_tests/test_cli.py +428 -0
  11. wormbench-1.0.1/tests/wormbench_tests/test_data.py +154 -0
  12. wormbench-1.0.1/tests/wormbench_tests/test_simulated_import.py +173 -0
  13. wormbench-1.0.1/tests/wormbench_tests/test_track_export.py +429 -0
  14. wormbench-1.0.1/wormbench/__init__.py +13 -0
  15. wormbench-1.0.1/wormbench/_data/benchmark/PROVENANCE.md +322 -0
  16. wormbench-1.0.1/wormbench/_data/benchmark/bands.json +356 -0
  17. wormbench-1.0.1/wormbench/_data/benchmark/bands_v2.json +5946 -0
  18. wormbench-1.0.1/wormbench/_data/benchmark/bands_v3.json +5977 -0
  19. wormbench-1.0.1/wormbench/_data/benchmark/bands_v4.json +6038 -0
  20. wormbench-1.0.1/wormbench/_data/benchmark/classifier.json +113 -0
  21. wormbench-1.0.1/wormbench/_data/benchmark/lopezcruz2019_reference.json +105 -0
  22. wormbench-1.0.1/wormbench/_data/benchmark/lopezcruz2019_split.json +44 -0
  23. wormbench-1.0.1/wormbench/_data/benchmark/scheer_tracker_noise.npz +0 -0
  24. wormbench-1.0.1/wormbench/_data/example/example.zip +0 -0
  25. wormbench-1.0.1/wormbench/_data/example/expected_v4.json +129 -0
  26. wormbench-1.0.1/wormbench/_data/kappa_v1.json +11 -0
  27. wormbench-1.0.1/wormbench/_data/manifest.json +94 -0
  28. wormbench-1.0.1/wormbench/_data/roaming_dwelling/PROVENANCE.md +156 -0
  29. wormbench-1.0.1/wormbench/_data/roaming_dwelling/calibration_retry.json +65 -0
  30. wormbench-1.0.1/wormbench/_data/roaming_dwelling/reference_hmm.json +36 -0
  31. wormbench-1.0.1/wormbench/_data/urls.json +11 -0
  32. wormbench-1.0.1/wormbench/_data/validity.json +20 -0
  33. wormbench-1.0.1/wormbench/bands.py +195 -0
  34. wormbench-1.0.1/wormbench/builder.py +339 -0
  35. wormbench-1.0.1/wormbench/chemotaxis.py +261 -0
  36. wormbench-1.0.1/wormbench/classifier.py +433 -0
  37. wormbench-1.0.1/wormbench/cli.py +280 -0
  38. wormbench-1.0.1/wormbench/data.py +208 -0
  39. wormbench-1.0.1/wormbench/grade.py +577 -0
  40. wormbench-1.0.1/wormbench/grading.py +858 -0
  41. wormbench-1.0.1/wormbench/measurement.py +316 -0
  42. wormbench-1.0.1/wormbench/odour_field.py +103 -0
  43. wormbench-1.0.1/wormbench/readouts.py +280 -0
  44. wormbench-1.0.1/wormbench/records.py +74 -0
  45. wormbench-1.0.1/wormbench/references.py +303 -0
  46. wormbench-1.0.1/wormbench/track_export.py +327 -0
  47. wormbench-1.0.1/wormbench/track_import.py +576 -0
@@ -0,0 +1,54 @@
1
+ .DS_Store
2
+ *.pyc
3
+ __pycache__/
4
+ *.egg-info/
5
+ *.egg
6
+ *.log
7
+ *.code-workspace
8
+ .vscode/
9
+ tmp/*
10
+ temp/*
11
+ build/*
12
+ builds/*
13
+ log/*
14
+ logs/*
15
+ exports/*
16
+ plots/*
17
+
18
+ # Experiment tracking (auto-tracked experiments are gitignored)
19
+ experiments/*
20
+
21
+ # Evolution results
22
+ evolution_results/*
23
+
24
+ # Campaign runs (scripts/run_campaign.py default output root)
25
+ campaigns/*
26
+
27
+ # Bench harness scratch (scripts/benchmarks/bench_evolution_smoke.py output)
28
+ .bench_evolution_tmp/
29
+
30
+ # Configuration files
31
+ configs/*.yml
32
+ !configs/scenarios/**/*.yml
33
+ !configs/evolution/*.yml
34
+ !configs/special/*.yml
35
+
36
+ # Environment files
37
+ .env
38
+ .env.local
39
+ !.env.template
40
+ !.env.example
41
+
42
+ # Coverage files
43
+ .coverage
44
+ .coverage.*
45
+ coverage.xml
46
+ htmlcov/
47
+ .pytest_cache/
48
+
49
+ # Claude
50
+ .claude/
51
+ CLAUDE.md
52
+
53
+ # sbi training logs (TensorBoard), written to the working directory
54
+ sbi-logs/
@@ -0,0 +1,44 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use wormbench, please cite it as below, and cite the real-worm data it grades against (see the README)."
3
+ type: software
4
+ title: "wormbench: grading simulated and real C. elegans tracks against real-worm behaviour"
5
+ authors:
6
+ - family-names: Zaharia
7
+ given-names: Chris Julian
8
+ orcid: "https://orcid.org/0009-0005-6849-8081"
9
+ repository-code: "https://github.com/SyntheticBrains/nematode"
10
+ url: "https://github.com/SyntheticBrains/nematode/tree/main/packages/wormbench"
11
+ license: Apache-2.0
12
+ version: 1.0.1
13
+ date-released: "2026-11-28"
14
+ keywords:
15
+ - C. elegans
16
+ - behaviour
17
+ - benchmark
18
+ - foraging
19
+ - roaming and dwelling
20
+ - local search
21
+ - chemotaxis
22
+ abstract: >-
23
+ A grader for simulated or real C. elegans tracks on standard assays: Scheer and
24
+ Bargmann's small lawn and uniform well, the kinematics and activity of worms on a
25
+ lawn, López-Cruz et al.'s local search after food removal, and Chen et al.'s
26
+ butanone chemotaxis. Each statistic is graded against bands built from the spread
27
+ between real recording dates, at the population's own size.
28
+ references:
29
+ - type: data
30
+ title: "Real-worm reference data for wormbench, version 1"
31
+ authors:
32
+ - family-names: Zaharia
33
+ given-names: Chris Julian
34
+ orcid: "https://orcid.org/0009-0005-6849-8081"
35
+ doi: 10.5281/zenodo.24585652
36
+ version: "1"
37
+ date-published: "2026-11-27"
38
+ publisher:
39
+ name: Zenodo
40
+ notes: >-
41
+ Each file keeps the licence of the deposit it is derived from: CC0-1.0 for the
42
+ files from Scheer and Bargmann 2023, Calhoun et al. 2014 and Roberts et al. 2016,
43
+ and CC BY 4.0, which requires attribution, for the files from López-Cruz et al.
44
+ 2019 and Chen et al. 2025. The deposit's README lists each file's licence.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Chris Julian Zaharia
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
wormbench-1.0.1/NOTICE ADDED
@@ -0,0 +1,20 @@
1
+ wormbench
2
+ =========
3
+
4
+ The code is licensed under the Apache License, Version 2.0 (LICENSE).
5
+
6
+ The reference data shipped with the package, or fetched by `wormbench data fetch`, are derived from
7
+ public deposits and keep their deposits' licences. Each file's source, licence and derivation are in
8
+ its namespace's PROVENANCE.md.
9
+
10
+ - Scheer, E. & Bargmann, C. I. (2023). Sensory neurons couple arousal and foraging decisions in
11
+ Caenorhabditis elegans. eLife 12:RP88657. Dryad doi:10.5061/dryad.47d7wm3jf. CC0-1.0.
12
+ - Calhoun, A. J., et al. (2014). Maximally informative foraging by Caenorhabditis elegans. eLife
13
+ 3:e04220. Dryad doi:10.5061/dryad.3j2j9. CC0-1.0.
14
+ - Roberts, W. M., et al. (2016). A stochastic neuronal model predicts random search behaviors at
15
+ multiple spatial scales in C. elegans. eLife 5:e12572. Dryad doi:10.5061/dryad.35qv6. CC0-1.0.
16
+ - López-Cruz, A., et al. (2019). Parallel multimodal circuits control an innate foraging behavior.
17
+ Neuron 102:407-419. Mendeley Data doi:10.17632/prdtw5jgcd.1. CC BY 4.0.
18
+ - Chen, K. S., et al. (2025). Navigation strategies in Caenorhabditis elegans are differentially
19
+ altered by learning. PLoS Biology, doi:10.1371/journal.pbio.3003005. figshare
20
+ doi:10.6084/m9.figshare.24764403. CC BY 4.0.
@@ -0,0 +1,168 @@
1
+ Metadata-Version: 2.5
2
+ Name: wormbench
3
+ Version: 1.0.1
4
+ Summary: Grade simulated or real C. elegans tracks against real-worm behaviour
5
+ Project-URL: Homepage, https://github.com/SyntheticBrains/nematode/tree/main/packages/wormbench
6
+ Project-URL: Repository, https://github.com/SyntheticBrains/nematode
7
+ Project-URL: Issues, https://github.com/SyntheticBrains/nematode/issues
8
+ Project-URL: Data, https://doi.org/10.5281/zenodo.24585652
9
+ Author: Chris Julian Zaharia
10
+ Maintainer: Chris Julian Zaharia
11
+ License-Expression: Apache-2.0 AND CC0-1.0 AND CC-BY-4.0
12
+ License-File: LICENSE
13
+ License-File: NOTICE
14
+ Keywords: behaviour,benchmark,c-elegans,chemotaxis,foraging,nematode,simulation
15
+ Classifier: Development Status :: 5 - Production/Stable
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
24
+ Requires-Python: >=3.10
25
+ Requires-Dist: numpy>=1.24
26
+ Requires-Dist: scipy>=1.10
27
+ Description-Content-Type: text/markdown
28
+
29
+ # wormbench
30
+
31
+ Grade simulated or real *Caenorhabditis elegans* tracks against real-worm behaviour.
32
+
33
+ `wormbench` reads 1-s positions and grades a population on standard assays:
34
+
35
+ - **Scheer & Bargmann's small lawn:** roaming fraction, roaming and dwelling bout lengths, lawn
36
+ exits per on-lawn hour, roaming enrichment before an exit, and time on the lawn;
37
+ - **Scheer & Bargmann's uniform well:** roaming fraction and both bout lengths;
38
+ - **kinematics on the lawn:** 10-s window speeds while dwelling and roaming, and roaming-bout
39
+ survival;
40
+ - **activity on the lawn:** the pause share, the direction-flip fraction and the reversal-onset rate;
41
+ - **López-Cruz et al.'s local search** after food removal: its decay rate and early/late ratio.
42
+
43
+ Each statistic is graded against a band built from the spread between real recording dates, at the
44
+ population's own size. A population passes a statistic when its z lies within the benchmark's
45
+ Bonferroni bar, and it passes the wild type when every family passes. Two distances summarise the
46
+ grading: D over every family and D_fit over the families a fit reads. A mutant is graded on its
47
+ difference from its own wild type.
48
+
49
+ It depends on numpy and scipy only, on Python 3.10 or later.
50
+
51
+ ## Install
52
+
53
+ ```bash
54
+ pip install wormbench
55
+ ```
56
+
57
+ ## A first grading
58
+
59
+ The package ships 64 real wild-type animals on the small lawn, so a grading runs with no download:
60
+
61
+ ```bash
62
+ wormbench example --out example
63
+ wormbench grade --manifest example/manifest.txt --out example/grade.json
64
+ ```
65
+
66
+ These animals come from the recording dates the bands are built from, so the example shows how the
67
+ grader reads tracks and validates nothing.
68
+
69
+ ## Your own tracks
70
+
71
+ A manifest lists one file per line, as `<family> <file>`, with `family` one of `small_lawn`,
72
+ `uniform_lawn` or `local_search`. Each animal in a file is one member of its family's population.
73
+ Relative files are read against the manifest's directory.
74
+
75
+ **CSV**, with a sidecar `<file>.json`:
76
+
77
+ - columns `animal`, `t_s`, `x`, `y`, and an optional `on_lawn` (0 or 1);
78
+ - the sidecar names the `family`, the `analysis_start_s` at which the family's window begins, the
79
+ `units` (`mm`, `um`, or in a CSV pixels with `mm_per_px`) and the `lawn`. A lawn is
80
+ `{"centre": [x, y], "radius": r}`, `{"centre": [x, y], "radii": [...]}` at equally spaced angles
81
+ from +x, or `"uniform"`.
82
+
83
+ **WCON 1.0**: its core (`units`, `data`), with the same metadata in a top-level
84
+ `@nematode_benchmark` object. Records sharing an `id` are merged in time order. A skeleton is reduced
85
+ to its middle point, and `null` is a missing sample.
86
+
87
+ Each track is resampled to 1 s and cut to its family's window: the small lawn's and the uniform
88
+ well's last 40 minutes, and local search's 45 minutes from food removal.
89
+
90
+ ### Writing WCON
91
+
92
+ `wormbench wcon` writes a CSV's tracks, with its sidecar, as one WCON 1.0 file in mm and s. It then
93
+ reads the file back, and writes the output only if every sample and the metadata are unchanged, so
94
+ the WCON file grades as the CSV does:
95
+
96
+ ```bash
97
+ wormbench wcon --tracks tracks.csv --out tracks.wcon [--simulated]
98
+ ```
99
+
100
+ `--simulated` carries each animal's primitive labels and seed as `@primitive` and `@seed`. WCON's
101
+ core has no on-lawn flag, so a lawn family's file whose membership comes from an `on_lawn` column is
102
+ refused: drop the column and give the lawn's boundary, or `"uniform"`, in the sidecar instead. From Python,
103
+ `wormbench.track_export.write_wcon` and `write_csv` write a list of tracks as
104
+ `wormbench.track_import` reads them.
105
+
106
+ ### Simulated tracks
107
+
108
+ A real tracker loses and blurs a worm's position; a simulator does not. To grade a simulated worm the
109
+ way the benchmark grades its own, pass `--simulated`. Each animal on Scheer's rig is then measured
110
+ first: tracker noise resampled from real paused worms, and lost seconds.
111
+
112
+ ```bash
113
+ wormbench grade --manifest sim.txt --out sim.json --simulated
114
+ ```
115
+
116
+ That needs each second's primitive (`run`, `reversal`, `omega` or `delta`) and one integer seed per
117
+ animal: `primitive` and `seed` CSV columns, or a WCON record's `@primitive` (one per time) and
118
+ `@seed`. A simulated track must be sampled every second. A seed used twice is refused, since two
119
+ animals would draw the same noise. Local search is never measured.
120
+
121
+ ### What is not graded for imported tracks
122
+
123
+ Chemotaxis is graded on Chen et al.'s measured butanone field, which an imported track does not
124
+ carry, so an imported population is graded on the other families, and its D is undefined.
125
+
126
+ ## Versions
127
+
128
+ `--bands v1|v2|v3|v4` picks the benchmark's version. Every 1.x release grades on v4 by default;
129
+ only a major release changes the default. v1 to v3 are frozen, so a past grading can be reproduced.
130
+ Every grading records the package version, the bands version and the bands' SHA-256.
131
+
132
+ ## Data
133
+
134
+ The bands, the classifier, the tracker-noise library and the local-search reference ship inside the
135
+ package. Grading at a population size with no vendored bands (anything but 64 or 200 animals)
136
+ rebuilds the bands from the real tracks, which are fetched once:
137
+
138
+ ```bash
139
+ wormbench data fetch
140
+ wormbench data verify
141
+ ```
142
+
143
+ The tracks are deposited on Zenodo as the package's reference data, version 1
144
+ ([doi:10.5281/zenodo.24585652](https://doi.org/10.5281/zenodo.24585652), about 37 MB). `wormbench data fetch`
145
+ downloads them from that record, resuming a transfer the server cuts short, and checks each file
146
+ against its SHA-256. `WORMBENCH_DATA` can instead point at a directory holding the files, laid out
147
+ as `benchmark/<file>`. The example in *A first grading* needs no download.
148
+
149
+ Nothing is downloaded otherwise. Every file read from `WORMBENCH_DATA`, the package or the fetched
150
+ cache is checked against the SHA-256 the package records. A program that sets its own data root
151
+ (as the project this package comes from does for its repository's `data/`) has those files read as
152
+ given. `wormbench info` shows where each file is read from.
153
+
154
+ ## Citation
155
+
156
+ Cite the package (see `CITATION.cff`) and the data it grades against:
157
+
158
+ - Scheer, E. & Bargmann, C. I. (2023). *eLife* 12:RP88657. Dryad doi:10.5061/dryad.47d7wm3jf.
159
+ - López-Cruz, A., et al. (2019). *Neuron* 102:407–419. Mendeley Data doi:10.17632/prdtw5jgcd.1.
160
+ - Chen, K. S., et al. (2025). *PLoS Biology*, doi:10.1371/journal.pbio.3003005.
161
+ - Calhoun, A. J., et al. (2014). *eLife* 3:e04220; Roberts, W. M., et al. (2016). *eLife* 5:e12572.
162
+ - The derived files as this package fetches them: Zaharia, C. J. (2026). *Real-worm reference data
163
+ for wormbench, version 1*. Zenodo. doi:10.5281/zenodo.24585652.
164
+
165
+ ## Licence
166
+
167
+ The code is licensed under Apache-2.0. The reference data keep their deposits' licences, CC0-1.0
168
+ and CC BY 4.0; see `NOTICE` and each data namespace's `PROVENANCE.md`.
@@ -0,0 +1,140 @@
1
+ # wormbench
2
+
3
+ Grade simulated or real *Caenorhabditis elegans* tracks against real-worm behaviour.
4
+
5
+ `wormbench` reads 1-s positions and grades a population on standard assays:
6
+
7
+ - **Scheer & Bargmann's small lawn:** roaming fraction, roaming and dwelling bout lengths, lawn
8
+ exits per on-lawn hour, roaming enrichment before an exit, and time on the lawn;
9
+ - **Scheer & Bargmann's uniform well:** roaming fraction and both bout lengths;
10
+ - **kinematics on the lawn:** 10-s window speeds while dwelling and roaming, and roaming-bout
11
+ survival;
12
+ - **activity on the lawn:** the pause share, the direction-flip fraction and the reversal-onset rate;
13
+ - **López-Cruz et al.'s local search** after food removal: its decay rate and early/late ratio.
14
+
15
+ Each statistic is graded against a band built from the spread between real recording dates, at the
16
+ population's own size. A population passes a statistic when its z lies within the benchmark's
17
+ Bonferroni bar, and it passes the wild type when every family passes. Two distances summarise the
18
+ grading: D over every family and D_fit over the families a fit reads. A mutant is graded on its
19
+ difference from its own wild type.
20
+
21
+ It depends on numpy and scipy only, on Python 3.10 or later.
22
+
23
+ ## Install
24
+
25
+ ```bash
26
+ pip install wormbench
27
+ ```
28
+
29
+ ## A first grading
30
+
31
+ The package ships 64 real wild-type animals on the small lawn, so a grading runs with no download:
32
+
33
+ ```bash
34
+ wormbench example --out example
35
+ wormbench grade --manifest example/manifest.txt --out example/grade.json
36
+ ```
37
+
38
+ These animals come from the recording dates the bands are built from, so the example shows how the
39
+ grader reads tracks and validates nothing.
40
+
41
+ ## Your own tracks
42
+
43
+ A manifest lists one file per line, as `<family> <file>`, with `family` one of `small_lawn`,
44
+ `uniform_lawn` or `local_search`. Each animal in a file is one member of its family's population.
45
+ Relative files are read against the manifest's directory.
46
+
47
+ **CSV**, with a sidecar `<file>.json`:
48
+
49
+ - columns `animal`, `t_s`, `x`, `y`, and an optional `on_lawn` (0 or 1);
50
+ - the sidecar names the `family`, the `analysis_start_s` at which the family's window begins, the
51
+ `units` (`mm`, `um`, or in a CSV pixels with `mm_per_px`) and the `lawn`. A lawn is
52
+ `{"centre": [x, y], "radius": r}`, `{"centre": [x, y], "radii": [...]}` at equally spaced angles
53
+ from +x, or `"uniform"`.
54
+
55
+ **WCON 1.0**: its core (`units`, `data`), with the same metadata in a top-level
56
+ `@nematode_benchmark` object. Records sharing an `id` are merged in time order. A skeleton is reduced
57
+ to its middle point, and `null` is a missing sample.
58
+
59
+ Each track is resampled to 1 s and cut to its family's window: the small lawn's and the uniform
60
+ well's last 40 minutes, and local search's 45 minutes from food removal.
61
+
62
+ ### Writing WCON
63
+
64
+ `wormbench wcon` writes a CSV's tracks, with its sidecar, as one WCON 1.0 file in mm and s. It then
65
+ reads the file back, and writes the output only if every sample and the metadata are unchanged, so
66
+ the WCON file grades as the CSV does:
67
+
68
+ ```bash
69
+ wormbench wcon --tracks tracks.csv --out tracks.wcon [--simulated]
70
+ ```
71
+
72
+ `--simulated` carries each animal's primitive labels and seed as `@primitive` and `@seed`. WCON's
73
+ core has no on-lawn flag, so a lawn family's file whose membership comes from an `on_lawn` column is
74
+ refused: drop the column and give the lawn's boundary, or `"uniform"`, in the sidecar instead. From Python,
75
+ `wormbench.track_export.write_wcon` and `write_csv` write a list of tracks as
76
+ `wormbench.track_import` reads them.
77
+
78
+ ### Simulated tracks
79
+
80
+ A real tracker loses and blurs a worm's position; a simulator does not. To grade a simulated worm the
81
+ way the benchmark grades its own, pass `--simulated`. Each animal on Scheer's rig is then measured
82
+ first: tracker noise resampled from real paused worms, and lost seconds.
83
+
84
+ ```bash
85
+ wormbench grade --manifest sim.txt --out sim.json --simulated
86
+ ```
87
+
88
+ That needs each second's primitive (`run`, `reversal`, `omega` or `delta`) and one integer seed per
89
+ animal: `primitive` and `seed` CSV columns, or a WCON record's `@primitive` (one per time) and
90
+ `@seed`. A simulated track must be sampled every second. A seed used twice is refused, since two
91
+ animals would draw the same noise. Local search is never measured.
92
+
93
+ ### What is not graded for imported tracks
94
+
95
+ Chemotaxis is graded on Chen et al.'s measured butanone field, which an imported track does not
96
+ carry, so an imported population is graded on the other families, and its D is undefined.
97
+
98
+ ## Versions
99
+
100
+ `--bands v1|v2|v3|v4` picks the benchmark's version. Every 1.x release grades on v4 by default;
101
+ only a major release changes the default. v1 to v3 are frozen, so a past grading can be reproduced.
102
+ Every grading records the package version, the bands version and the bands' SHA-256.
103
+
104
+ ## Data
105
+
106
+ The bands, the classifier, the tracker-noise library and the local-search reference ship inside the
107
+ package. Grading at a population size with no vendored bands (anything but 64 or 200 animals)
108
+ rebuilds the bands from the real tracks, which are fetched once:
109
+
110
+ ```bash
111
+ wormbench data fetch
112
+ wormbench data verify
113
+ ```
114
+
115
+ The tracks are deposited on Zenodo as the package's reference data, version 1
116
+ ([doi:10.5281/zenodo.24585652](https://doi.org/10.5281/zenodo.24585652), about 37 MB). `wormbench data fetch`
117
+ downloads them from that record, resuming a transfer the server cuts short, and checks each file
118
+ against its SHA-256. `WORMBENCH_DATA` can instead point at a directory holding the files, laid out
119
+ as `benchmark/<file>`. The example in *A first grading* needs no download.
120
+
121
+ Nothing is downloaded otherwise. Every file read from `WORMBENCH_DATA`, the package or the fetched
122
+ cache is checked against the SHA-256 the package records. A program that sets its own data root
123
+ (as the project this package comes from does for its repository's `data/`) has those files read as
124
+ given. `wormbench info` shows where each file is read from.
125
+
126
+ ## Citation
127
+
128
+ Cite the package (see `CITATION.cff`) and the data it grades against:
129
+
130
+ - Scheer, E. & Bargmann, C. I. (2023). *eLife* 12:RP88657. Dryad doi:10.5061/dryad.47d7wm3jf.
131
+ - López-Cruz, A., et al. (2019). *Neuron* 102:407–419. Mendeley Data doi:10.17632/prdtw5jgcd.1.
132
+ - Chen, K. S., et al. (2025). *PLoS Biology*, doi:10.1371/journal.pbio.3003005.
133
+ - Calhoun, A. J., et al. (2014). *eLife* 3:e04220; Roberts, W. M., et al. (2016). *eLife* 5:e12572.
134
+ - The derived files as this package fetches them: Zaharia, C. J. (2026). *Real-worm reference data
135
+ for wormbench, version 1*. Zenodo. doi:10.5281/zenodo.24585652.
136
+
137
+ ## Licence
138
+
139
+ The code is licensed under Apache-2.0. The reference data keep their deposits' licences, CC0-1.0
140
+ and CC BY 4.0; see `NOTICE` and each data namespace's `PROVENANCE.md`.