Automatic cell tracking for time-lapse microscopy using TrackAstra, a deep learning-based tracking framework. This processing function tracks cells across time points in segmented label images, maintaining consistent object IDs throughout the time series.
- Deep Learning-Based Tracking: Uses pre-trained TrackAstra models
- 2D and 3D Support: Handles both TYX and TZYX time-lapse data
- Multiple Tracking Modes: Greedy, ILP (Integer Linear Programming), and no-division modes
- Automatic Environment Management: Creates a dedicated conda environment for TrackAstra
- Flexible Input: Works with both raw images and pre-segmented label images
TrackAstra runs in a dedicated conda environment that is automatically created when first used. The environment includes:
- TrackAstra
- ILP solver (ilpy)
- PyTorch
- scikit-image
- tifffile
These will be automatically installed into a dedicated trackastra-env environment when first used.
TrackAstra model selection:
-
"ctc": Cell Tracking Challenge model- Optimized for cell tracking benchmarks
- Good for standard cell tracking scenarios
- Trained on diverse cell types from CTC datasets
-
"general_2d": General-purpose 2D tracking model- More generic, works across various cell types
- Good fallback if ctc model doesn't work well
Tracking algorithm mode:
-
"greedy": Fast greedy linking (default)- Fastest option
- Good for most applications
- Allows cell divisions
- May miss some complex tracking scenarios
-
"ilp": Integer Linear Programming- Most accurate but slower
- Globally optimal solutions
- Better for complex scenarios with many cells
- Requires ILP solver (ilpy)
-
"greedy_nodiv": Greedy without divisions- Fast like greedy
- Does not allow cell divisions
- Use when cells don't divide during imaging
Pattern to identify label images in filenames.
Use cases:
- When processing raw images: Plugin looks for corresponding label files with this pattern
- When processing label images: Plugin identifies paired raw images
Examples:
"_labels.tif": Matchessample_labels.tif"_mask.tif": Matchessample_mask.tif"_segmentation.tif": Matchessample_segmentation.tif
- Time-series label images: Already segmented with Cellpose, manual annotation, or other methods
- At least 2 timepoints: Tracking requires temporal information
- Matching dimensions: All timepoints must have the same spatial dimensions
- Open Plugins > T-MIDAS > Image Processing
- Browse to your folder containing label images
- Use the suffix filter to select label files (e.g.,
_labels.tif) - Select "TrackAstra Tracking" from the processing function dropdown
- Configure parameters:
- Choose
modelbased on your data - Select
mode(start with "greedy") - Set
label_patternto match your label file naming
- Choose
- Click "Start Batch Processing"
Step 1: Segment cells (Cellpose or manual)
Input: raw_image.tif (TZYX or TYX)
Output: raw_image_labels.tif
Step 2: Track cells (TrackAstra)
Input: raw_image_labels.tif
Parameters:
- model: "ctc"
- mode: "greedy"
- label_pattern: "_labels.tif"
Output: raw_image_tracked.tif
experiment_folder/
├── sample001.tif # Raw time-lapse image
├── sample001_labels.tif # Segmented labels (from Cellpose/other)
├── sample002.tif
├── sample002_labels.tif
└── ...
- TYX: 3D array (Time, Y, X) - 2D time series
- TZYX: 4D array (Time, Z, Y, X) - 3D time series
- Minimum 2 timepoints for tracking
- Label images: Instance segmentation with unique IDs per object per timepoint
- Consistent dimensions: All timepoints must have same spatial size
- uint8, uint16, uint32 label images supported
- Background should be 0
- Each object should have a unique positive integer ID
Suffix: _tracked
The function produces tracked label images where:
- Each cell maintains a consistent ID across all timepoints
- Cell divisions are handled (in "greedy" and "ilp" modes)
- Output dimensions match input dimensions (TYX → TYX, TZYX → TZYX)
- Background remains 0
TrackAstra assigns consistent IDs such that:
- Cell at time t=0 with ID=5 keeps ID=5 at t=1, t=2, etc.
- Daughter cells from divisions get new unique IDs
- Lost/appeared cells get new IDs
- Start with
"ctc"for standard cell tracking - Try
"general_2d"if ctc doesn't work well - Model choice depends on cell morphology and imaging conditions
- For fast preview: Use
"greedy" - For high accuracy: Use
"ilp"(slower but better) - For non-dividing cells: Use
"greedy_nodiv"
- TrackAstra tracks pre-segmented objects
- Poor segmentation = poor tracking
- Review segmentation before tracking
- Use
"greedy"or"ilp"modes for dividing cells - TrackAstra can track cell lineages through divisions
- Use
"greedy_nodiv"if divisions are not expected
- Load time-lapse data as single TZYX or TYX files
- Don't split into individual timepoint files before tracking
- TrackAstra needs temporal context
- Visualize tracked results in napari
- Check ID consistency across timepoints
- Verify that divisions are correctly handled
- Environment is created automatically on first use
- Wait for installation to complete (may take 5-10 minutes)
- Check terminal/console for installation progress
- Verify
label_patternmatches your label file naming convention - Ensure label files exist in the same folder as raw images
- Check file extensions match (e.g., .tif vs .tiff)
- TrackAstra requires at least 3D data (TYX)
- Ensure time dimension is present
- Check dimension order in your data
- Tracking requires temporal information
- Ensure your data has multiple time points
- Single timepoints cannot be tracked
- IDs jump/change: Try
"ilp"mode for global optimization - Missed tracks: Improve segmentation quality first
- Wrong divisions: Check if
"greedy_nodiv"is more appropriate - Model mismatch: Try switching between "ctc" and "general_2d"
"ilp"mode is slower than "greedy"- Large datasets (many cells/timepoints) take longer
- Consider using
"greedy"for initial testing - Processing time increases with number of objects
- Input validation: Checks for time dimension and minimum timepoints
- Environment check: Ensures TrackAstra environment exists
- File preparation: Identifies label and raw image pairs
- Tracking script generation: Creates Python script for TrackAstra
- Execution: Runs tracking in isolated environment via subprocess
- Output loading: Reads tracked labels and returns results
- Dedicated
trackastraconda environment - Isolated from main napari-tmidas environment
- Uses subprocess calls for cross-environment execution
- Prevents dependency conflicts
- Greedy: Frame-to-frame linking with local decisions
- ILP: Global optimization over time using integer programming
- No-divisions: Simplified tracking without mitosis handling
TrackAstra is developed by the Weigert Lab:
- Cellpose Segmentation - Segment cells before tracking
- Regionprops Analysis - Extract properties from tracked objects
- Basic Processing Functions - Label manipulation tools