Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3026afb
docs: spec for reading native 3-D tracker files (sub-project A)
claude Oct 10, 2026
fc5b2fc
docs: implementation plan for native 3-D files (sub-project A)
claude Oct 11, 2026
e56918b
feat(native3d): absolute z, water column and 3-D positions from z
claude Oct 11, 2026
be757e3
fix(native3d): keep_animals filters raw_z, fusion refuses native sess…
claude Oct 11, 2026
3409420
style(native3d): wrap fuse docstring line
claude Oct 11, 2026
f09f062
feat(readers): shared native 3-D helpers and the Anipose reader
claude Oct 11, 2026
1b8b192
fix(readers): refuse a score cutoff without scores, exact unit conver…
claude Oct 11, 2026
7b4d9f1
feat(readers): DLC-3D reader
claude Oct 11, 2026
acdff78
feat(native3d): project rules, calibration and availability
claude Oct 11, 2026
9b5ad85
fix(native3d): batch set-up, read-only import checks, no forced calib…
claude Oct 11, 2026
5dd0c7f
fix(native3d): import_sessions only checks, never sets a project up
claude Oct 11, 2026
36f1228
feat(native3d): no-pixel-frame handling, water column fields, README …
claude Oct 11, 2026
4111a93
fix(native3d): frame the native preview from the positions, keep pixe…
claude Oct 11, 2026
132d53b
test: end-to-end native 3-D files
claude Oct 11, 2026
ab445b4
docs: describe native 3-D files
claude Oct 11, 2026
5f41b29
docs: restore the pinned research file, keep the P5 notes in the desi…
claude Oct 11, 2026
f2baa38
fix(native3d): the water column is entered on the file's axis, flip i…
claude Oct 11, 2026
0bf7570
fix(native3d): rule out pixel-sized and group metrics in native projects
claude Oct 11, 2026
0677705
fix(native3d): IL-15 source is water_column for native sessions; metr…
claude Oct 11, 2026
d5850ff
docs: native z in the IL-15/16/17 spec rows, wiki stamp and glossary
claude Oct 11, 2026
3c60ce2
fix(native3d): pixel projects keep their hash, cache key and manifest…
claude Oct 11, 2026
b8c81b1
style: wrap a long documentation line
claude Oct 11, 2026
2921e43
fix(readers): name multi-animal and incomplete DeepLabCut 3-D tables …
claude Oct 11, 2026
7282d6a
fix(native3d): a replaced jump blanks z; no 'None' in the mixing refusal
claude Oct 11, 2026
4e5e2e2
docs: native files offer no group or pixel-sized metrics; hash unchan…
claude Oct 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

### Added

- **Native 3-D files: Anipose and DeepLabCut 3-D.** Two new readers (`anipose` for `pose-3d` CSV, `deeplabcut_3d` for the triangulated tables; both built from the published layouts and tested on synthetic files only, so labelled *synthetic only*) give sessions with an absolute z in the project's length unit. `fps` and `unit` (mm, cm, m, in) are required options and never guessed (Anipose proposes `mm`, DeepLabCut 3-D proposes nothing); `target_unit` (default `cm`), `keypoint`, `likelihood_cutoff` (Anipose only), `vertical_axis` (`x`, `y`, `z`; default `z`), `flip` and `keep_skeleton` are optional. Units are converted when the file is read. IL-16 and IL-17 run on them with no water column; the 2-D metrics measure on the horizontal plane. **IL-15** runs once you give the **water column** (Surface z and Floor z on the Calibration screen); positions outside it have no depth and are counted in `frac_outside_extent`, never clipped. A native 3-D project is a 2-D project (leave Analysis type on 2D) with no Views or Fusion step; adding the first file sets Session calibration, the unit label and its confirmation, and later files must use the same target unit (`NATIVE_3D_UNIT_MISMATCH`); native and pixel sessions cannot share a project (`NATIVE_3D_MIXED`); other calibration modes are blocked (`NATIVE_3D_NEEDS_SESSION_CALIBRATION`). Not offered for native files (greyed out with a reason): every group metric, GL-16 included (a file holds one animal), and IL-3, IL-9, IL-10 and IL-14 (pixel-sized defaults that would change with the project unit). The water column is entered on the file's own vertical axis; each session's flip is applied for you. Limits: one animal per file, no z column in the per-frame table, no zones or background image, no refraction correction, a multi-animal DeepLabCut 3-D table (or one without full x, y, z triples) is still named by the scan as one it cannot read yet. The run `README.md` gains a **Native 3-D source** section. See the user guide and decision D-043.
- **3-D metrics (fused 3-D projects).** Three new metrics next to the 2-D ones, which are unchanged: **IL-16 3-D Distance Travelled** (`path_length_3d_cm`, `path_length_3d_bl`, `n_valid_steps`), **IL-17 3-D Speed** (`mean_speed_3d_cm_s`, `median_speed_3d_cm_s`, `max_speed_3d_cm_s`, `mean_speed_3d_bl_s`) and **GL-16 3-D Nearest-Neighbour Distance** (`mean_nnd_3d_cm`, `median_nnd_3d_cm`, `mean_nnd_3d_bl`, `n_skipped_frames_3d`). Positions are in cm: x and y from the top view divided by its scale, depth fraction times the tank height from the fusion settings. IL-16 and IL-17 need identities, GL-16 does not; all three compute per time bin like their 2-D counterparts. They need the top view's cm scale (scalar or session calibration): in a 2-D project they are greyed out ("needs a fused 3-D session"), under body-length calibration they are greyed out ("needs a cm scale for the top view (use scalar or session calibration)"), and a unit whose top view has no scale is skipped at run time ("needs a cm scale for the top view"), with the reason in the run README. Track2Data does not estimate the scale from the fusion. IL-17 uses the project's kinematics estimator for the vertical speed, and its horizontal part is IL-2's speed. A step, frame or speed needs a valid x, y and depth, otherwise the value is NaN, never 0. Not included: vertical speed as its own metric, 3-D inter-individual distance and cohesion. The Metrics screen presets (for example *All metrics*) no longer tick any row that is greyed out for the project (also, for instance, identity-needing metrics when every session is identity-free). `codebook.csv` lists the whole registry, so it gains rows for the three metrics in 2-D runs too; no other 2-D output changes. `track2data list-metrics` shows "fused 3-D + cm scale" for them.
- **Run a 3-D project.** A 3-D project now runs: every top/side pair with fusion settings that fuses without error becomes one run unit (id `<top>+<side>`, output folder `<run>/<top>+<side>/`), and each unit goes through the usual pipeline as a fused session. Sessions in no fusable pair, and pairs that fail to fuse, are left out with their reason: the Processing screen lists them, the run writes them to `skipped.csv` and to a "Skipped sessions" section of `PROJECT_SUMMARY.md` (both only when something was skipped), and `track2data run` prints them. A 3-D project with no fusable pair refuses to run ("no pair is ready to fuse: ..." or "Pair and fuse a top and a side session first"); one bad pair among good ones does not stop the run. Vertical position (IL-15) reads the fused depth, with `depth_extent_source` = `fusion`, and is available for a fused session whatever the project's camera view is; `frac_outside_extent` counts the side positions that fell outside the water column. Where the fused frames jump (a frame one of the views lacks), the fused track keeps a break, as a 2-D session tracked in separate intervals does, so path length and every other metric that steps from frame to frame never bridges the gap. A unit carries the TOP session's metadata (session-level columns such as `group_id`, `treatment` or `sex`), and per-animal metadata matches the fused fish by the top session's label or index. The per-frame tables (CSV long, Feather, Excel) gain `depth_fraction` and `depth_cm` for fused sessions; `sessions.csv`, each unit's README ("3-D fusion") and `manifest.json` (`run_metadata.fusion`) record how the pair was fused, including the SHA-256 of the side trajectory file. `PROJECT_SUMMARY.md` counts "Units processed (fused pairs)", and the pooled `all_sessions/manifest.json` records each unit's fusion. `track2data validate` and Validate check only the sessions that run: the consistency report reads the top session of each pair with fusion settings, and session calibration checks both sessions of such pairs. Serial and parallel runs give identical files. Processing, Preview and Export are blocked only while no pair has fusion settings; Processing shows what will run and what is skipped, and Preview shows the top-view tracks of a fused unit. `track2data validate` lists unfusable pairs as notes. 2-D projects are unchanged. Still missing: 3-D speed, path length and neighbour distance (sub-project B2); zones are one set applied to the top view; `sensitivity` refuses 3-D projects. New `Engine.run_units`, `RunPlan`, `RunUnit` and `Engine.validation_issues`.
- **Fusion of top and side views (3-D projects).** The Views page gains a **Fusion** section for the selected pair with a status line and **Set up fusion…**. The dialog shows the side view with two draggable lines for the water surface and the tank floor, fields for both rows, the tank height (default 20 cm), the shared horizontal axis (top-view x or y) with Flip, and the frame offset (hidden and fixed at 0 for "One video, two panels"), a live summary (shared frames, fused fish, positions outside the water column, agreement) and **Suggest offset**, which scans ±5 s around 0 (about 3 s on a 1-hour, 5-fish recording; needs a calibrated top view, otherwise it is disabled with a hint). The fusion keeps the fish matched in the pair on the frames both views have and adds a depth (0 = surface, 1 = floor; positions outside the column become empty and are counted). The cameras are assumed to be at right angles; the two views' horizontal positions are compared in cm and a warning shows when they disagree by more than 10% of the top-view range (needs a calibrated top view). Frame rates must match. New `FusionSettings` on each pair (`ViewPair.fusion`), `PreprocessedSession.depth`, `Engine.fuse_pair`, `fuse_all` and `suggest_offset`. The Views status warns "Fusion setup needed for …" and never blocks. A fused pair is what a 3-D run is made of (see "Run a 3-D project" above).
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ It is a desktop application and a Python engine you can drive headlessly for bat
→ export sessions.csv
```

**Reads** idtracker.ai (6.x and v5), DeepLabCut (CSV, also Lightning Pose), SLEAP
(analysis HDF5), Ctrax (raw `.mat`), `trx.mat`, and two native 3-D formats, Anipose
`pose-3d` CSV and DeepLabCut 3-D tables (positions in physical units; the 3-D metrics
the 3-D metrics IL-16 and IL-17 run on them, and IL-15 once you give the water column; GL-16 does not, because a native file holds one animal). Run
`track2data list-readers` for the list and the options each reader needs.

**Individual** — distance travelled, speed, acceleration, tortuosity,
freezing bouts, thigmotaxis, turn rate, home-base use.
**Group** — nearest-neighbour and inter-individual distance, polarisation,
Expand Down
8 changes: 4 additions & 4 deletions docs/3d-movement/2026-10-08-3d-roadmap.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 3-D movement: roadmap

**Status:** approved 2026-10-08. Sub-project C is in progress; E (mode switch), G, F, D (fusion) B1 (running a 3-D project) and B2 (3-D metrics) are implemented; A is not started.
**Status:** approved 2026-10-08. Sub-project C is in progress; E (mode switch), G, F, D (fusion) B1 (running a 3-D project) and B2 (3-D metrics) and A (native 3-D files) are implemented.
**Relates to:** `docs/dev/DECISIONS.md` D-031, `docs/dev/ROADMAP.md` (Z-10),
`docs/tracker-formats/2026-10-07-tracker-import-design.md` (Tier 3)

Expand All @@ -13,20 +13,20 @@ build cycle.
| **E** | **2D/3D project mode**: `ProjectManifest.mode`, Project-screen choice, lock, 3-D compute blocked. Done; see [the spec](2026-10-09-mode-switch-design.md) | nothing |
| F | **Panel split**: one video with the top and side views in two panels becomes two sessions (a panel rectangle per session, panel-relative coordinates). Done; see [the spec](2026-10-09-panel-split-design.md) | E |
| G | **ID correspondence**: view roles, pairing top and side sessions (regex or by hand), fish mapping between views, a Views step. Done; see [the spec](2026-10-09-id-correspondence-design.md) | E |
| A | Read 3-D tracker files (Anipose pose-3d CSV, DLC-3D). Metrics run on a chosen plane and z is stored (D-031 as written) | `feat/native-units` merged |
| A | Read 3-D tracker files (Anipose pose-3d CSV, DLC-3D). Metrics run on the horizontal plane and z is stored in the project unit. Done; see [the spec](2026-10-10-native-3d-files-design.md). **Amends D-031 a second time** | `feat/native-units` merged |
| B1 | **Run a 3-D project**: run units per fused pair, IL-15 from the fused depth, depth in the exports, UI and CLI. Done; see [the spec](2026-10-10-3d-run-design.md) | D |
| B2 | Metrics that use z: 3-D speed and path length, 3-D neighbour distance. Done; see [the spec](2026-10-10-3d-metrics-design.md). **Amends D-031** | B1 |
| D | Fuse top and side recordings into one 3-D session. Done; see [the spec](2026-10-09-fusion-design.md) | F and G (done) |

**Order: C, F/G/E, D, B1 and B2 are done; A remains.** A moves first if real 3-D files turn up. C went
**Order: all sub-projects are done.** C went
first because no data of any kind existed, it is testable on synthetic tracks, and it created the
project-level camera-view setting that B reuses.

## Hand-offs between the sub-projects

- `KeypointSelection.plane` and `camera_view` have no defined precedence. A and B must define
a vertical axis for 3-D data.
- The `has_pixel_frame` guard from native-units joins the IL-15 extent derivation when A lands.
- The `has_pixel_frame` guard from native-units joined the IL-3 and IL-14 arena fallback in A (the data extent is used, with a warning).
- Per-session camera views arrive with D (`Engine.camera_view_for(session)` is the seam).
- Whether IL-3 and IL-14, which assume a top-down view, should be gated for side views is
left open.
Loading