Skip to content

Commit 44f22cf

Browse files
alxndrkalininclaude
andcommitted
refactor(dynacell): replace microssim dep with cubic.metrics.MicroMS3IM
cubic 0.7.0a4 ships a native MicroSSIM / MicroMS3IM implementation, making the upstream juglab/microssim git pin redundant. Swap dynacell's calculate_microssim to lazy-import `cubic.metrics.MicroMS3IM` so the existing test stubs in `test_evaluation_metrics.py` (which fake `cubic.metrics` at module load) keep working unchanged. Notes on the wiring: - Top-of-file `from microssim import MicroMS3IM` (try/except shim) and the `_require_microssim` helper are removed; metrics.py no longer references upstream microssim. - `_require_cubic()` is NOT called from `calculate_microssim`. That helper requires the GPU stack (cupy, cucim) and would regress CPU-only eval runs that only need MicroMS3IM; the lazy import alone is the gate. - The cubic.metrics stub gains `MicroMS3IM = object` so future tests exercising calculate_microssim won't need to re-extend it. Lock + workspace: - `applications/dynacell/pyproject.toml` bumps `cubic==0.7.0a2` → `cubic==0.7.0a4` and drops the microssim git pin from `optional-dependencies.eval`. - Workspace `[tool.uv.sources]` carries a temporary git override pointing cubic at the 0.7.0a4 release commit until PyPI catches up. Remove the override after the cubic release lands on PyPI. - `uv.lock` regenerated; no more `juglab/microssim` references. README sweep: drop microssim from the optional-deps shortlist. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 74085e0 commit 44f22cf

6 files changed

Lines changed: 13 additions & 41 deletions

File tree

applications/dynacell/pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,12 @@ optional-dependencies.eval = [
4343
"aicsmlsegment",
4444
"aicssegmentation",
4545
"cellpose",
46-
"cubic==0.7.0a2",
46+
"cubic==0.7.0a4",
4747
"dynaclr",
4848
"hydra-core>=1.2",
4949
"iohub",
5050
"itk",
5151
"matplotlib",
52-
"microssim @ git+https://github.com/juglab/microssim.git@8bccb17d",
5352
"pandas",
5453
"scikit-image",
5554
"scikit-learn>=1.4",

applications/dynacell/src/dynacell/evaluation/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ eval_timing.csv # region timer log (always on)
250250

251251
## Installation
252252

253-
Heavy optional deps (`aicssegmentation`, `segmenter-model-zoo`, `cubic`, `microssim`, `transformers`, `dynaclr`):
253+
Heavy optional deps (`aicssegmentation`, `segmenter-model-zoo`, `cubic`, `transformers`, `dynaclr`):
254254

255255
```bash
256256
uv pip install -e "applications/dynacell[eval]"

applications/dynacell/src/dynacell/evaluation/metrics.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
import numpy as np
44
import torch
55

6-
try:
7-
from microssim import MicroMS3IM
8-
except ImportError:
9-
MicroMS3IM = None # type: ignore[assignment, misc]
10-
116
try:
127
from cubic.cuda import ascupy, asnumpy
138
from cubic.feature.voxel import regionprops_table
@@ -24,11 +19,6 @@
2419
from dynacell.evaluation.utils import _minmax_norm
2520

2621

27-
def _require_microssim():
28-
if MicroMS3IM is None:
29-
raise ImportError("microssim is required for MicroMS3IM computation. Install it with: pip install microssim")
30-
31-
3222
def _require_cubic():
3323
if ascupy is None:
3424
raise ImportError(
@@ -259,8 +249,8 @@ def compute_pixel_metrics(prediction, target, spacing, fsc_kwargs=None, spectral
259249

260250
def calculate_microssim(microssim_data):
261251
"""Calculate MicroMS3IM scores across a collection of images."""
262-
_require_microssim()
263-
_require_cubic()
252+
from cubic.metrics import MicroMS3IM
253+
264254
targets = np.concatenate([img["target"] for img in microssim_data], axis=0)
265255
predictions = np.concatenate([img["predict"] for img in microssim_data], axis=0)
266256

applications/dynacell/tests/test_evaluation_metrics.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,14 @@
1313

1414
def _import_metrics_with_stubs(monkeypatch):
1515
"""Import the metrics module with lightweight optional-dependency stubs."""
16-
microssim_module = types.ModuleType("microssim")
17-
microssim_module.MicroMS3IM = object
18-
1916
cubic_module = types.ModuleType("cubic")
2017
cubic_cuda_module = types.ModuleType("cubic.cuda")
2118
cubic_cuda_module.ascupy = lambda x: x
2219
cubic_cuda_module.asnumpy = lambda x: x
2320

2421
cubic_metrics_module = types.ModuleType("cubic.metrics")
2522
cubic_metrics_module.fsc_resolution = lambda *args, **kwargs: {}
23+
cubic_metrics_module.MicroMS3IM = object
2624

2725
cubic_bandlimited_module = types.ModuleType("cubic.metrics.bandlimited")
2826
cubic_bandlimited_module.spectral_pcc = lambda *args, **kwargs: 0.0
@@ -31,7 +29,6 @@ def _import_metrics_with_stubs(monkeypatch):
3129
cubic_feature_voxel_module = types.ModuleType("cubic.feature.voxel")
3230
cubic_feature_voxel_module.regionprops_table = lambda *args, **kwargs: {}
3331

34-
monkeypatch.setitem(sys.modules, "microssim", microssim_module)
3532
monkeypatch.setitem(sys.modules, "cubic", cubic_module)
3633
monkeypatch.setitem(sys.modules, "cubic.cuda", cubic_cuda_module)
3734
monkeypatch.setitem(sys.modules, "cubic.metrics", cubic_metrics_module)

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ cytoland = { workspace = true }
5858
airtable-utils = { workspace = true }
5959
qc = { workspace = true }
6060
dynacell = { workspace = true }
61+
# Temporary: cubic 0.7.0a4 is not yet on PyPI. Remove this entry once the
62+
# release is published; the workspace falls back to PyPI for `cubic==0.7.0a4`
63+
# pinned in `applications/dynacell/pyproject.toml`. The URL is the canonical
64+
# cubic Repository (per PyPI metadata).
65+
cubic = { git = "https://github.com/alxndrkalinin/cubic.git", rev = "424343f5e1c9f34921936b037863479c91072b28" }
6166
waveorder = { git = "https://github.com/mehta-lab/waveorder.git", branch = "main" }
6267
aicssegmentation = { git = "https://github.com/alxndrkalinin/aics-segmentation.git", branch = "main" }
6368
segmenter-model-zoo = { git = "https://github.com/alxndrkalinin/segmenter_model_zoo.git", branch = "main" }

uv.lock

Lines changed: 3 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)