Skip to content

Read native 3-D tracker files (Anipose pose-3d, DLC-3D) — sub-project A - #144

Merged
mbel-tech merged 25 commits into
mainfrom
fatina-del-codice/beautiful-hypatia-wlxfol
Oct 11, 2026
Merged

mbel-tech merged 25 commits into
mainfrom
fatina-del-codice/beautiful-hypatia-wlxfol

Conversation

@mbel-tech

Copy link
Copy Markdown
Owner

What and why

Adds two readers for tracker output that is already 3-D: Anipose pose-3d CSV and DLC-3D. Their coordinates are in physical units with an absolute z axis and no pixel frame, so sessions carry raw_z / PreprocessedSession.z in the project's length unit. IL-16, IL-17 and GL-16 (B2) read it directly; IL-15 works once the user enters a water column (surface z, floor z) on the Calibration page.

Key behaviour:

  • unit and fps are required reader options (the files record neither); coordinates are converted to the project unit with exact ratios.
  • A native 3-D project is a dimension == "2d" project whose sessions come from native readers: no Views/Fusion step, run units and stage flow unchanged. Mixing native and pixel sessions is refused (NATIVE_3D_MIXED), as is a second target unit (NATIVE_3D_UNIT_MISMATCH).
  • Only the add entry point sets up calibration (mode session, label = target unit, confirmed); import, validate and runs are read-only on it.
  • No pixel frame: zones/background disabled, IL-3/IL-14 arena from the data extent with a warning, preview framed from the positions.
  • Spec: docs/3d-movement/2026-10-10-native-3d-files-design.md; plan: docs/superpowers/plans/2026-10-11-native-3d-files.md.

Test plan

Failing tests first per task. Full suite: QT_QPA_PLATFORM=offscreen pytest -q -W error::RuntimeWarning (4316 passed, 191 skipped), ruff check ., CI-venv mypy 2.4.0 (clean). End-to-end: tests/test_integration/test_native_3d.py.

Checklist

  • Tests added or updated (written before the fix)
  • ruff check . passes
  • Docs updated if behaviour changed
  • CHANGELOG.md entry under [Unreleased]; decision entry added
  • Guide screenshots regenerated if a screen changed (Calibration page gained water-column fields for native projects; not regenerated here)

🤖 Generated with Claude Code

https://claude.ai/code/session_01QXpnhJcJvaj5BxqfESMHNp


Generated by Claude Code

claude added 25 commits October 10, 2026 18:22
…ions, non-finite z is missing

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QXpnhJcJvaj5BxqfESMHNp
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QXpnhJcJvaj5BxqfESMHNp
Adds readers/native3d.py (unit table, axis permutation, shared options, reduce_native),
assemble_native_session (separate from assemble_session, which still rejects a frame size
below 1), the provides_native_3d flag and AniposeReader (pose-3d CSV; unit and fps required,
fnum gaps become tracking_intervals).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QXpnhJcJvaj5BxqfESMHNp
DeepLabCut3DReader reads triangulated DLC-3D CSV tables (scorer/bodyparts/coords with x, y, z, no
likelihood) via the shared native-3D helpers: fps and unit required, no proposed unit, no
likelihood_cutoff, all-zero (0,0,0) or NaN rows are missing, frame-index gaps become tracking
intervals. The unreadable-format entry for dlc_3d is removed from recognise.py now that it is read.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QXpnhJcJvaj5BxqfESMHNp
Engine.register_native_import refuses mixing native 3-D and pixel sessions
(NATIVE_3D_MIXED) or another target unit (NATIVE_3D_UNIT_MISMATCH) and sets
session calibration on the first native import; import_ref, the GUI add
path and t2d add all go through it. Availability treats a native project as
3-D data, top-view, with IL-15 waiting for the water column
(NEEDS_WATER_COLUMN_REASON); validate requires session calibration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QXpnhJcJvaj5BxqfESMHNp
…ration

One add entry point, Engine.set_up_native_import, decides 'first native'
from the project before the batch and checks mixing and units across the
project and within the batch; t2d add, the GUI add path (pre-checked from
the saved options, set up when the batch's probes finish) and
import_sessions use it. import_ref only checks and never rewrites the
manifest; validate and the stage status report mode, confirmation and unit
mismatches each on their own; a native session outside session calibration
is refused at preprocess and compute time (NATIVE_3D_NEEDS_SESSION_CALIBRATION).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QXpnhJcJvaj5BxqfESMHNp
Every entry import_sessions reads was already in the project, so none is
an add: it no longer calls set_up_native_import, and a native project in
bodylength mode, unconfirmed or with a hand-edited label is left as it is
for validate to report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QXpnhJcJvaj5BxqfESMHNp
…block

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QXpnhJcJvaj5BxqfESMHNp
…l size passing, golden pixel README

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QXpnhJcJvaj5BxqfESMHNp
Synthetic Anipose files added through the real add flow (t2d add), preprocessed and run:
IL-16 13 cm, IL-17 32.5 cm/s, GL-16 NaN (one animal per file), the 2-D metrics on the
horizontal plane, IL-15 unavailable without and exact with the water column (outside values
counted), reversed column, binned run, serial == parallel, vertical_axis=y, a pixel project
unchanged.

Found by the test and fixed: IL-17 (Speed3D) read depth * height only, so a native session
without a water column got NaN; it now takes the vertical series from the absolute z.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QXpnhJcJvaj5BxqfESMHNp
User guide (native files, units, vertical axis, water column, limits), CHANGELOG, decision D-043
(amends D-031 a second time), tracker-formats P5 status and a DLC-3D entry, roadmap row A done,
README reader list, wiki format pages (DeepLabCut 3-D is no longer "unreadable"), and the spec
set to implemented with a "Changes made during the build" section.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QXpnhJcJvaj5BxqfESMHNp
…gn doc

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QXpnhJcJvaj5BxqfESMHNp
…s applied per session

IL-15 was inverted for a session read with flip: the reader had already negated z, while the
column was applied as entered.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QXpnhJcJvaj5BxqfESMHNp
IL-3, IL-9, IL-10 and IL-14 use pixel-sized defaults that would silently mean the project unit,
and every group metric needs several animals while a native file holds one. One reason each,
through availability.unavailable_reason, so every caller agrees.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QXpnhJcJvaj5BxqfESMHNp
…ic docs cover native z

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QXpnhJcJvaj5BxqfESMHNp
….json bytes

water_column is left out while None (a serializer on CalibrationConfig) and the provenance
native_3d key only appears for a native session. Golden values computed from fc5b2fc.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QXpnhJcJvaj5BxqfESMHNp
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QXpnhJcJvaj5BxqfESMHNp
…again

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QXpnhJcJvaj5BxqfESMHNp
…ged; flip and recognise notes

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QXpnhJcJvaj5BxqfESMHNp
@mbel-tech
mbel-tech marked this pull request as ready for review October 11, 2026 09:39
@mbel-tech
mbel-tech merged commit c2b9bb8 into main Oct 11, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants