Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tools/trackastra_galaxy/.shed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: trackastra_galaxy
owner: iuc
categories:
- Machine Learning
- Imaging
description: Track cell instances in time-lapse OME-Zarr datasets using Trackastra and Cellpose.
long_description: |
Trackastra-Galaxy is a wrapper around the Trackastra cell-tracking pipeline that supports
both segmentation+tracking and track-only workflows on time-lapse OME-Zarr datasets.
It can consume remote or local Zarr datasets and outputs a CTC track log plus per-frame mask images.
homepage_url: https://github.com/bioinfbrad/trackastra_galaxy
remote_repository_url: https://github.com/galaxyproject/tools-iuc/tree/main/tools/trackastra_galaxy
type: unrestricted

85 changes: 85 additions & 0 deletions tools/trackastra_galaxy/macros.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<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.

<token name="@PROFILE@">23.0</token>
Comment thread
SaimMomin12 marked this conversation as resolved.
Outdated
<token name="@VERSION_SUFFIX@">0</token>
<xml name="bio_tools">
<xrefs>
<xref type="bio.tools">trackastra-galaxy</xref>
</xrefs>
</xml>
<xml name="creators">
<creator>
<person givenName="Vladimír" familyName="Ulman" url="https://github.com/xulman" />
<person givenName="Khaled" familyName="Jum'ah" url="https://github.com/khaled196" />
<person givenName="Krzysztof" familyName="Poterlowicz" url="https://github.com/kpoterlowicz" />
<organization name="poterlowicz-lab" url="https://github.com/poterlowicz-lab" />
</creator>
</xml>
<xml name="input_source_params">
<conditional name="input_source">
<param name="input_source" type="select" label="Input source" help="Choose whether to use a URL or upload a local Zarr dataset">
<option value="url" selected="true">URL</option>
<option value="file">Local file</option>
</param>
<when value="url">
<param name="zarr_path" type="text" label="Zarr dataset URL" help="URL to OME-Zarr dataset. Can be https://, s3://. Example: https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0101A/13457537.zarr/0">
<sanitizer>
<valid initial="string.printable" />
</sanitizer>
<validator type="empty_field" message="Please provide a Zarr dataset URL."/>
<validator type="regex" message="Zarr dataset URL must start with http://, https://, or s3://">^(https?|s3)://.+$</validator>
</param>
</when>
<when value="file">
<param name="zarr_path" type="data" format="zarr" label="Zarr dataset file" help="Local Zarr dataset" />
</when>
</conditional>
</xml>

<xml name="requirements">
<requirements>
<requirement type="package" version="@TOOL_VERSION@">trackastra-galaxy</requirement>
<requirement type="package" version="3.1.1.3">cellpose</requirement>
<requirement type="package" version="0.5.3">trackastra</requirement>
<requirement type="package" version="2.0.2">numpy</requirement>
<requirement type="package" version="0.26.0">scikit-image</requirement>
<requirement type="package" version="0.14.0">ome-zarr</requirement>
</requirements>
</xml>

<xml name="common_tracking_params">
<param name="scale_level" type="integer" value="0" min="0" label="Pyramid scale level" help="Resolution level in zarr pyramid. 0=finest resolution (best quality but slower), higher numbers=lower resolution but faster processing"/>
<param name="downscale_x" type="float" value="1.0" min="0.1" label="Downscale factor X" help="Spatial downscaling for X dimension (1.0=no scaling, 2.0=half resolution). Useful for large images (500+ pixels) to speed up processing"/>
<param name="downscale_y" type="float" value="1.0" min="0.1" label="Downscale factor Y" help="Spatial downscaling for Y dimension (1.0=no scaling, 2.0=half resolution)"/>
<param name="downscale_z" type="float" value="1.0" min="0.1" label="Downscale factor Z" help="Spatial downscaling for Z dimension (1.0=no scaling, 2.0=half resolution) for 3D tracking"/>
<param name="start_tp" type="integer" value="0" min="0" label="Start time point" help="First frame to process (0-indexed). Use to test on subset of frames"/>
<param name="end_tp" type="integer" value="-1" label="End time point" help="Last frame to process. Use -1 to process all frames"/>
<param name="raw_channel_coords" type="text" value="0" label="Raw channel coordinate" help="For multi-dimensional zarr, specify coordinates to select the raw image channel. Space or comma-separated. Example: '0' or '0 1' for 6D data">
<sanitizer>
<valid initial="string.printable" />
</sanitizer>
<validator type="empty_field" message="Please provide raw channel coordinates."/>
<validator type="regex" message="Use one or more non-negative integers separated by spaces or commas, for example: 0 or 0 1 or 0,1">^\s*\d+(\s*[, ]\s*\d+)*\s*$</validator>
</param>
<param name="tracking_model" type="select" label="Tracking model" help="Trackastra model to use for tracking cells across frames">
<option value="ctc" selected="true">ctc - Default CTC model</option>
</param>
</xml>

<xml name="citations">
<citations>
<citation type="bibtex">@article{trackastra,
title={Trackastra: transformer-based cell tracking},
author={Theis, F. J. and others},
journal={Nature Methods},
year={2024}
}</citation>
<citation type="bibtex">@article{cellpose,
title={Cellpose: a generalist algorithm for cellular segmentation},
author={Stringer, C. and Wang, T. and others},
journal={Nature Methods},
year={2021}
}</citation>
</citations>
</xml>
</macros>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 1 2 0
Binary file not shown.
Binary file not shown.
30 changes: 30 additions & 0 deletions tools/trackastra_galaxy/test-data/track_only/man_track.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
1 0 2 0
2 0 2 0
3 0 1 0
4 0 1 0
5 0 2 0
6 0 1 0
7 0 2 0
8 0 1 0
9 1 2 0
10 1 2 0
11 1 2 0
12 1 2 0
13 1 2 0
14 1 2 0
15 1 2 0
16 1 1 0
17 1 2 0
18 1 2 0
19 1 1 0
20 1 2 0
21 1 2 0
22 1 2 0
23 1 2 0
24 1 2 0
25 1 2 0
26 1 2 0
27 2 2 16
28 2 2 16
29 2 2 19
30 2 2 19
Binary file not shown.
Binary file not shown.
157 changes: 157 additions & 0 deletions tools/trackastra_galaxy/trackastra_galaxy.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<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?

<description>with Trackastra Galaxy pipeline</description>
<macros>
<import>macros.xml</import>
</macros>
<expand macro="requirements" />
<expand macro="creators"/>
<command detect_errors="exit_code"><![CDATA[

mkdir -p result_directory &&

#if $method.input_source.input_source == "file"
ln -s '$method.input_source.zarr_path' ./file.zarr &&
#end if

trackastra-galaxy $method.mode
#if $method.input_source.input_source == "file"
--zarr-path ./file.zarr
#else
--zarr-path '$method.input_source.zarr_path'
#end if
--scale-level $method.scale_level
--raw-channel-coords '$method.raw_channel_coords'
#if $method.mode == 'track'
--seg-channel-coords '$method.seg_channel_coords'
#end if
--result-path ./result_directory
--downscale-x $method.downscale_x
--downscale-y $method.downscale_y
--downscale-z $method.downscale_z
--start-tp $method.start_tp
--end-tp $method.end_tp
--tracking-model '$method.tracking_model'
#if $method.mode == 'segment-and-track'
--segmentation-model '$method.segmentation_model'
--objects-diameter-px $method.objects_diameter_px
#end if
&& awk 'BEGIN{OFS="\t"} {print $1,$2,$3,$4}' result_directory/man_track.txt > result_directory/man_track.tsv
&& for f in result_directory/man_track*.tif; do mv "$f" "${f%.tif}.tiff"; done
]]></command>
<inputs>
<conditional name="method">
<param name="mode" type="select" label="Processing mode" help="Choose between segmentation+tracking or tracking only">
<option value="segment-and-track" selected="true">Segment cells and track (Cellpose v3 + Trackastra)</option>
<option value="track">Track only (requires pre-segmented data)</option>
</param>
<when value="segment-and-track">
<expand macro="input_source_params" />
<expand macro="common_tracking_params" />
<param name="segmentation_model" type="select" label="Segmentation model" help="Cellpose v3 model to use for cell/nuclei detection">
<option value="cyto3" selected="true">cyto3 - Cytoplasm</option>
<option value="cyto2">cyto2 - Cytoplasm (older model)</option>
<option value="nuclei">nuclei - Nuclei only</option>
</param>
<param name="objects_diameter_px" type="integer" value="25" min="1" label="Object diameter (px)" help="Expected object diameter in pixels for Cellpose v3 segmentation"/>
</when>
<when value="track">
<expand macro="input_source_params" />
<expand macro="common_tracking_params" />
<param name="seg_channel_coords" type="text" value="1" label="Segmentation channel coordinate" help="For multi-dimensional zarr, specify coordinates to select the segmentation channel. Space or comma-separated. Example: '1' or '0 1' for 6D data">
<sanitizer>
<valid initial="string.printable" />
</sanitizer>
<validator type="empty_field" message="Please provide a Zarr dataset URL."/>
<validator type="regex" message="Use one or more non-negative integers separated by spaces or commas, for example: 1 or 0 1 or 0,1">^\s*\d+(\s*[, ]\s*\d+)*\s*$</validator>
</param>
</when>
</conditional>
</inputs>
<outputs>
<data name="output_ctc_tracklog" format="tsv" from_work_dir="result_directory/man_track.tsv" label='${tool.name} on ${on_string}: CTC track log'/>
<collection name="output_ctc_masks" type="list" label='${tool.name} on ${on_string}: CTC mask images'>
<discover_datasets
pattern="(?P&lt;designation&gt;man_track\d+)\.tiff"
format="tiff"
visible="true"
directory="result_directory" />
</collection>
</outputs>
<tests>
<test expect_num_outputs="2">
<conditional name="method">
<param name="mode" value="segment-and-track"/>
<conditional name="input_source">
<param name="input_source" value="url"/>
<param name="zarr_path" value="https://s3.cl2.du.cesnet.cz/35b9fef6_a5c7_4724_b7ad_0db97899a356:public/CTC_trif_01_cropped_2channels_v04.zarr"/>
</conditional>
<param name="scale_level" value="3"/>
<param name="downscale_x" value="1.0"/>
<param name="downscale_y" value="1.0"/>
<param name="downscale_z" value="1.0"/>
<param name="start_tp" value="0"/>
<param name="end_tp" value="2"/>
<param name="raw_channel_coords" value="0"/>
<param name="segmentation_model" value="cyto3"/>
<param name="objects_diameter_px" value="25"/>
<param name="tracking_model" value="ctc"/>
</conditional>
<output name="output_ctc_tracklog" file="segment_and_track/man_track.tsv" ftype="tsv"/>
<output_collection name="output_ctc_masks" type="list" count="3"/>
</test>

<test expect_num_outputs="2">
<conditional name="method">
<param name="mode" value="track"/>
<conditional name="input_source">
<param name="input_source" value="url"/>
<param name="zarr_path" value="https://s3.cl2.du.cesnet.cz/35b9fef6_a5c7_4724_b7ad_0db97899a356:public/CTC_trif_01_cropped_2channels_v04.zarr"/>
</conditional>
<param name="scale_level" value="3"/>
<param name="downscale_x" value="1.0"/>
<param name="downscale_y" value="1.0"/>
<param name="downscale_z" value="1.0"/>
<param name="start_tp" value="0"/>
<param name="end_tp" value="2"/>
<param name="raw_channel_coords" value="0"/>
<param name="seg_channel_coords" value="1"/>
<param name="tracking_model" value="ctc"/>
</conditional>
<output name="output_ctc_tracklog" file="track_only/man_track.tsv" ftype="tsv"/>
<output_collection name="output_ctc_masks" type="list" count="3"/>
</test>
</tests>
<help><![CDATA[
**Trackastra: Deep Learning-based Cell Tracking in Zarr Datasets**

This tool performs automated cell instance tracking in time-lapse OME-Zarr (NGFF) datasets. It supports two workflows:

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)
Comment on lines +142 to +143
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 👍 )


**Input Sources**

Choose between URL or local Zarr dataset:

- **URL**: HTTP/HTTPS or S3 path to remote OME-Zarr dataset
- **Local file**: Upload or select a local Zarr dataset directory

**Key Parameters**

- **scale_level**: Pyramid resolution level. 0 is finest resolution.
- **Downscale factors (x, y, z)**: Additional spatial downscaling to speed up processing.
- **Time point range**: start_tp and end_tp select the processed frames.
- **Raw/segmentation channel coordinates**: Use space- or comma-separated coordinates for non-tzyx dimensions.

**Outputs**

The tool writes its results into an internal result directory named `result_directory`.
Galaxy exposes the key result files from this directory as outputs:

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

These are exposed as Galaxy outputs for downstream analysis.
]]></help>
<expand macro="citations" />
</tool>
Loading