This repository provides the implementation of Cell-TRACTR paper by Owen M. O'Connor and Mary J. Dunlop. The codebase builds upon DETR, Deformable DETR and Trackformer
- Abstract
- Features
- Installation
- Formatting Datasets
- Weights
- Training
- Inference
- Visual Examples
- Citation
- License
Cell-TRACTR (Cell TRacking with Attention and TRansformers) is a state-of-the-art deep learning framework designed for robust cell tracking in time-lapse microscopy. By leveraging the power of transformer architectures and attention mechanisms, Cell-TRACTR excels at tracking both bacterial cells in microfluidic devices and mammalian cells in standard culture conditions. The model demonstrates exceptional performance in handling challenging scenarios such as cell division events, density variations, and diverse morphologies. Cell-TRACTR achieves this through an end-to-end architecture that simultaneously performs detection, segmentation, and tracking, eliminating the need for separate pre-processing steps or post-processing heuristics.
Figure 1: The Cell-TRACTR architecture combines a CNN backbone with transformer modules for simultaneous detection, segmentation, and tracking of cells in microscopy videos.
- π¬ End-to-end cell tracking in microscopy videos
- 𧬠Support for both bacterial and mammalian cell tracking
- π Robust handling of cell division events
- π― Simultaneous detection, segmentation, and tracking
- π High accuracy across varying cell densities
- π GPU-accelerated inference
- π Extensive evaluation on standard benchmarks
Since Cell-TRACTR uses the MultiScaleDeformableAttention package, a GPU is required to train or run inference.
- NVIDIA GPU with CUDA support
- Python 3.10
- Git
- Conda package manager
- Clone and enter this repository:
git clone https://gitlab.com/dunloplab/Cell-TRACTR.git
cd Cell-TRACTR- Create and activate conda environment:
conda create -n cell-tractr python=3.10
conda activate cell-tractr- Install required packages:
pip3 install -r requirements.txt- Install FFmpeg:
conda install -c conda-forge ffmpeg-
Install PyTorch 1.13.1 and CUDA 11.6: Visit PyTorch Previous Versions to get the correct installation command for your system. You may choose other compatible versions of PyTorch.
-
Install pycocotools with fixed ignore flag:
pip3 install -U 'git+https://github.com/timmeinhardt/cocoapi.git#subdirectory=PythonAPI'- Install MultiScaleDeformableAttention package:
pip install -e src/trackformer/models/ops-
CUDA/GPU Issues
- Ensure your NVIDIA drivers are up to date
- Verify CUDA installation with
nvidia-smi - Check PyTorch GPU support with
torch.cuda.is_available()
-
MultiScaleDeformableAttention Installation
- If compilation fails, ensure you have the correct CUDA toolkit version
- On Windows, you may need Microsoft Visual C++ Build Tools
- For detailed troubleshooting, refer to Deformable DETR
-
Environment Conflicts
- Always start with a fresh conda environment
- If you encounter conflicts, try installing packages in the order listed above
- Use
conda listto verify package versions
To verify your installation:
python -c "import torch; print(f'PyTorch version: {torch.__version__}'); print(f'CUDA available: {torch.cuda.is_available()}')"Cell-TRACTR supports multiple dataset formats and provides tools for converting them to the required format. Below are the supported datasets and formatting instructions.
-
Mother Machine Dataset
- Available on Zenodo
- Contains bacterial cell tracking data in microfluidic devices
- Pre-formatted in CTC format
-
DeepCell Dataset
- Dataset: DynamicNuclearNet-tracking-v1_0
- Contains mammalian cell tracking data
- Requires conversion to CTC format before use
You can use your own custom dataset by following the Cell Tracking Challenge (CTC) format specifications. For detailed formatting guidelines, refer to the CTC documentation.
Your dataset should follow this structure:
data/
βββ your_dataset/
βββ CTC/
βββ train/
βββ val/
βββ test/ (optional)
After organizing your data in CTC format, use the conversion script to prepare it for Cell-TRACTR:
python create_coco_dataset_from_CTC.py --dataset your_datasetThis will create a COCO-formatted version with the following structure:
data/
βββ your_dataset/
βββ COCO/
βββ annotations/
βββ man_track/
βββ train/
βββ val/
- Videos must have a minimum number of frames to be included in the training set
- The conversion script automatically handles frame sequence validation
- Both training and validation sets are required for training
- Test set is optional and used only for inference
The weights to both pretrained models are availabe on zenodo.
Cell-TRACTR training requires dataset-specific configurations through the train.py script in the src directory.
python src/train.py with dataset='your_dataset'- Each dataset requires its own configuration file (e.g.,
train_moma.yaml,train_DynamicNuclearNet-tracking-v1_0.yaml) - Important parameters to configure per dataset:
- Number of queries
- Target size
- Learning rate
- Batch size
- Number of epochs
- Model architecture settings
- Monitor GPU memory usage during training
- Use
nvidia-smito track GPU utilization - Adjust batch size based on available GPU memory
- Consider using gradient accumulation for larger effective batch sizes
- The script automatically resumes from checkpoints if available
The inference pipeline requires dataset-specific configuration:
python src/pipeline.py with dataset='your_dataset'- Uses dataset-specific configuration file
- Requires the same parameter settings used during training
- Processes test data from your dataset's test folder
- Ensure your dataset follows the CTC format
- GPU is required for inference
- Monitor system resources during processing
- Results are saved in the dataset's output directory
Figure 4: Quantitative analysis using Cell-HOTA and Cell Tracking Challenge (CTC) metrics to evaluate Cell-TRACTR's performance across different experimental conditions and cell types. Cell-HOTA provides a comprehensive assessment of detection, segmentation, and tracking accuracy, while CTC metrics enable direct comparison with other methods.
A time-lapse microscopy video of bacteria growing in the mother machine analyzed by Cell-TRACTR. The raw images used to generate this movie was taken from the test set within the mother machine dataset
A time-lapse microscopy video of mammalian cells growing on 96-well plates. The raw images used to generate this movie was taken from the test set within the DeepCell dataset - DynamicNuclearNet Tracking
If you find this work useful in your research, please consider citing:
@article{oconnor2025cell,
title={Cell-TRACTR: A transformer-based model for end-to-end segmentation and tracking of cells},
author={O'Connor, Owen M. and Dunlop, Mary J.},
journal={PLOS Computational Biology},
year={2025},
publisher={Public Library of Science},
doi={10.1371/journal.pcbi.1013071}
}Cell-TRACTR is released under the Apache 2.0 License.


![[Video]](https://media0.giphy.com/media/v1.Y2lkPTc5MGI3NjExd2VrOW16djJnYzJ4cWhsd2F0cjNtNzVnazgzNjZuMjhucmdoNGkwYiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/cwNDVhxqTPYMYMxd75/giphy.gif)
