# =============================================================================
# requirements.txt — Reproducible environment for Opal Studio
# Goal: Mesmer (DeepCell) + StarDist + Cellpose + InstanSeg on TF 2.8
#
# Setup:
#   conda create -n opal-all python=3.9
#   conda activate opal-all
#   pip install -r requirements.txt        ← note the -r flag!
#   pip install --no-deps -e .             ← install opal-studio without re-resolving deps
#
# Constraints:
#   - deepcell 0.12.x requires Python < 3.11 (using 3.9.25)
#   - tensorflow 2.8.0 pinned for deepcell compatibility
#   - numpy 1.26.4 is the latest compatible with both TF 2.8 and Torch 2.1
# =============================================================================

# ── TensorFlow Stack (DeepCell/Mesmer) ───────────────────────────────────────
tensorflow==2.8.0
tensorflow-addons==0.16.1
tensorflow-io-gcs-filesystem==0.26.0
protobuf==3.20.3
spektral==1.0.6

# ── PyTorch Stack (Cellpose/InstanSeg) ───────────────────────────────────────
# Install CUDA build with:
#   pip install torch==2.1.2+cu121 torchvision==0.16.2+cu121 --index-url https://download.pytorch.org/whl/cu121
# CPU-only fallback (slower, no GPU segmentation):
#   pip install torch==2.1.2 torchvision==0.16.2
torch==2.1.2
torchvision==0.16.2
einops==0.8.2

# ── Segmentation Tools ───────────────────────────────────────────────────────
deepcell==0.12.10
deepcell-toolbox==0.12.1
deepcell-tracking==0.6.5
stardist==0.9.2
csbdeep==0.8.2
cellpose==3.1.1.3

# ── Virtual Brightfield (Brightfield tab) ─────────────────────────────────────
# Base install only — do NOT add [enhance], whose tensorflow==2.14 pin breaks the
# Mesmer/DeepCell TF 2.8 stack.
multiplex2brightfield>=0.2.8
omnipose==1.0.6
instanseg-torch==0.1.1
torchvf==0.1.4

# ── Core Scientific Stack ────────────────────────────────────────────────────
numpy==1.26.4
scipy==1.13.1
pandas==2.3.3
scikit-image==0.24.0
scikit-learn==1.6.1
matplotlib==3.9.4
networkx==3.2.1
numba==0.60.0
llvmlite==0.43.0
contourpy==1.3.0

# ── Image I/O & Processing ───────────────────────────────────────────────────
imageio==2.37.2
tifffile==2024.8.30
imagecodecs==2024.12.30
roifile==2024.9.15
pillow==11.3.0
h5py==3.14.0
opencv-python-headless==4.11.0.86
fastremap==1.18.0
fill-voids==2.1.1
edt==3.1.1
mgen==1.2.1
ncolor==1.5.3
peakdetect==1.2
mahotas==1.4.18
igraph==0.11.9

# ── UI Framework ─────────────────────────────────────────────────────────────
PySide6==6.4.3

# ── Utilities ────────────────────────────────────────────────────────────────
tqdm==4.67.3
natsort==8.4.0
pydot==1.4.2
packaging==26.1
six==1.17.0
pywin32==311; sys_platform == 'win32'
colorama==0.4.6
psutil==7.2.2
threadpoolctl==3.6.0
setuptools>=68.0,<70.0.0

zarr==2.18.2
numcodecs==0.12.1      # zstd chunk codec used directly by image_loader / project_io
numexpr==2.10.2

# ── Project I/O (SpatialData save/load: GeoParquet shapes + cell table) ───────
geopandas==1.0.1
shapely==2.0.7
pyarrow==21.0.0

seaborn==0.13.2

# ── Clustering (Phenotyping) ──────────────────────────────────────────────────
scanpy==1.10.3
anndata==0.10.9
umap-learn==0.5.12
leidenalg==0.10.2      # backend for scanpy sc.tl.leiden (not pulled by scanpy itself)
louvain==0.8.2         # backend for scanpy sc.tl.louvain
flowsom==0.2.1
PhenoGraph==1.5.7