Skip to content

Commit 71a8e8c

Browse files
authored
Merge pull request #132 from mbel-tech/fatina-del-codice/loving-heisenberg-udq8my
Calibration: session scale per tracker, not idtracker.ai only
2 parents 5df8162 + 695c3f6 commit 71a8e8c

33 files changed

Lines changed: 916 additions & 69 deletions

‎CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- **Session calibration works beyond idtracker.ai.** The Calibration screen describes the mode per tracker, with an ⓘ note linking to each tracker's documentation, and disables it when no session can supply a scale. DeepLabCut, SLEAP and Ctrax raw files take an optional **Scale (pixels per cm)** import option.
13+
- **`trx.mat` reader (Ctrax / FlyTracker / JAABA).** Built from the documented layout, unverified against a real sample. `pxpermm` becomes the session scale.
14+
- **Average or median of several idtracker.ai length calibrations.** The average (idtracker.ai's own `length_unit`) stays the default.
15+
- **Wiki and guide:** the user guide, Before You Record, Glossary, Compatibility, Known Issues and Formats pages describe the per-tracker scale and the readers that exist today.
16+
1017
### Fixed
1118

1219
- **The test run no longer crashes at exit, and runs about three times faster.** After every test had passed, the Qt

‎docs/INTEROPERABILITY.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ ds = xr.Dataset(
134134
| `movement` xarray | 📋 documented above | Not implemented |
135135
| DeepLabCut CSV input (also Lightning Pose, EKS) | ✅ supported | One session per prediction file; the frame rate and frame size are options you give (the file records neither); one keypoint stands for the animal and the whole skeleton is stored beside it. See `docs/tracker-formats/README.md`. |
136136
| SLEAP analysis HDF5 input | ✅ supported | In SLEAP choose *File > Export Analysis HDF5*. One session per file; the frame rate and frame size are options you give; one skeleton node stands for the animal and the whole skeleton is stored beside it. `.slp` project files are not read. See `docs/tracker-formats/README.md`. |
137-
| Ctrax raw `.mat` input | ✅ supported | The file Ctrax's *Save Tracks as Matlab File* writes. Frame size is an option you give; the frame rate comes from the file. Ctrax track ids are fragments, so a session is identity-free and one slot per id (`top_n` keeps the longest). `trx.mat` (Ctrax / FlyTracker / JAABA) is not read yet. See `docs/tracker-formats/README.md`. |
137+
| Ctrax raw `.mat` input | ✅ supported | The file Ctrax's *Save Tracks as Matlab File* writes. Frame size is an option you give; the frame rate comes from the file. Ctrax track ids are fragments, so a session is identity-free and one slot per id (`top_n` keeps the longest). See `docs/tracker-formats/README.md`. |
138+
| `trx.mat` input (Ctrax / FlyTracker / JAABA) | 🧪 synthetic only | A classic (v5/v7) MATLAB file holding a `trx` struct, built from the documented layout with no real sample pinned yet. Frame size is an option; `fps` is read from the file. `pxpermm` (pixels per mm) becomes the session scale for Session calibration, pending the usual unit confirmation; a value of exactly 1 is ignored. v7.3 files are not read. |
138139
| DeepLabCut `.h5` input | 🕒 planned | Waiting on the decoder decision in the reader rollout (`docs/tracker-formats/`). Until then export DeepLabCut as CSV. A reader plug-in is also possible — see the `track2data.readers` entry point in `CONTRIBUTING.md`. |
139140
| NWB | ❌ not planned | Would be worth revisiting if the behavioural-NWB extensions stabilise. |
140141

89.6 KB
Binary file not shown.

‎docs/guide/USER_GUIDE.md‎

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Calibration decides which units distances and speeds are reported in. Figure 4 s
193193
|---|---|---|
194194
| **Body length** (recommended) | You do not have a reliable scale | `*_bl` columns: distances in body lengths. Physical `*_cm` columns stay empty. |
195195
| **Custom (px per unit)** | You know the scale | `*_cm` columns, and `*_bl` columns too whenever the tracker recorded body length |
196-
| **Session calibration** | You used idtracker.ai's *Length Calibration* tool | each session's own ratio; you must confirm the unit |
196+
| **Session calibration** | Each session already carries a scale: idtracker.ai's *Length Calibration* tool, a Ctrax / JAABA `trx.mat` `pxpermm`, or a scale you gave when importing | each session's own ratio; you must confirm the unit |
197197

198198
In Session calibration mode, Track2Data also records how much your length-calibration clicks disagreed
199199
(a relative spread, saved in `sessions.csv` as `length_calibration_rel_sd`) and warns when it is above 5%.
@@ -216,6 +216,33 @@ you. A third click starts the measurement over.
216216
If a mode is incomplete (no scale, or an unconfirmed unit) the stage shows ✗ and **Next** is
217217
disabled until you fix it.
218218

219+
### Session calibration: where each tracker's scale comes from
220+
221+
Only some trackers record a scale. The **ⓘ** button beside the description opens a short note on
222+
what each tracker in your project records, with links to its documentation. Figure 6 shows the mode.
223+
224+
<figure>
225+
<img src="images/03-calibration-session.png" alt="Session calibration">
226+
<figcaption><b>Figure 6.</b> Session calibration: the unit, the choice between several calibrations, the confirmation and each session's readiness.</figcaption>
227+
</figure>
228+
229+
| Tracker | Where the scale comes from |
230+
|---|---|
231+
| **idtracker.ai** | The Validator's *Length Calibration* tool saves one or more measurements. `length_unit` is their average: a factor from pixels to *user-defined units*. idtracker.ai does not record whether you measured in cm or mm, so the **Unit** you pick is your own declaration and you must confirm it. See the [idtrackerai.Session reference](https://idtracker.ai/latest/reference/generated/idtrackerai.Session.html). |
232+
| **Ctrax / JAABA `trx.mat`** | `pxpermm` (pixels per millimetre), present once the file's units were converted. Track2Data turns it into pixels per cm and ignores a value of exactly 1, which those tools use for "never calibrated". See [the Ctrax trx fields](https://ctrax.sourceforge.net/bmat.html). |
233+
| **DeepLabCut, SLEAP, Ctrax raw `.mat`** | Their files record no scale. Give **Scale (pixels per cm)** in the confirm step when you add the sessions, or use **Custom** or **Body length**. |
234+
235+
The per-session readiness list says whether each session is calibrated and with which value. A
236+
session without a scale reads *not calibrated* (idtracker.ai) or *no scale set at import* (other
237+
trackers). The **Session calibration** card is disabled when no session in the project can supply a
238+
scale.
239+
240+
**Several calibrations.** An idtracker.ai session can hold several length measurements. With
241+
**Several calibrations** you choose **Average** (idtracker.ai's own `length_unit`, the default) or
242+
**Median** (one badly placed click cannot move it). The list shows which one is in use, for example
243+
*median of 3*. If the saved `length_unit` differs from the average of the session's measurements
244+
(they were edited after export), the saved value is used and the run log carries a warning.
245+
219246
### Camera view
220247

221248
Further down the same screen, **Camera view** says how the camera looked at the animals: **Not
@@ -245,7 +272,7 @@ one. You can:
245272

246273
<figure>
247274
<img src="images/04-zones.png" alt="Zones list">
248-
<figcaption><b>Figure 6.</b> The zone list, with the import and load buttons.</figcaption>
275+
<figcaption><b>Figure 7.</b> The zone list, with the import and load buttons.</figcaption>
249276
</figure>
250277

251278
### Drawing zones
@@ -255,7 +282,7 @@ with their names.
255282

256283
<figure>
257284
<img src="images/04-zones-canvas.png" alt="Zone canvas">
258-
<figcaption><b>Figure 7.</b> The zone canvas: saved zones are shaded and named, validator landmarks are blue.</figcaption>
285+
<figcaption><b>Figure 8.</b> The zone canvas: saved zones are shaded and named, validator landmarks are blue.</figcaption>
259286
</figure>
260287

261288
| Tool | How |
@@ -282,7 +309,7 @@ Attach experimental information (treatment, date, tank, …) to every row of the
282309

283310
<figure>
284311
<img src="images/05-metadata.png" alt="Metadata screen">
285-
<figcaption><b>Figure 8.</b> The Metadata screen: CSV preview, column mapping and the match summary.</figcaption>
312+
<figcaption><b>Figure 9.</b> The Metadata screen: CSV preview, column mapping and the match summary.</figcaption>
286313
</figure>
287314

288315
1. **Load metadata CSV…**. The first rows are previewed.
@@ -327,7 +354,7 @@ step has an **Enabled** box; the raw data is never overwritten.
327354

328355
<figure>
329356
<img src="images/06-preprocessing.png" alt="Preprocessing screen">
330-
<figcaption><b>Figure 9.</b> The Preprocessing screen with the default settings.</figcaption>
357+
<figcaption><b>Figure 10.</b> The Preprocessing screen with the default settings.</figcaption>
331358
</figure>
332359

333360
| Step | What it does |
@@ -361,7 +388,7 @@ went, not a measurement:
361388

362389
<figure>
363390
<img src="images/06-preprocessing-identity-switch.png" alt="Identity switch correction">
364-
<figcaption><b>Figure 10.</b> The identity switch correction options (experimental, off by default).</figcaption>
391+
<figcaption><b>Figure 11.</b> The identity switch correction options (experimental, off by default).</figcaption>
365392
</figure>
366393

367394
**Identity switch correction is experimental and off by default.** It reassigns identities from
@@ -378,7 +405,7 @@ Choose what to compute. Metrics are grouped on three tabs: **Individual** (per a
378405

379406
<figure>
380407
<img src="images/07-metrics.png" alt="Metrics screen">
381-
<figcaption><b>Figure 11.</b> The Metrics screen, with search, presets and the three metric tabs.</figcaption>
408+
<figcaption><b>Figure 12.</b> The Metrics screen, with search, presets and the three metric tabs.</figcaption>
382409
</figure>
383410

384411
- **Search** filters all tabs by name or ID (`speed`, `IL-2`). The line beneath says which tabs
@@ -410,7 +437,7 @@ zone assignment, metrics, export.
410437

411438
<figure>
412439
<img src="images/08-processing.png" alt="Processing screen">
413-
<figcaption><b>Figure 12.</b> The Processing screen: one row per session, with status and duration.</figcaption>
440+
<figcaption><b>Figure 13.</b> The Processing screen: one row per session, with status and duration.</figcaption>
414441
</figure>
415442

416443
- The table shows each session's status and duration. A failed session is marked *Failed* and does
@@ -444,12 +471,12 @@ Choose a session and **Load trajectories** (it reuses the cache after a run). Th
444471

445472
<figure>
446473
<img src="images/09-preview-trajectories.png" alt="Trajectories">
447-
<figcaption><b>Figure 13.</b> Trajectories with Raw + processed shown: the dashed grey line is a tracking jump that was removed.</figcaption>
474+
<figcaption><b>Figure 14.</b> Trajectories with Raw + processed shown: the dashed grey line is a tracking jump that was removed.</figcaption>
448475
</figure>
449476

450477
- Drag the slider, or press ▶, to move through time. **Trail** sets how many past frames are drawn.
451478
- **Show ▸ Raw + processed** draws the raw path as a dashed grey line next to the processed one, so
452-
you can see exactly what gap filling, jump removal and smoothing changed. In Figure 13 the
479+
you can see exactly what gap filling, jump removal and smoothing changed. In Figure 14 the
453480
dashed line is a tracking jump that was removed.
454481
- **Zones** shows or hides the saved zones. The mouse wheel zooms.
455482

@@ -462,7 +489,7 @@ Tick **Occupancy heatmap** to see where the animals spent their time (red = most
462489

463490
<figure>
464491
<img src="images/09-preview-heatmap.png" alt="Heatmap">
465-
<figcaption><b>Figure 14.</b> The occupancy heatmap.</figcaption>
492+
<figcaption><b>Figure 15.</b> The occupancy heatmap.</figcaption>
466493
</figure>
467494

468495
### Diagnostics
@@ -473,7 +500,7 @@ changed.
473500

474501
<figure>
475502
<img src="images/09-preview-diagnostics.png" alt="Diagnostics">
476-
<figcaption><b>Figure 15.</b> The Diagnostics tab.</figcaption>
503+
<figcaption><b>Figure 16.</b> The Diagnostics tab.</figcaption>
477504
</figure>
478505

479506
### Metrics
@@ -486,7 +513,7 @@ Tick the formats you want, choose where to write them, and press **Export**.
486513

487514
<figure>
488515
<img src="images/10-export.png" alt="Export screen">
489-
<figcaption><b>Figure 16.</b> The Export screen, with the file receipt after an export.</figcaption>
516+
<figcaption><b>Figure 17.</b> The Export screen, with the file receipt after an export.</figcaption>
490517
</figure>
491518

492519
1. Tick the formats you want.
@@ -516,7 +543,7 @@ After an export, the panel at the bottom gives ready-to-paste code for the files
516543

517544
<figure>
518545
<img src="images/10-export-code.png" alt="Code snippets">
519-
<figcaption><b>Figure 17.</b> Ready-to-paste R and Python snippets for the files just written.</figcaption>
546+
<figcaption><b>Figure 18.</b> Ready-to-paste R and Python snippets for the files just written.</figcaption>
520547
</figure>
521548

522549
See [Understanding the output files](#understanding-the-output-files) for what the columns mean.
@@ -563,6 +590,7 @@ Definitions, formulas and references for every metric: [`docs/METRICS_SPEC.md`](
563590
| You see | Why | What to do |
564591
|---|---|---|
565592
| **Next** is disabled | A required stage is empty or invalid | Hover over Next: the tooltip names the problem. Check the ✗ / ○ badges in the sidebar |
593+
| *"Session calibration selected but these sessions have no length_unit"* | A session has no scale (idtracker.ai never calibrated it, or the other tracker's file records none) | Calibrate it in the idtracker.ai Validator, give **Scale (pixels per cm)** when importing, or switch the calibration mode |
566594
| *"No reader recognised the session folder"* | The folder is not an idtracker.ai output | Pick the session folder itself (the one containing `trajectories/`). Supported: idtracker.ai 6.x output (the legacy v5 layout also works); v4 is not supported yet (a v4-looking folder gets a specific message; see [sending a v4 sample](../IDTRACKERAI_V4_SAMPLES.md)) |
567595
| Video column says *Not found* | The video path idtracker.ai recorded does not exist on this computer | Select the session and press **Locate Video…** (Sessions). Metrics do not need the video |
568596
| *READER_NOT_AVAILABLE* | A project session was added with software this version of Track2Data does not have | Install a version that has that reader. Track2Data will not read it with a different one, since that could change the numbers |

‎docs/guide/images/01-project.png‎

3.42 KB
Loading
-607 Bytes
Loading
5.61 KB
Loading
4.03 KB
Loading
130 KB
Loading
137 Bytes
Loading

0 commit comments

Comments
 (0)