Working with Other Programs - prnvkhndlwl/Kinetrace GitHub Wiki
Kinetrace can take over from another program at any stage, or hand its work on. Every conversion below is done by the program — pixel conventions (0- or 1-based, y down or up), axis handedness, transposed MATLAB matrices — and the calibration files are checked against Kinetrace's own projection before they are written. The same conversions are in the menus and in a command-line converter for scripts.
| You have | Menu | Kinetrace reads |
|---|---|---|
| 2D tracks | File → Import → Tracks… | (the message counts only what was written and names any landmark it left alone because it comes from the silhouette or is a ball) DeepLabCut CSV (from analysing a video; single animal), SLEAP CSV (1.x analysis CSV, sleap-io's sleap / instances / points / frames; one track), DLTdv / Argus xypts (one camera or all; top-left or bottom-left, from the _pointnames.csv sidecar), a Kinetrace tracks.csv. Points are matched by name; frames the file has no position for keep yours. A name that differs from yours only in capitals ("head" beside "Head") arrives as "head (2)", and a second import of the file updates that point |
| a camera calibration | File → Import → Calibration… | Kinetrace .kcal.json, DLTdv / easyWand / Argus dltCoefs.csv, easyWandData.mat, a DLTdv8 project, Anipose calibration.toml, OpenCV .yml / .json, MATLAB .mat with a cameras struct, K + R/t JSON or text |
| 3D points | File → Import → 3D Points… | Anipose points_3d CSV, DLTdv xyzpts, Kinetrace's xyz CSV — for the 3D view and the kinematics export |
| camera offsets | File → Import → Camera Offsets… | CSV camera, name, offset, rate (matched by camera name). Re-based on your project's first camera — a table saying camA 120, camB 97, camC 130 becomes 0, −23, 10 when camA is first; a file with no row for your first camera asks whether to apply its numbers as written |
| silhouettes | File → Import → Silhouettes (mask images)… | a folder of black / white masks named with their frame number (mask_000012.png), the size of the video. All or nothing: one wrong-sized or unreadable image refuses the folder, naming it, and nothing is stored |
| a lens profile | 3D → Calibrate → Calibrate a Lens → I already have a lens file… (and the wand wizard's Cameras page) | Kinetrace .klens.json, OpenCV .yml / .json, Argus profile lines |
| You want | Menu | Kinetrace writes |
|---|---|---|
| the calibration for another program | File → Export → Calibration… (tick one or all) |
.kcal.json + dltCoefs.csv (MATLAB pixels, for DLTdv / easyWand) + report; Anipose calibration.toml; OpenCV .yml / .json (K, distortion, R, t per camera); MATLAB .mat (MATLAB's fields — 1-based K, IntrinsicMatrix, RotationMatrix … — and OpenCV's); a Blender script that makes the cameras; lens profiles; offsets.csv
|
| 2D tracks | File → Export → Tracks… (Ctrl+E) | wide CSV, DeepLabCut CSV, DeepLabCut multi-animal CSV (one individual per animal, Scene points under single), SLEAP analysis CSV (one track per animal + a scene track), DLTdv8 xypts (one camera, or all cameras for 3D), sparse TSV, MATLAB |
| 3D | Ctrl+E | Kinetrace xyz CSV, Anipose points_3d CSV, DLTdv xyzpts, 3D kinematics |
| silhouettes | Ctrl+E | polygons per frame (JSON), one PNG mask per frame — one file / folder per animal when there are several |
Two things the calibration export tells you about when they happen:
coefficients from easyWand or DLTdv usually describe a mirrored
(left-handed) world, which K + R/t formats cannot hold, so the exported world
is Kinetrace's mirrored in Z (and 3D points exported with it are mirrored the
same way); and DLTdv's own lens correction is not an OpenCV model, so one is
fitted to it and its largest error is named. 3D → Set World Axes… (an origin
and +X / +Y from three landmarks, +Z by the right-hand rule) gives such a
calibration a right-handed world, so nothing is mirrored on export. Exported 3D
points are always in the same world as the exported cameras. A DLTdv export
(xypts or xyzpts) is only the points file and its quoted _pointnames.csv. Otherwise the exported cameras
agree with Kinetrace's to about a thousandth of a pixel.
- Open one video per camera (File → Open Folder of Videos… for a folder of them, or File → Open Video, then + Add video in the CAMERAS panel), line the cameras up (3D → Sync → Sync Cameras), and calibrate (3D → Calibrate → Calibrate a Lens for wide-angle cameras, then 3D → Calibrate → Calibrate Cameras with a Wand).
-
File → Export → Calibration… and tick the program you use next: Anipose's
calibration.tomlgoes in Anipose's calibration folder (rename itcalibration.toml); the OpenCV files load withcv2.FileStorage; the MATLAB file withload; the Blender script runs in Blender's Scripting tab; DLTdv8 and easyWand take thedltCoefs.csv.
For scripts and pipelines, with the environment's Python
(.venv\Scripts\python on Windows, .venv/bin/python on Linux and macOS):
python -m kinetrace.convert info FILE
python -m kinetrace.convert check FILE # exit 0 clean, 1 warnings, 2 errors
python -m kinetrace.convert calibration IN OUT [--to anipose|opencv-yaml|opencv-json|matlab|blender|dlt|kcal]
[--size WxH ...] [--pixels matlab|bottom-left|opencv]
(--pixels is needed for a dltCoefs.csv or easyWand file)
python -m kinetrace.convert tracks IN OUT (--video V | --size WxH --frames N)
[--to dlc|dltdv|dltdv-bottomleft|wide|sparse|kinetrace]
python -m kinetrace.convert points3d IN OUT [--to kinetrace|dltdv|anipose]
[--calibration CAL [--size WxH ...] [--pixels P]]
python -m kinetrace.convert masks PROJECT OUT [--camera NAME] [--animal NAME] [--to json|png]
(--animal is needed when the camera has several animals)
python -m kinetrace.convert offsets PROJECT OUT
python -m kinetrace.convert import PROJECT --tracks FILE [--camera NAME] [--out NEW.kinetrace]
python -m kinetrace.convert pack PROJECT OUT.kinetrace (a project folder -> one file)
python -m kinetrace.convert unpack FILE.kinetrace FOLDER.kinetrace (one file -> a project folder)
python -m kinetrace.convert previous PROJECT (back one save)
tracks --camera K refuses an all-cameras file for K above 1 (its rows are
frames of the reference camera: use import, which maps them through the
project's offsets); points3d --calibration writes the 3D points in the same
world as the cameras calibration exports from that file. The output format
follows --to, or else the output's name (.toml,
.yml, .mat, .kinetrace …). A dltCoefs.csv records no picture sizes:
give --size once for all cameras or once per camera. import writes the
project folder back, only the files that change, with the previous save kept
in its .history/ (previous goes back to it; a single-file project keeps its
previous version as .bak; use --out for a new project, which gets an identity
of its own); do not run it on a
project that is open in Kinetrace. New point names
land in every camera's list, with data only in the camera imported into — the
same shared list the app keeps.
A .kinetrace project is a folder of CSV / JSON (and .npy for silhouette
outlines and body poses) — one CSV per landmark and camera — readable and
writable without Kinetrace: open cameras/<camera>/tracks/<landmark>.csv in
any program. Every file and column is described in
docs/FORMAT.md,
with a Python reader and a three-file project you can write by hand. For
DeepLabCut, DLTdv and MATLAB's own formats, File → Export → Keep Exports Up to Date…
writes them into the project's exports/ folder at every save.
| Program | first pixel | y |
|---|---|---|
| Kinetrace, OpenCV, DeepLabCut, SLEAP, Anipose | 0 (pixel centres on whole numbers) | down |
| DLTdv8, easyWand, MATLAB | 1 | down |
| older DLTdv, Argus Clicker | 1 | up from the bottom edge |
A calibration is converted to Kinetrace's own pixels once, when it is imported. The dltCoefs.csv and
MATLAB exports are in DLTdv8's convention (first pixel 1, y down), whatever the imported file used: a
file counted from the bottom edge comes back top-left. A dltCoefs.csv or easyWand file does not say
which row of this table it came from, so the import asks (the command line wants --pixels).