Skip to content

fix(scripts): update debug_track.py to the current track API - #463

Draft
tayllatheodoro wants to merge 2 commits into
mainfrom
fix/debug-track-458
Draft

tayllatheodoro wants to merge 2 commits into
mainfrom
fix/debug-track-458

Conversation

@tayllatheodoro

@tayllatheodoro tayllatheodoro commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #458.

scripts/debug_track.py stopped working when #424 removed resolve_z_slice, and it had other problems too:

  • Import: resolve_z_slice no longer exists, so the script failed with an ImportError at startup.
  • Config keys: TrackingSettings forbids unknown keys, so the old z_range and mode would have been rejected.
  • Function key: biahub.cli.track.mem_nuc_contour isn't in CUSTOM_FUNCTIONS. The same stale key was also in settings/example_track_settings.yml.

Changes

  • Import from biahub.tracking (refactor(track): move the tracking library code into biahub/tracking #454) and call run_ultrack with keyword arguments (detection=, edges=, scale=).
  • Replace the old keys with segmentation_method: foreground_contour and output_mode.
  • Projection: track no longer selects Z-planes, so the script projects the FOV in memory with the biahub project API (no CLI, no output store).
    • find_focus() wraps _find_focus_per_t, and project_fov() calls resolve_z_indices / project_zyx per channel.
    • The defaults use the same window as nextflow/configs/a549/project.yml: a mean over 60 planes starting 20 below the Phase3D focus, found per timepoint.
    • Focus store: a virtual-stain store usually has no Phase3D, so the new focus_store_path lets the focus channel come from another plate. Without it, the script gives a clear error.
    • Like biahub project: every input_images entry with a path is projected, and the output is float32 when any channel uses mean/sum.
    • A store that's already projected (Z=1) is tracked as is.
  • Tracks layer: in 3D the napari tracks layer now includes the z column and uses a (1, *scale) scale, so tracks line up with the (T, Z, Y, X) layers.
  • Match the blank-frames CSV using the B/1/000000 FOV form, the same way track does.
  • Fix the mem_nuc_contour key in the script and in example_track_settings.yml, plus some leftover typos. napari is now only imported when the viewer opens.
  • Update the note about the script in the track-with-biahub skill (references/evaluation.md).

Testing

On synthetic plates (T=4, Z=70; nuclei_prediction, membrane_prediction, Phase3D):

  • Projection:
    • With the virtual-stain channels in one store and Phase3D in another, the projection gives the same values as biahub project (project(..., cluster="debug")) on the combined plate. Without a focus store, the missing Phase3D raises a clear error.
    • The whole-stack mean fallback (no focus) equals mean over Z.
  • Tracking: the script's pipeline produces 4 tracks over 4 timepoints from the 4 planted cells (2D).
  • Viewer: the napari layers were built headless for 2D and 3D. The tracks layer has the image's dimensionality, with scale (1, *scale). napari.run() itself wasn't run.

Note: the script uses _find_focus_per_t and _FLOAT_METHODS, which are private to biahub/project.py, so it will need updating if they change.

debug_track.py failed at import after #424 removed resolve_z_slice, and its
config used keys TrackingSettings now rejects (z_range, mode) and a stale
function key (biahub.cli.track.mem_nuc_contour).

- import from biahub.tracking (#454) and call run_ultrack with keywords
- use segmentation_method: foreground_contour and output_mode
- project a 3D FOV in memory with the biahub project API (focus search plus
  per-channel projection), defaulting to the A549 project.yml window; a Z=1
  store is tracked as is
- match the blank-frames CSV with the B/1/000000 FOV form, as track does
- fix the mem_nuc_contour key here and in example_track_settings.yml

Closes #458
- show 3D tracks with their z column and a (1, *scale) scale, so they line
  up with the (T, Z, Y, X) layers instead of putting time on Z
- read the focus channel from focus_store_path when input_images[0] lacks it
  (a virtual-stain store has no Phase3D), and find the focus once
- project every input_images entry with a path, as biahub track loads them
- cast projections to float32 when any channel is mean/sum, as biahub project
- import napari only for the viewer, so spawned focus workers skip it
- fix the contradictory input-path comment and leftover typos
- update the track-with-biahub evaluation note about the script
@tayllatheodoro
tayllatheodoro marked this pull request as draft November 6, 2026 23:32

This branch has not been deployed

No deployments
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)

1 participant