An integrated framework for cell segmentation and cell type annotation using CellSAM and DeepCell Types.
This repository provides reproducible pipelines for processing, segmenting, and classifying cells in multi-channel microscopy datasets.
This repository implements the following workflow:
- Segmentation with CellSAM for identifying single cells in microscopy images.
- Annotation with DeepCell Types via API for cell identity prediction.
- Output reports with per-cell CSVs and visual summaries.
This project requires Python 3.12.
You can create the environment using Conda or pip/venv, as described below.
-
Clone this repository
git clone https://github.com/cns-iu/hra-deepcell-experiments.git cd hra-deepcell-experiments -
Create and activate the environment
conda create -n hra-deepcell python=3.12 conda activate hra-deepcell
-
Install dependencies
pip install -r requirements.txt pip install git+https://github.com/vanvalenlab/cellSAM.git pip install git+https://github.com/vanvalenlab/deepcell-types@master
If you’re not using Conda, you can create a standard virtual environment:
-
Create and activate the environment
python3.12 -m venv hra-deepcell source hra-deepcell/bin/activate # On Mac/Linux hra-deepcell\Scripts\activate # On Windows
-
Install dependencies
pip install -r requirements.txt pip install git+https://github.com/vanvalenlab/cellSAM.git pip install git+https://github.com/vanvalenlab/deepcell-types@master
Before running DeepCell for cell type predictions, configure your API access token.
- Go to DeepCell API Key Management.
- Log in and generate a new API key.
- Save the token using one of the following methods.
conda env config vars set -n hra-deepcell DEEPCELL_ACCESS_TOKEN=<your-token>
conda deactivate && conda activate hra-deepcellOn Mac/Linux:
export DEEPCELL_ACCESS_TOKEN=<your-token>On Windows (PowerShell):
setx DEEPCELL_ACCESS_TOKEN "<your-token>"On Windows (CMD):
set DEEPCELL_ACCESS_TOKEN=<your-token>💡 Restart your terminal or IDE after setting the environment variable.
import os
os.environ["DEEPCELL_ACCESS_TOKEN"] = "<your-token>"To enable data access from the HuBMAP Data Portal or interact programmatically with the Search & Index API, follow these steps for Globus authentication.
pip install atlas-consortia-cltglobus login --no-local-serverCopy the link shown in the terminal, open it in your browser, complete the authentication, and authorize Globus access.
To verify authentication:
globus whoami --verboseFollow the HuBMAP Manifest File Documentation to create a manifest.txt file listing the dataset(s) to download.
Refer to How To Install, Configure, and Uninstall Globus Connect Personal for Linux.
You can also download it directly using:
wget https://downloads.globus.org/globus-connect-personal/linux/stable/globusconnectpersonal-latest.tgzExtract and navigate into the directory:
tar -xzf globusconnectpersonal-latest.tgz
cd globusconnectpersonal-x.y.z(Replace x.y.z with the extracted version number.)
Start Globus Connect Personal for the first time:
./globusconnectpersonal -start &Complete setup as prompted. After setup, exit the directory:
cd ..Once authenticated and your manifest.txt is ready, you can transfer HuBMAP data using:
hubmap-clt transfer manifest.txtThis will initiate a secure data transfer using Globus.
You may see this message:
The resource you are trying to access requires you to re-authenticate.
Session reauthentication required (Globus Transfer)
The CLI will provide a command like:
globus session update <SESSION-ID>
*You have successfully updated your CLI session.
⚠️ Common Error: “Markers are extracted from the .ome.tiff metadata and not the pipeline_config.json due to mismatch size”
After a successful run, you will obtain:
mask.tif— labeled segmentation maskscell_populations.csv— morphological cell metricscell_types.csv— annotated cell types
- CellSAM Documentation
- DeepCell Types Tutorial
- DeepCell API Setup
- HuBMAP API Reference
- HuBMAP CLT Guide