Skip to content

dkittelson/cell-tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔬 Cell Segmentation & Tracking

Interactive web app for cell segmentation and tracking using Cellpose + LAP tracking.

✨ Now with Apple M4 GPU Support!

🚀 Quick Start

Installation

# Clone repository
git clone https://github.com/YOUR_USERNAME/flim_tracker.git
cd flim_tracker

# Create conda environment
conda create -n flim python=3.10
conda activate flim

# Install dependencies
pip install -r requirements.txt

Run App

streamlit run streamlit_app.py

Open http://localhost:8501 in your browser.

💻 GPU Support

Apple Silicon (M4/M3/M2/M1)

Automatic M4 Pro GPU acceleration via MPS (Metal Performance Shaders)

  • 5-10x faster than CPU
  • ~10-30 seconds per frame (vs 2-3 minutes on CPU)

NVIDIA GPUs

Automatic CUDA GPU acceleration

  • ~1-2 seconds per frame

CPU Fallback

⚠️ Automatically uses CPU if no GPU available (slower)

📊 Features

Interactive Parameter Tuning

  • Real-time Preview: See segmentation results instantly
  • Compact UI: No scrolling, all controls visible
  • Video Playback: Play/pause frame-by-frame animation
  • Arrow Navigation: Previous/Next buttons for frame selection

Preprocessing Options

  • Brightness adjustment (0.1-3.0x)
  • Contrast normalization (stretch 0-255)
  • CLAHE enhancement
  • Gamma correction

Cellpose Parameters

  • Diameter: Expected cell size (10-60px)
  • Flow Threshold: Cell boundary detection strictness (0-1)
  • Cell Prob Threshold: Detection permissiveness (-6 to 6)

Filtering

  • Min/Max cell area
  • Minimum intensity threshold

Tracking

  • LAP (Linear Assignment Problem) algorithm
  • Max linking distance
  • Gap frame bridging (handle temporary occlusions)

Export

  • Download tracking CSV with:
    • Track IDs
    • Frame numbers
    • Cell centroids (x, y)
    • Cell areas
    • Mean intensities

📁 Data Format

Upload a ZIP file containing microscopy images:

  • Supported formats: TIF, TIFF, PNG, JPG, JPEG
  • Images should be grayscale
  • Consistent dimensions across frames

🎯 Workflow

  1. Upload Data: Drag & drop ZIP of images
  2. Tune Parameters: Adjust preprocessing, Cellpose, and filtering in sidebar
  3. Preview: Navigate frames with ⬅️/➡️ arrows
  4. Play Video: Click ▶️ to see animated tracking preview
  5. Run Pipeline: Process all frames with full tracking
  6. Download CSV: Export results for analysis

📈 Performance

Hardware Speed per Frame Full Dataset (15 frames)
Apple M4 Pro 10-30 seconds ~3-7 minutes
NVIDIA T4 1-2 seconds ~15-30 seconds
CPU (Intel/AMD) 2-3 minutes ~30-45 minutes

🔧 Technical Details

  • Segmentation: Cellpose v3.0+ (cyto2 model)
  • Tracking: LAP algorithm with gap closing
  • UI: Streamlit with custom compact CSS
  • GPU: PyTorch MPS (Apple Silicon) or CUDA (NVIDIA)

📦 Example Data

Sample PBS_1 dataset included: pbs1_frames.zip (15 frames, 1.8MB)

🐛 Troubleshooting

"No cells detected"

  • Try enabling Contrast Normalize (dim images)
  • Lower Cell Prob Threshold (more permissive)
  • Adjust Diameter to match your cell size

Slow performance on Mac

  • Verify GPU is enabled: Look for "🚀 GPU: Apple M4 Pro (MPS)" message
  • If showing "💻 CPU Mode": Reinstall PyTorch with MPS support
    pip uninstall torch torchvision
    pip install torch torchvision torchaudio

Too many false positives

  • Increase Flow Threshold (stricter boundaries)
  • Increase Cell Prob Threshold (stricter detection)
  • Adjust Min/Max Area filters
  • Increase Min Intensity threshold

Broken tracks

  • Increase Max Linking Distance (cells move farther between frames)
  • Increase Max Gap Frames (handle longer occlusions)

🙏 Credits

Built with Cellpose, Streamlit, and PyTorch

📄 License

MIT License

About

End-to-end pipeline for segmenting and tracking T-cells

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages