Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/ops_model/data/data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,17 @@ def __getitem__(self, index):
nuc_mask = np.expand_dims(nuc_mask, axis=0)
sc_mask = cell_mask == ci.segmentation_id

# cell_seg and nuclear_seg zarr arrays can differ by a few pixels at FOV
# boundaries due to independent segmentation pipelines. Clip to the smaller
# extent so downstream mask multiplication doesn't broadcast-error.
min_h = min(nuc_mask.shape[1], sc_mask.shape[1])
min_w = min(nuc_mask.shape[2], sc_mask.shape[2])
nuc_mask = nuc_mask[:, :min_h, :min_w]
sc_mask = sc_mask[:, :min_h, :min_w]

# ensure that all output masks as binary
if self.cell_masks:
data = data * sc_mask
data = data[:, :min_h, :min_w]
nuc_mask = (nuc_mask * sc_mask) > 0

cyto_mask = sc_mask & (nuc_mask == 0)
Expand Down
16 changes: 14 additions & 2 deletions src/ops_model/data/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

"""

import os
from pathlib import Path


Expand All @@ -14,11 +15,22 @@ def __init__(self, experiment: str, well: str = None):
else:
self.well_prefix = None

self.base = Path("/hpc/projects/icd.fast.ops")
# Allow override of base directory via environment variable
self.base = Path(
os.environ.get(
"OPS_OUTPUT_BASE_DIR",
"/hpc/projects/icd.fast.ops",
)
)

# Allow override of fast_ops base directory (defaults to base)
fast_base = Path(
os.environ.get("OPS_FAST_OUTPUT_BASE_DIR", str(self.base))
)

self.stores = {
"phenotyping": self.base / self.experiment / "3-assembly/phenotyping.zarr",
"phenotyping_v3": Path("/hpc/projects/icd.fast.ops")
"phenotyping_v3": fast_base
/ self.experiment
/ "3-assembly/phenotyping_v3.zarr",
}
Expand Down
Loading
Loading