SKILL.md
Version Compatibility
Reference examples tested with: Cellpose 3.0+, anndata 0.10+, matplotlib 3.8+, numpy 1.26+, pandas 2.2+, scanpy 1.10+, steinbock 0.16+
Before using code patterns, verify installed versions match. If versions differ:
- Python:
pip show <package>thenhelp(module.function)to check signatures - CLI:
<tool> --versionthen<tool> --helpto confirm flags
If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
Cell Segmentation for IMC
"Segment cells from my IMC images" → Identify individual cell boundaries in multiplexed imaging data using deep learning (Cellpose) or watershed-based approaches for single-cell extraction.
- Python:
cellpose.models.Cellpose()for deep learning segmentation - CLI:
steinbock segmentfor pipeline-based segmentation
Cellpose Segmentation
from cellpose import models, io
import numpy as np
import tifffile
# Load image
img = tifffile.imread('processed.tiff')
# Extract nuclear channel (e.g., DNA1)
nuclear_channel = img[0] # Adjust index based on panel
# Initialize Cellpose model
model = models.Cellpose(model_type='nuclei', gpu=True)
# Run segmentation
masks, flows, styles, diams = model.eval(
nuclear_channel,
diameter=30, # Average nucleus diameter in pixels
flow_threshold=0.4,
cellprob_threshold=0.0
)
# masks contains integer labels for each cell
print(f'Cells segmented: {masks.max()}')
Whole-Cell Segmentation with Cellpose
# Use membrane marker for whole-cell
membrane_channel = img[1] # e.g., CD45
# Combine nuclear and membrane for cyto model
model = models.Cellpose(model_type='cyto2', gpu=True)
# Create 2-channel input [membrane, nuclear]
img_input = np.stack([membrane_channel, nuclear_channel])
masks, flows, styles, diams = model.eval(
img_input,
channels=[1, 2], # [membrane, nuclear]
diameter=50,
flow_threshold=0.4
)
