Skip to content

track: write tracks.geff for every tracker, not only ultrack #441

Open

Description

@ieivanov

Follow-up to #427 (choose the tracker: ultrack, tracksdata, HOCT or Trackastra), part of #361.

Problem

After #413, biahub track writes tracks.geff next to the tracked labels, and VisCy (Biohub/VisCy#525) and the DCA layout (#363) read it. The GEFF comes from ultrack's Tracker.to_geff(tracks_df=...) (royerlab/ultrack#290). That export reads node positions and properties from ultrack's own solution database, so it can't export another tracker's results. With #427 merged, tracker: tracksdata | hoct | trackastra write the tracked labels and tracks_<fov>.csv but no tracks.geff, and they remove a stale one left by an earlier ultrack run. VisCy falls back to the CSV, but such a store doesn't meet the #361 contract.

Proposal

Add a tracker-independent GEFF writer that works from the final tracks table, i.e. after the sibling filter and the one-child merge. That table is what the labels are painted from, so the GEFF can't disagree with them.

  • Nodes: one per row (track_id, t, y, x[, z]), with seg_id = track_id (the painted value), parent_track_id, and lineage_id (the root track).
  • Edges: consecutive rows within a track, plus each daughter's first row to its parent's last row.
  • Metadata: the same as the ultrack export, so readers can't tell them apart:
    • track_node_props = {tracklet: track_id, lineage: lineage_id};
    • related_objects = [{type: labels, path: ../labels/<tracked_label>, node_prop: seg_id}];
    • axes in pixels/frames with scale/scaled_unit from the plate;
    • zarr v3.
  • Implementation options:
    • geff.write on a networkx DiGraph built from the table;
    • geff.core_io.write_arrays directly, which avoids networkx and handles large FOVs;
    • for tracksdata/HOCT, tracksdata's own BaseGraph.to_geff. But the solved graph doesn't reflect the post-solve edits, so the table is the safer source.
  • Optional: use the same writer for ultrack too, so all trackers share one export path and biahub no longer depends on the ultrack fork (feat(tile_stitch): honour monarch.recon_dtype as the stored output dtype #290) for it. The ultrack-only node properties (area, frontier, bbox) would be dropped.
  • Validation: check the result with geff.validate_structure and full data validation (graph, tracklet, lineage), like the ultrack export's tests.

Alternative: contribute to_geff upstream to tracksdata, Trackastra and HOCT

Rather than (or as well as) a biahub writer, the export could live in the trackers themselves, as royerlab/ultrack#288 and #290 did for ultrack. Two of the three already have a GEFF export, but neither produces what biahub writes for ultrack:

today missing for biahub
tracksdata BaseGraph.to_geff(store, geff_metadata=None, overwrite, zarr_format=3) writes the whole graph (candidate nodes and edges too, with the solution attribute); axes t, (z), y, x; tracklet node prop tracklet_id export only the solution; lineage_id + track_node_props; seg_id = the value painted into the labels; related_objects pointing at an external label image; axis units/scale
HOCT (hoct.predict returns a tracksdata RustWorkXGraph) inherits tracksdata's to_geff same as tracksdata; nothing HOCT-specific once tracksdata has it
Trackastra trackastra.tracking.write_to_geff(graph, masks, outdir, ...) writes the graph and its own copy of the masks into one zarr an option to skip the masks and link an existing label image (related_objects), tracklet/lineage props, seg_id matching graph_to_ctc's relabelled masks, axis units/scale, zarr v3

Suggested contributions, mirroring ultrack's to_geff keyword arguments so callers handle every tracker the same way (zarr_format, include_masks, segmentation_path, scale, spatial_unit, time_scale, time_unit):

  • tracksdata: extend to_geff with a solution-only export, lineage and seg_id props, track_node_props, related_objects and units/scale. HOCT gets it for free.
  • Trackastra: the same options on write_to_geff, including writing no masks when an external label image is linked.
  • tracks_df=-style override: biahub edits the tracks after solving (sibling filter, one-child merge), as ultrack's filter_short_sibling_tracks does. Each export would need a way to restrict and relabel to the final table, like Export GEFF from a tracks DataFrame (consistent with filter_short_sibling_tracks) royerlab/ultrack#290's tracks_df=, so the GEFF matches the labels.

Trade-off: upstream exports help everyone who uses those tools directly, but biahub would depend on three more upstream releases, and still needs the tracks_df-style hook. The biahub writer above covers all trackers immediately. The two aren't exclusive: biahub can ship its writer now and switch tracker by tracker as upstream exports gain these options.

Acceptance

biahub track with any tracker: writes <stem>.geff that passes geff validation, whose seg_ids per frame equal the tracked label values, and that VisCy#525's reader turns into the same table as the CSV.

Activity

  1. ieivanov commented on Oct 26, 2026

    @ieivanov
    CollaboratorAuthor

    I would prefer we contribute to_geff methods upstream. The Royer lab may chose to develop a small geff writer, instead of maintaining methods in each repo.

  2. tayllatheodoro commented on Oct 27, 2026

    @tayllatheodoro
    Collaborator

    Agreed on upstream. A note on what the libraries already have (installed versions in the track extra), and the catch for a shared writer:

    tracker GEFF writer in its own library
    ultrack Tracker.to_geff / ultrack.core.export.geff.to_geff (biahub uses it through your fork, which takes the final tracks_df)
    tracksdata BaseGraph.to_geff(geff_store, geff_metadata=None, overwrite=False, zarr_format=3). HOCT's solutions are tracksdata graphs too, so this covers both
    Trackastra trackastra.tracking.utils.write_to_geff(...)

    The catch: biahub edits the tracks after the tracker. It merges one-child links into their parent and applies the sibling filter (min_sibling_length), and with #446 it also maps tracks found on downsampled labels back to full resolution. A GEFF written from a tracker's raw output would then disagree with the labels/tracks_<labels> and the CSV biahub writes. So the writer needs to start from the final tracks table plus the tracked labels, as your ultrack fork does with tracks_df.

    One option for the small shared writer: build a tracksdata graph from the final tracks table and labels (nodes = (t, track_id) objects with their masks, edges = consecutive frames of a track plus parent -> daughter links), then call its to_geff. That would make one code path for all four trackers, with seg_id linking each node to the labels.

  3. tayllatheodoro commented on Oct 27, 2026

    @tayllatheodoro
    Collaborator

    @ieivanov we like the shared-writer option: build a tracksdata graph from biahub's final tracks table and tracked labels, then call its to_geff.

    Would you put it in tracksdata (e.g. a "tracks table + labels -> graph" constructor) so other projects can reuse it, or start in biahub? We're happy to write it either way. If biahub, it fits the tracking/postprocess.py of #449.

  4. ieivanov commented on Nov 2, 2026

    @ieivanov
    CollaboratorAuthor

    @tayllatheodoro yes, the idea is to "build a tracksdata graph from the final tracks table and labels (nodes = (t, track_id) objects with their masks, edges = consecutive frames of a track plus parent -> daughter links), then call its to_geff". Please consult with @JoOkuma on where that should live, preferrably not in biahub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions