Skip to content

Commit d453dc3

Browse files
authored
segment cristae now uses torch_em's predict_with_halo mask ... (#166)
* segment cristae now uses torch_em's predict_with_halo mask to limit the prediction to actual mitochondria. Mask is either passed to segment_cristae or computed from the the mitochondria segmentation * minor corrections
1 parent 4f03f00 commit d453dc3

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

synapse_net/inference/cristae.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,21 @@ def segment_cristae(
143143
# rescale each channel
144144
volume = scaler.scale_input(input_volume)
145145
mito_seg = scaler.scale_input(mitochondria, is_segmentation=True)
146-
input_volume = np.stack([volume, mito_seg], axis=0)
147146

148147
# target 10nm erosion for mitochondria
149148
# voxel_size is the model's training voxel size, which is the space we erode in
150149
erode_voxels = max(1, round(10.0 / voxel_size))
151150

152-
# Run prediction and segmentation.
153-
if mask is not None:
151+
# Use the mitochondria segmentation as the prediction mask so that
152+
# predict_with_halo skips tiles with no mito voxels entirely.
153+
# Replace with the optional external mask if one is provided.
154+
if mask is None:
155+
mask = mito_seg > 0
156+
else:
154157
mask = scaler.scale_input(mask, is_segmentation=True)
158+
159+
input_volume = np.stack([volume, mito_seg], axis=0)
160+
# Run prediction and segmentation.
155161
pred = get_prediction(
156162
input_volume, model_path=model_path, model=model, mask=mask,
157163
tiling=tiling, with_channels=with_channels, channels_to_standardize=channels_to_standardize, verbose=verbose

0 commit comments

Comments
 (0)