Skip to content

Add Trackastra-Galaxy to perform object tracking with Trackastra#7893

Open
khaled196 wants to merge 14 commits into
galaxyproject:mainfrom
khaled196:trackastra
Open

Add Trackastra-Galaxy to perform object tracking with Trackastra#7893
khaled196 wants to merge 14 commits into
galaxyproject:mainfrom
khaled196:trackastra

Conversation

@khaled196

@khaled196 khaled196 commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

FOR CONTRIBUTOR:

  • I have read the CONTRIBUTING.md document and this tool is appropriate for the tools-iuc repo.
  • License permits unrestricted use (educational + commercial)
  • This PR adds a new tool or tool collection
  • This PR updates an existing tool or tool collection
  • This PR does something else (explain below)

There are two labels that allow to ignore specific (false positive) tool linter errors:

  • skip-version-check: Use it if only a subset of the tools has been updated in a suite.
  • skip-url-check: Use it if github CI sees 403 errors, but the URLs work.

@khaled196 khaled196 marked this pull request as draft April 14, 2026 14:35
@khaled196 khaled196 changed the title Trackastra Add Trackastra-Galaxy Apr 14, 2026
Comment thread tools/trackastra_galaxy/trackastra_galaxy.xml Outdated
Comment thread tools/trackastra_galaxy/trackastra_galaxy.xml Outdated
@khaled196 khaled196 marked this pull request as ready for review April 15, 2026 14:36
@khaled196 khaled196 changed the title Add Trackastra-Galaxy Add Trackastra-Galaxy to perform object tracking with Trackastra Apr 15, 2026
@@ -0,0 +1,81 @@
<macros>
<token name="@TOOL_VERSION@">1.0.1</token>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the main package here (the one that implements the main functionallity) is trackastra, not trackastra-galaxy, right? In that case:

Suggested change
<token name="@TOOL_VERSION@">1.0.1</token>
<token name="@TOOL_VERSION@">0.5.3</token>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main package is tracksatra-galaxy https://github.com/bioinfbrad/trackastra-galaxy.

The tool itself is a pipeline that automates and orchestrates the process of running Trackastra on Galaxy's servers, allowing users to process large datasets efficiently

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. In that case I need to revise the comment that I previously made here, the description of the tool should rather be with Trackastra Galaxy Tool, assuming from PyPI that the name of the package actually is Trackastra Galaxy Tool.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming of the tool is peculiar.... It is a tool for tracking (and segmenting) that features Trackastra (and Cellpose) and came to being only specifically for Galaxy. In its journey to possibly become a Galaxy node, it got published on PyPI as a package in its own right (currently at version 1.0.1) -- this is what we're trying to turn into a Galaxy node.

The PyPI package is basically an adapter around Trackastra (and Cellpose) to

  • read OME-Zarrs, and
  • save into CellTrackingChallenge format,
  • exposing both Python API and CLI for Galaxy.

For the PyPI, it needed to have a name, which perhaps unfortunately ended up being trackastra-galaxy to reflect what its main star is and what it is meant for...

In Galaxy itself, it could probably be named better, e.g., "tracking cells with Trackastra".... I'm open to anything.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file actually used in the tests? Couldn't find it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generated the files during tests and then removed the script. I considered leaving them for potential future use.

Galaxy exposes the key result files from this directory as outputs:

- **man_track.tsv**: CTC track log converted to tab-separated format
- **man_trackNNNN.tif**: Frame-wise mask images

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use .tiff instead of .tif FAIR-imaging/galaxy-image-community#43

unless this contradicts some IUC policy?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.... but the output is strictly according to the Cell Tracking Challenge format that mandates the use of .tif (not .tiff).

For example, any challenge tool would not recognize tiff-named files (I'm the author of several such tools, that's how I know). But there are 3rd party tools that may work with tiff-named files and that are far more important for the world than the official tools from CTC :-) (perhaps we don't need to be compatible with the CTC tools).

....maybe CTC should be more flexible on this in the future. But now, unf., .tif is what it should be.

Comment on lines +128 to +129
1. **Segment and Track**: Automatically segments cell instances using Cellpose v3, then performs tracking using Trackastra
2. **Track Only**: Performs tracking on pre-segmented data (segmentation provided by other tools)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In terms of maintainability, what's the advantage of providing mode (1) here?

Isn't it sufficient to only provide (2), since Cellpose v3 is already available in Galaxy?

My concern is that by "including" Cellpose v3 in this tool, a redundancy is introduced that at some point will require extra maintenance work. So if there is no real advantage, it might be better to focus on (2).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good point.

The original goal of the package indeed is to be able to track nuclei/cells, not really to segment them.

However, the tracking engine (Trackastra) itself needs both segmentation and raw data, both must be provided (and must be consistent to each other).

If the user comes with just the raw data, I wanted to give them this segmentation opportunity to just let it happen on the fly, because

  • to run this segmentation today is just very easy (programatically), and
  • it is somewhat safe to run it internally in the sense that the segmentation input will then for sure fit the raw input in spatial and temporal size/dimensions and content (assuming segmentation went okayish), and
  • this tool was also about featuring the OME-Zarr and I don't if users can produce their segmentation and serve them in the OME-Zarr (that said, if we ask only to provide segmentation as TIFFs, we would get OME-Zarr raw input + TIFF mask input).

I'm okay to drop the segment+track regime and leave it only with the tracking mode.

I'm okay to modify the tool such that two input streams (a time-lapse for raw data; a time-lapse for segmentation masks) would be two explicit inputs to the node.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, as I'm thinking abourt it and how to improve its chance to be integrated into any workflow -->> I don't even insist on OME-Zarr :) We could brainstorm and figure out how to do both ways... to be able to read OME-Zarras well as TIFFs.

(In the code it is not a big deal... there is a reading section that massages the input, and then there is the tracking itself... I could easily have two reading sections, one for OME-Zarr, and one for TIFFs... no problem 👍 )

Comment on lines +50 to +52
<option value="cyto3" selected="true">cyto3 - Cytoplasm (recommended)</option>
<option value="cyto2">cyto2 - Cytoplasm (older model)</option>
<option value="nuclei">nuclei - Nuclei only</option>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the Cytoplasm model recommended? Isn't it a matter of the analysis task whether nuclei or cytoplasm are subject of the analysis?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a wording issue as cyto3 is the default. I have removed the term "recommended" from the text. I will also curate the rest of the help text to avoid this issue in the future.

Comment thread tools/trackastra_galaxy/macros.xml Outdated
@xulman

xulman commented Apr 17, 2026

Copy link
Copy Markdown

Guys, MANY THANKS for your effort.

I'm very much open to adopting the tool if need be.

There is now a question whether a time-lapse collection (or whatever is the Galaxy counterpart/term to represent this) should be accepted as an input to the tool, and whether two such inputs should be there (in the case we would drop the auto-segmentation regime).

Eventually, as I think is apparent from the discussion above, Galaxy developers would need to address how to represent the tracking...

@bernt-matthias bernt-matthias left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By IUC guidelines subcommands should be wrapped in different tools.

This would also apply here.

@@ -0,0 +1,156 @@
<tool id="trackastra_galaxy" name="Perform object tracking" version="@TOOL_VERSION@+galaxyy@VERSION_SUFFIX@" profile="@PROFILE@">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name would then also be more fitting, since 1 of the tools does segmentation, or?

@xulman

xulman commented Apr 20, 2026

Copy link
Copy Markdown

OK to remove the subcommand (the segmentation).

Before I do any programming: How shall this tool be designed now w.r.t. inputs? Let me remind that this tool was also meant to be a demonstrator of using/consuming OME-Zarrs. And I don't expect that Galaxy users today can create new OME-Zarrs with segmentation results (*), nor extend the original (raw) OME-Zarrs (to have one Zarr with two channels - raw and seg).

(*) They can certainly create TIFFs with segmentation. But when this lands on Galaxy storage, it makes no sense to repack/resave it into OME-Zarr....

I guess I would modify the tool as follows:

  • Remove the segment-and-track subcommand and all its parameters.
  • Change input parameters:
    • to provide raw data:
      • --raw-tiffs-input-path (assumes single channel tiffs)
      • --raw-ome-zarr-input-path and --raw-scale-level and --raw-channel-coords
      • User is expected to use either tiffs or ome-zarr exclusively. If both are provided, it stops and complains (and educates the user via the error message).
    • to provide segmentation data:
      • --mask-tiffs-input-path (assumes single channel tiffs)
      • --mask-ome-zarr-input-path and --mask-channel-coords (note there's no scale parameter!)
      • User is expected to use either tiffs or ome-zarr exclusively. If both are provided, it stops and complains.

The tool would support all four combinations of input file formats: (T,T) (T,Z) (Z,T) (Z,Z). The duality of input types (T or Z) should make it easier to integrate this tool into current Galaxy workflows (that are mostly based around Ts). T = tiffs, Z = ome-zarr.

Raw channel defines the tracking resolution (image size in pixels) at which the tracking will happen (this is given either by the tiffs themselves, or with the zarr+scale). Mask channel with tiffs, will be auto-resized to match the tracking resolution. Mask channel with zarr, will auto-choose the nerest better zarr pyramid level and auto-resize to the tracking resolution. Result will be stored at the tracking resolution.

When reading tiffs, I expect a path to a folder that contains the tiffs. The code would internally list all *.tiff files in the given folder, and lexicographically sort according to their names, and take/consume them in this order. The parameter --start-tp N will simply skip the first N files. The tool will not try to make any sense of the tiff file names, it will not try to guess what time points do the individual tiff files represent.

The tiff input path must point to some Galaxy storage. zarr input path can be either the storage or any URL to some hosted zarr...

@bernt-matthias @kostrykin Are you, please, okay with this plan?

@xulman

xulman commented Apr 20, 2026

Copy link
Copy Markdown

@khaled196 the proposed changes above would only need from you to change the facade xml (and release updated version on Pypi).
I'm okay to change the guts of the plugin and README myself and ASAP...

but only after we confirm the plan so that we don't iterate too many times :-P

@bernt-matthias

Copy link
Copy Markdown
Contributor

The plan sounds reasonable to me. But I'm not an expert in the area. Most important point seems to be that it plays nicely with the outputs of the cellpose Galaxy tool.

@bernt-matthias

Copy link
Copy Markdown
Contributor

But note that I would also be fine with just splitting the tool into two tools (one for each branch of the conditional) .. but the outlined plan seems even better.

@xulman

xulman commented Apr 20, 2026

Copy link
Copy Markdown

Yes, since there is already a Cellpose node and one usually wants to post-filter the automatic segmentation results, it is indeed better to perform the segmentation in a workflow and only then wire it to this tracking tool. I trust that the above outlined plan should support this, just like @bernt-matthias is saying.

@kostrykin do I get a green light from you as well?? no pressure :-)

@kostrykin

Copy link
Copy Markdown
Contributor

I'm not that firm with the whole Zarr topic, but as long as the tool supports arbitrary combinations of Zarr and TIFF, it sounds reasonable to me.

When reading tiffs, I expect a path to a folder that contains the tiffs. The code would internally list all *.tiff files in the given folder, and lexicographically sort according to their names, and take/consume them in this order. The parameter --start-tp N will simply skip the first N files. The tool will not try to make any sense of the tiff file names, it will not try to guess what time points do the individual tiff files represent.

Why this inconsistency with Zarrs? Wouldn't it be clearer if a single multi-frame TIFF was consumed, instead of requiring a series of single-frame TIFFs? Keeping it consistent will also ease establishing input validators.

For start/end parameters I think it's very handy to also allow supplying negative values, to count from the end of the sequence (e.g., --start-tp -10 to process the last 10 frames of the sequence). Please consider this, unless it causes too much headaches.

@xulman

xulman commented Apr 20, 2026

Copy link
Copy Markdown

For start/end parameters I think it's very handy to also allow supplying negative values, to count from the end of the sequence (e.g., --start-tp -10 to process the last 10 frames of the sequence). Please consider this, unless it causes too much headaches.

This is a super good idea! I'll gladly add it there.

@xulman

xulman commented Apr 20, 2026

Copy link
Copy Markdown

Wouldn't it be clearer if a single multi-frame TIFF was consumed, instead of requiring a series of single-frame TIFFs?

Hmm... are we also considering processing 3D+t data?

The huge TIFF (for 3D+t) would need to be somewhat 4D... yes.. It is a matter of one extra "stride" to split "very deep 3D" to 3D+t, but also very non-standard, no?


Regarding OME-Zarr, I'm okay to throw it over the board at all. It was Bea and Arrate's invention to base it specifically around the OME-Zarr. But apparently, it is not fitting to the Galaxy env (yet).

@xulman

xulman commented Apr 20, 2026

Copy link
Copy Markdown

Why this inconsistency with Zarrs? Wouldn't it be clearer if a single multi-frame TIFF was consumed, instead of requiring a series of single-frame TIFFs?

I was thinking:

  • single-frame TIFF to hold a 2D image at one particular time point
  • multi-frame TIFF to hold a 3D image at one particular time point
  • have a series of these, a folder with files, to represent time-lapse data

@kostrykin

kostrykin commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

The huge TIFF (for 3D+t) would need to be somewhat 4D... yes.. It is a matter of one extra "stride" to split "very deep 3D" to 3D+t, but also very non-standard, no?

AFAIK neither TIFF nor OME-TIFF have explicit limitations on the number of axes/dimensions for the array, so TZYX should be perfectly legal. I think, the advantage of using a single TYX or TZYX is that you don't have to care about the order of the timepoints, they are already encoded in the file structure. If the user comes with a series of separate files, it would be in the responsibility of the user to establish a proper order when concatenating the timepoints into a single file (as opposed to trying to deduce the order of lexicographically which sounds rather heuristic).

But I also see the disadvantage, that the file might become very large. What's the IUC standpoint here, are many small files advantages over a single large/huge file, or rather disadvantages? @bernt-matthias

@xulman: If you decide to use multiple files, I think you should use the order of the list (collection) rather than lexicographical order.

Regarding OME-Zarr, I'm okay to throw it over the board at all. It was Bea and Arrate's invention to base it specifically around the OME-Zarr. But apparently, it is not fitting to the Galaxy env (yet).

@beatrizserrano ping

@xulman

xulman commented Apr 20, 2026

Copy link
Copy Markdown

@xulman: If you decide to use multiple files, I think you should use the order of the list (collection) rather than lexicographical order.

I would wait for @bernt-matthias' opinion on one-huge vs. many-smaller.

My opinion on that is that

  • I haven't seen this model very often, in fact I'm (honestly) pretty scared about 4D tiffs :) -- but that doesn't mean a thing :)
  • Thinking of the --start-tp and --end-tp parameters: If I were to test the node/tool on some limited number of time points in the middle of the time lapse, wouldn't I still need to load the full 4D?

(but, I agree, having all governed within one file (and its standard) is removing some pain and assumptions from our coding, that's always nice :))

I have to learn (look around) how collections are fed into Galaxy nodes -- I was a believer until now :) that it is merely a folder, and then my tool gets a path to it. It sounds now that the collection "mechanism" is somehow giving/feeding me with paths to the individual files... or? Do you please happen to know, @kostrykin ? (would help me a lot to geting a quick pointer).

@bernt-matthias

Copy link
Copy Markdown
Contributor

I have to learn (look around) how collections are fed into Galaxy nodes -- I was a believer until now :) that it is merely a folder, and then my tool gets a path to it.

It's not a folder, but a collection of (links to) individual datasets.

Something behaving more like a directory is the directory datatype.

@kostrykin

Copy link
Copy Markdown
Contributor

I haven't seen this model very often, in fact I'm (honestly) pretty scared about 4D tiffs :) -- but that doesn't mean a thing :)
Thinking of the --start-tp and --end-tp parameters: If I were to test the node/tool on some limited number of time points in the middle of the time lapse, wouldn't I still need to load the full 4D?

Just wait until you see 6-D TIFFs :) but yes, AFAIK the whole hyperstack needs to be loaded.

@xulman

xulman commented Apr 20, 2026

Copy link
Copy Markdown

Many thanks, @bernt-matthias, for the explanation. Pardon me, please, one more question:

It's not a folder, but a collection of (links to) individual datasets.

So, e.g., my proposed --raw-tiffs-input-path (expected parameter value was a path to a directory) would become --raw-tiffs-input-paths and the values are(?) space-separated paths to individual (tiff) files?

Is Galaxy's dataset equivalent to a single file?

(I'm sorry, I'm very new to this...)

@bernt-matthias

Copy link
Copy Markdown
Contributor

It's not a folder, but a collection of (links to) individual datasets.

So, e.g., my proposed --raw-tiffs-input-path (expected parameter value was a path to a directory) would become --raw-tiffs-input-paths and the values are(?) space-separated paths to individual (tiff) files?

You could create a folder in the working dir and symlink all datasets into the folder.

Is Galaxy's dataset equivalent to a single file?

Yes.

(I'm sorry, I'm very new to this...)

No worries.

@xulman

xulman commented Apr 20, 2026

Copy link
Copy Markdown

[ sharing a thought:

I'm ATM more leaning towards creating a dedicated

  • node to extract from OME-Zarr a collection of TIFFs
  • change this node to consume only a collection of TIFFs
  • (and for the symmetry)
    • node to create empty OME-Zarr
    • node to fill/provide_content for OME-Zarr from a collection of TIFF

Rather than having this node "super fat" (in what all input combinations it is consuming). Plus this "pulling of TIFFs" from OME-Zarr could be beneficial for many nodes. What do you think?
]

@kostrykin

Copy link
Copy Markdown
Contributor

[ sharing a thought:

I'm ATM more leaning towards creating a dedicated

  • node to extract from OME-Zarr a collection of TIFFs

  • change this node to consume only a collection of TIFFs

  • (and for the symmetry)

    • node to create empty OME-Zarr
    • node to fill/provide_content for OME-Zarr from a collection of TIFF

Rather than having this node "super fat" (in what all input combinations it is consuming). Plus this "pulling of TIFFs" from OME-Zarr could be beneficial for many nodes. What do you think? ]

I think this is best judged by @jburel. Could you maybe have a quick look?

@jburel

jburel commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

It looks like my previous comment was not posted.
Converting OME-Zarr into a collection of TIFF is not really supporting the format.
Analytical framework like https://fractal-analytics-platform.github.io/ reads and writes OME-Zarr.
This PR was driven by the paper if I am not mistaken. I don't think that it will make a strong point for Galaxy if we use OME-Zarr to Tiff approach suggested
We discussed in the paper the efforts to work towards true support of OME-Zarr in Galaxy

@xulman

xulman commented Apr 22, 2026

Copy link
Copy Markdown

Many thanks for your opinion @jburel

Then, I think, it is clear that the tool must use

  • OME-Zarr for raw inputs,
  • for the segmentation inputs
    • either OME-Zarr
    • or TIFFs (as segmentation will not happen inside this tool, and outside it is still more likely that it would come in as TIFFs)

The discussion whether to use one multi-frame TIFF or a series of single-frame TIFFs is resolved as the OME-Zarr expresses clearly the shape of the input data (if it is 2D+t or 3D+t), and so the TIFF I/O for the segmentation data can easily recognize if it is facing multi- or single-frame TIFF(s). And it could silently support both formats....

For this tool, I'm proposing to be unable to read TIFFs as an input for the raw channel/data.
Instead, I'm willing to contribute TIFFs to OME-Zarr conversion node... shall I? (in the spirit of increasing the use of OME-Zarrs in Galaxy).

Are we good on this plan? :-)

(not pushing, only trying to drive constructively forward :-) )

@xulman

xulman commented Apr 22, 2026

Copy link
Copy Markdown

...and I would make it create either CTC format or GEFF -- user can choose, default GEFF
in the spirit of this discussion

@kostrykin

Copy link
Copy Markdown
Contributor

Thanks for your input @jburel!

The discussion whether to use one multi-frame TIFF or a series of single-frame TIFFs is resolved as the OME-Zarr expresses clearly the shape of the input data (if it is 2D+t or 3D+t), and so the TIFF I/O for the segmentation data can easily recognize if it is facing multi- or single-frame TIFF(s). And it could silently support both formats....

Sounds good.

For this tool, I'm proposing to be unable to read TIFFs as an input for the raw channel/data. Instead, I'm willing to contribute TIFFs to OME-Zarr conversion node... shall I? (in the spirit of increasing the use of OME-Zarrs in Galaxy).

We already have that, no? https://usegalaxy.eu/?tool_id=toolshed.g2.bx.psu.edu/repos/imgteam/bioformats2raw/bf2raw

...and I would make it create either CTC format or GEFF -- user can choose, default GEFF

Sounds good, but actually I think it would be sufficient to confine yourself to just one. Maybe GEFF?

@xulman

xulman commented Apr 22, 2026

Copy link
Copy Markdown

We already have that... bioformats..

Yes, that tool can convert pretty much anything into OME-Zarr. It's probably easy to use. I saw some easy examples, but can't certify as I'm not using it myself.

And, I'd be happy if I didn't have to write another tool now :)

GEFF vs CTC

Well, I used to use GEFF circa one month ago, and it wasn't working well for me. But CTC was. However, GEFF should be the future :) ....so I thought, let's offer it to the users, but let's also offer them CTC as a backup solution. Just in case.

@xulman

xulman commented May 27, 2026

Copy link
Copy Markdown

Dear Friends,

FYI @khaled196 , @kostrykin

Just an update from my side: I'm still interested in finishing this one (semester finished only last week; teaching duties towards the end kept killing me).

Second, I reworked the code (already some weeks ago) to meet what we discussed above. Pending is to double-check and test thoroughly, then to update the "facade" .xml(s) to make it talk to Galaxy. And then it should be good for your testing.

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.

6 participants