88import os
99import warnings
1010from concurrent import futures
11- from functools import partial
1211from typing import Optional , Tuple
1312
1413import elf .parallel as parallel
2928import flamingo_tools .s3_utils as s3_utils
3029from flamingo_tools .file_utils import read_image_data
3130
32- try :
33- import fastfilters as ff
34- except ImportError :
35- import vigra .filters as ff
36-
3731
3832class SelectChannel (SimpleTransformationWrapper ):
3933 """Wrapper to select a chanel from an array-like dataset object.
@@ -231,7 +225,6 @@ def distance_watershed_implementation(
231225 center_distance_threshold : float = 0.4 ,
232226 boundary_distance_threshold : Optional [float ] = None ,
233227 fg_threshold : float = 0.5 ,
234- distance_smoothing : float = 1.6 ,
235228 original_shape : Optional [Tuple [int , int , int ]] = None ,
236229) -> None :
237230 """Parallel implementation of the distance-prediction based watershed.
@@ -244,7 +237,6 @@ def distance_watershed_implementation(
244237 boundary_distance_threshold: The threshold applied to the boundary predictions to derive seeds.
245238 By default this is set to 'None', in which case the boundary distances are not used for the seeds.
246239 fg_threshold: The threshold applied to the foreground prediction for deriving the watershed mask.
247- distance_smoothing: The smoothing factor applied to the distance predictions.
248240 original_shape: The original shape to resize the segmentation to.
249241 """
250242 input_ = open_file (input_path , "r" )["prediction" ]
@@ -260,9 +252,10 @@ def distance_watershed_implementation(
260252 boundary_distances = SelectChannel (input_ , 2 )
261253
262254 # Apply (lazy) smoothing to both.
263- smoothing = partial (ff .gaussianSmoothing , sigma = distance_smoothing )
264- center_distances = SimpleTransformationWrapper (center_distances , transformation = smoothing )
265- boundary_distances = SimpleTransformationWrapper (boundary_distances , transformation = smoothing )
255+ # NOTE: this leads to issues with the parallelization, so we don't implement distance smoothing for now.
256+ # smoothing = partial(ff.gaussianSmoothing, sigma=distance_smoothing)
257+ # center_distances = SimpleTransformationWrapper(center_distances, transformation=smoothing)
258+ # boundary_distances = SimpleTransformationWrapper(boundary_distances, transformation=smoothing)
266259
267260 # Allocate an zarr array for the seeds.
268261 block_shape = center_distances .chunks
@@ -366,7 +359,6 @@ def run_unet_prediction(
366359 center_distance_threshold : float = 0.4 ,
367360 boundary_distance_threshold : Optional [float ] = None ,
368361 fg_threshold : float = 0.5 ,
369- distance_smoothing : float = 1.6 ,
370362) -> None :
371363 """Run prediction and segmentation with a distance U-Net.
372364
@@ -385,7 +377,6 @@ def run_unet_prediction(
385377 boundary_distance_threshold: The threshold applied to the boundary predictions to derive seeds.
386378 By default this is set to 'None', in which case the boundary distances are not used for the seeds.
387379 fg_threshold: The threshold applied to the foreground prediction for deriving the watershed mask.
388- distance_smoothing: The smoothing factor applied to the distance predictions.
389380 """
390381 os .makedirs (output_folder , exist_ok = True )
391382
@@ -399,8 +390,9 @@ def run_unet_prediction(
399390 pmap_out = os .path .join (output_folder , "predictions.zarr" )
400391 distance_watershed_implementation (
401392 pmap_out , output_folder , min_size = min_size , original_shape = original_shape ,
402- center_distance_threshold = center_distance_threshold , boundary_distance_threshold = boundary_distance_threshold ,
403- fg_threshold = fg_threshold , distance_smoothing = distance_smoothing ,
393+ center_distance_threshold = center_distance_threshold ,
394+ boundary_distance_threshold = boundary_distance_threshold ,
395+ fg_threshold = fg_threshold ,
404396 )
405397
406398
0 commit comments