Skip to content

Commit a28d83b

Browse files
anna-grimanna-grim
andauthored
Bug model inference (#663)
* bug: model loading * refactor: remove test print * bug: segmentation in dataloader --------- Co-authored-by: anna-grim <anna.grim@alleninstitute.org>
1 parent 99ad03d commit a28d83b

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/neuron_proofreader/machine_learning/exaspim_dataloader.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ def __init__(
8888
self.skeletons = dict()
8989

9090
# --- Ingest Data ---
91-
def ingest_brain(self, brain_id, img_path, segmentation_path, swc_path):
91+
def ingest_brain(
92+
self, brain_id, img_path, segmentation_path=None, swc_path=None
93+
):
9294
"""
9395
Loads a brain image, label mask, and skeletons, then stores each in
9496
internal dictionaries.
@@ -99,21 +101,25 @@ def ingest_brain(self, brain_id, img_path, segmentation_path, swc_path):
99101
Unique identifier for the brain corresponding to the image.
100102
img_path : str
101103
Path to whole-brain image to be read.
102-
segmentation_path : str
103-
Path to segmentation.
104-
swc_path : str
105-
Path to SWC files.
104+
segmentation_path : str, optional
105+
Path to segmentation. Default is None.
106+
swc_path : str, optional
107+
Path to SWC files. Default is None.
106108
"""
107109
# Load data
108110
self.imgs[brain_id] = TensorStoreReader(img_path)
109-
self.segmentations[brain_id] = TensorStoreReader(segmentation_path)
111+
self._load_segmentation(brain_id, segmentation_path)
110112
self._load_swcs(brain_id, swc_path)
111113

112114
# Check image shapes
113115
shape1 = self.imgs[brain_id].shape()[2::]
114116
shape2 = self.segmentations[brain_id].shape()
115117
assert shape1 == shape2, f"img_shape={shape1}, mask_shape={shape2}"
116118

119+
def _load_segmentation(self, brain_id, path):
120+
if path:
121+
self.segmentations[brain_id] = TensorStoreReader(path)
122+
117123
def _load_swcs(self, brain_id, swc_path):
118124
if swc_path:
119125
# Initializations

0 commit comments

Comments
 (0)