TRACE-QC is a Python package for automated quality control and correction of mislabeling in longitudinal imaging of 3D cell cultures. Using a parameter-free algorithm that operates solely on image metadata, TRACE-QC detects and corrects spatial displacement artifacts in time-course imaging of tumor spheroids, organoids, and other matrix-embedded 3D structures.
Temporal reassignment and correspondence evaluation with quality control for time-course imaging of 3D cell culture Eric M. Cramer, Tamara Lopez-Vidal, Jeanette Johnson, Vania Wang, Daniel R. Bergman, Ashani Weeraratna, Richard Burkhart, Elana J. Fertig, Jacquelyn W. Zimmerman, Laura M. Heiser, and Young Hwan Chang Cell Reports Methods 5, 101237 (2025) DOI: 10.1016/j.crmeth.2025.101237
During long-term imaging of 3D cell cultures embedded in extracellular matrix:
- Matrix displacement can occur from detachment, rotation, or mechanical disruption
- Spheroids are mislabeled when imaged at previous locations after moving
- Manual correction is time-consuming and error-prone for high-throughput experiments
- Data integrity is compromised without proper quality control
In our experimental dataset, 9 out of 12 wells (75%) showed displacement, affecting 66% of total measurements.
TRACE-QC provides:
- β Automated mislabeling detection and correction using image coordinates (X, Y metadata)
- β Parameter-free algorithm requiring no tuning or ground truth data
- β Quality control metric (normalized FrΓ©chet distance) for automated decision-making
- β No experimental modifications needed - works with existing imaging workflows
TRACE-QC uses a two-stage algorithm:
- Permutation-based matching: Finds optimal point correspondence by minimizing the L2 norm of distance matrix differences
- Procrustes alignment: Applies SVD-based rotation and translation to align spheroid positions
The algorithm corrects for:
- Global well rotations
- Global translations (matrix shifts)
- Local spheroid movements (jittering)
Quality Control: Normalized FrΓ©chet distance β€ 1.0 indicates successful alignment (~90% accuracy).
(Key files described)
TRACEQC/
βββ align_spheroid/ # Core Python package
β βββ __init__.py # Package initialization
β βββ alignment.py # Main TRACE-QC algorithm (Aligner2D class)
β βββ alignment_polygon.py # Alternative polygon-based alignment
β βββ evaluation.py # Quality control metrics and evaluation functions
β βββ synthetic_data.py # CellSimulator for generating test data
β βββ utils.py # Utility functions
βββ gui/ # Web application (NEW!)
β βββ app.py # Streamlit web interface
β βββ requirements.txt # GUI-specific dependencies
β βββ README.md # GUI documentation
β βββ utils/ # GUI utility modules
β β βββ data_parser.py # Data parsing and validation
β β βββ visualization.py # Plotting functions
β βββ example_data/ # Sample datasets for testing
β βββ sample_spheroids.csv
β βββ example_well_b2.csv # Example data with successful alignment
β βββ example_well_b3.csv # Example data with unsuccessful alignment due to matrix degradation
βββ tests/ # Unit tests
β βββ test_alignment.py # Tests for alignment algorithms
β βββ test_evaluation.py # Tests for evaluation metrics
β βββ test_synthetic_data.py # Tests for synthetic data generation
βββ paper/ # Jupyter notebooks for manuscript figures
β βββ figure-1.ipynb # Figure 1: Experimental setup and displacement
β βββ figure-2.ipynb # Figure 2: Algorithm performance
β βββ figure-3.ipynb # Figure 3: Biological data application
β βββ tracker-comparison.ipynb # Algorithm benchmarking
βββ synthetic-example.ipynb # Example notebook demonstrating TRACE-QC
βββ requirements.txt # Python dependencies
βββ LICENSE # MIT License
βββ README.md # This filegit clone https://github.com/emcramer/TRACEQC.git
cd TRACEQCpython3 -m venv venv
source venv/bin/activate # On Linux/macOS
# OR
venv\Scripts\activate # On Windowspip install -r requirements.txtUse the TRACE-QC web interface for a user-friendly, point-and-click experience! The streamlit application is available online for those who want to to access the GUI and upload your data to run TRACEQC. If you wish to run the GUI locally, download the repo and run the following:
# Install GUI dependencies
pip install -r gui/requirements.txt
# Start the web application
streamlit run gui/app.pyThe application will open in your browser at http://localhost:8501.
To use the GUI, simply:
- Upload your CSV/TXT data file (<50 MB)
- Configure settings
- Click "Run Analysis"
- Download results
See the GUI README for detailed instructions. GIF demo below.
For integration into analysis pipelines or custom scripts:
from align_spheroid import Aligner2D
import numpy as np
# Prepare your data: shape (n_points, n_timepoints)
# dataX and dataY contain x,y coordinates for each spheroid at each time point
time_points = ['0h', '24h', '48h', '72h', '168h']
# Initialize and run TRACE-QC
aligner = Aligner2D(well_name="Well_A1", time_points=time_points)
aligner.align(dataX, dataY)
# Access corrected results
corrected_data = aligner.registered_df # DataFrame with corrected labels
aligned_coords = aligner.aligned_points # List of aligned coordinates
# Visualize alignment
aligner.plot(show_plot=True)
# Quality control: Check normalized FrΓ©chet distance
from align_spheroid.evaluation import normalize_distance, calculate_frechet
frechet_dist = calculate_frechet(aligner.aligned_points[0], aligner.aligned_points[1])
norm_frechet = normalize_distance(aligner.aligned_points[0], frechet_dist)
print(f"Normalized FrΓ©chet distance: {norm_frechet:.2f}")
if norm_frechet <= 1.0:
print("β Alignment successful")
else:
print("β Extreme displacement detected - manual review recommended")from align_spheroid import CellSimulator
# Create simulator
sim = CellSimulator(
n_circles=6,
width=1000,
height=1000,
rng=np.random.default_rng(seed=42)
)
# Simulate displacement over time
simulated_data = sim.simulate(
time_points=['0h', '24h', '48h', '72h'],
rotations=[15, 30, 45], # Rotation angles (degrees)
translations=[(10, 10), (20, 15), (15, 25)], # (dx, dy) translations
jitters=[(5, 5), (5, 5), (5, 5)], # Random jittering
shuffle_points=True # Shuffle row order (mimics real data)
)Run all tests using pytest:
pytest tests/Run specific test modules:
pytest tests/test_alignment.py
pytest tests/test_evaluation.py
pytest tests/test_synthetic_data.pySee synthetic-example.ipynb for a complete walkthrough demonstrating:
- Synthetic spheroid data generation
- Application of TRACE-QC algorithm
- Visualization of alignment results
- Quality control metric calculation
jupyter notebook synthetic-example.ipynbThe paper/ directory contains notebooks reproducing all figures from the publication:
jupyter notebook paper/figure-1.ipynb # Experimental setup and displacement
jupyter notebook paper/figure-2.ipynb # Algorithm performance validation
jupyter notebook paper/figure-3.ipynb # Application to biological data
jupyter notebook paper/tracker-comparison.ipynb # Benchmarking vs other methodsNote: Figure notebooks require the biological dataset (available on Zenodo).
TRACE-QC is designed for:
- Tumor spheroid assays (invasion, drug screening, growth dynamics)
- Organoid cultures (development, differentiation studies)
- Any 3D culture embedded in extracellular matrix with longitudinal imaging
- High-throughput screens where manual quality control is impractical
Aligner2Dclass: Main TRACE-QC implementation- Permutation-based optimization using L2 norm of distance matrices
- Procrustes analysis with SVD for rotation/translation
- Handles global rotations, translations, and local jittering
- Method chaining support
- Normalized FrΓ©chet distance (primary QC metric)
CellSimulator: Generate synthetic spheroid data- Configurable transformations (rotation, translation, jittering)
- Individual cell movement simulation
- Ground truth labels for validation
TRACE-QC may fail or produce suboptimal results when:
- Perfectly symmetrical arrangements: Regular polygons (square, hexagon) cause rotational ambiguity
- Extreme displacement: Normalized FrΓ©chet distance > 1.0
- Very close initial spacing: Small nearest-neighbor distances increase sensitivity
- Variable spheroid numbers: Algorithm requires same N at all time points
- Matrix degradation: Severe fragmentation over time
Important: Algorithm failure can itself be a valuable QC signal indicating spheroid fusion, dissolution, or matrix instability.
- Python 3.8+
- Memory: Scales with O(N! Γ NΒ²) for permutation step
- Recommended: N β€ 8-10 spheroids per well for practical runtimes
- For larger N, consider alternative methods (SCS) or spatial partitioning
If you use TRACE-QC in your research, please cite:
@article{cramer2025trace,
title={Temporal reassignment and correspondence evaluation with quality control for time-course imaging of 3D cell culture},
author={Cramer, Eric M and Lopez-Vidal, Tamara and Johnson, Jeanette and Wang, Vania and Bergman, Daniel R and Weeraratna, Ashani and Burkhart, Richard and Fertig, Elana J and Zimmerman, Jacquelyn W and Heiser, Laura M and Chang, Young Hwan},
journal={Cell Reports Methods},
volume={5},
pages={101237},
year={2025},
publisher={Elsevier},
doi={10.1016/j.crmeth.2025.101237}
}This project is licensed under the MIT License - see the LICENSE file for details.
For questions, issues, or collaboration inquiries:
- Lead Contact: Dr. Young Hwan Chang (chanyo@ohsu.edu)
- GitHub Issues: https://github.com/emcramer/TRACEQC/issues
This work was supported by:
- Jayne Koskinas Ted Giovanis Foundation for Health and Policy
- NIH/NCI U24CA284156
- NIH/NCI T32CA153952
- NIH/NIGMS T32GM141938
- Charles and Margaret Levin Family Foundation
- Dana & Albert R. Broccoli Charitable Foundation
We thank Dr. David Tuveson, Dr. Dennis Plenker, Dr. Amber Habowski, and Hardik Patel for kindly sharing the hT231 cell line.

