Skip to content

fix(scripts): bring debug_track.py up to the current track flow; fix the mem_nuc_contour key - #466

Merged
tayllatheodoro merged 1 commit into
mainfrom
fix/debug-track-script
Nov 10, 2026
Merged

tayllatheodoro merged 1 commit into
mainfrom
fix/debug-track-script

Conversation

@tayllatheodoro

Copy link
Copy Markdown
Collaborator

Closes #458 (option 1: update the script, fix the key in both places).

Problem

scripts/debug_track.py failed at import on main: resolve_z_slice was removed in #424. Beyond that, the script was written for the pre-#424 flow: z_range in the config (now rejected, since track doesn't select Z), the old run_ultrack(cfg, fg, contour, scale, path) signature, a foreground+contour-only path (the default is now segmentation_method: labels), hardcoded dataset paths, and the stale key biahub.cli.track.mem_nuc_contour. scripts/ is excluded from ruff, so none of this was caught.

Change

  • scripts/debug_track.py, rewritten as a thin wrapper over the library: python scripts/debug_track.py -c track.yml -i <plate>.zarr/B/1/000000 [--input-images-path …] [--database-dir …] [--n-workers N].
    • Reads the same YAML as biahub track (yaml_to_model(…, TrackingSettings)) and resolves the first null input_images path the same way.
    • Checks Z against output_mode (check_input_dimensionality), so a 3D plate with 2D tracking points you to biahub project.
    • Tracks one FOV with the same functions track_one_position uses: load_labels (labels mode) or _load_and_preprocess + detect_foreground_segmentation (foreground+contour), then run_ultrack. tracksdata / hoct / trackastra go through link_fixed_labels.
    • Opens napari with the inputs, the tracked labels and the tracks. Nothing is written into the plate. The ultrack database goes in a temp dir unless --database-dir is given.
  • settings/example_track_settings.yml: the commented example now uses biahub.track.mem_nuc_contour (the key in CUSTOM_FUNCTIONS).

Tested

On a synthetic 4-frame plate (3 moving disks, labels/nuclei), with napari stubbed (no display):

  • segmentation_method: labels → 3 tracks over 4 timepoints; viewer gets labels/nuclei, tracks_nuclei and the tracks layer.
  • segmentation_method: foreground_contour with biahub.track.mem_nuc_contour → 3 tracks over 4 timepoints.
  • The plate still has only labels/nuclei afterwards.

ruff check / ruff format --check (repo config, --no-force-exclude) pass, and tests/test_example_settings.py passes (32).

…the mem_nuc_contour key

debug_track.py failed at import: resolve_z_slice was removed in #424, and the
script also used z_range, the old run_ultrack signature, hardcoded dataset
paths and the stale function key biahub.cli.track.mem_nuc_contour.

The script now reads a biahub track config (-c) and one position (-i), tracks
that FOV in memory the way biahub track does (labels or foreground+contour for
ultrack; tracksdata/hoct/trackastra on the segment labels), and opens napari.
Nothing is written into the plate.

The commented example in settings/example_track_settings.yml used the same
stale key; it is now biahub.track.mem_nuc_contour.

Closes #458
@tayllatheodoro
tayllatheodoro merged commit 13eaeae into main Nov 10, 2026
7 checks passed
@tayllatheodoro
tayllatheodoro deleted the fix/debug-track-script branch November 10, 2026 00:20
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.

scripts/debug_track.py is broken on main (resolve_z_slice removed in #424; stale mem_nuc_contour key)

2 participants