Skip to content

Commit 8efb98f

Browse files
committed
Updated criteria for IHC mask creation
1 parent 4b37372 commit 8efb98f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

flamingo_tools/segmentation/unet_prediction.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,15 @@ def find_mask(input_path: str, input_key: Optional[str], output_folder: str, seg
198198
if seg_class == "sgn":
199199
upper_percentile = 95
200200
min_intensity = 200
201+
print(f"Calculating mask for segmentation class {seg_class}.")
201202
elif seg_class == "ihc":
202-
upper_percentile = 98
203+
upper_percentile = 99
203204
min_intensity = 150
205+
print(f"Calculating mask for segmentation class {seg_class}.")
204206
else:
205207
upper_percentile = 95
206208
min_intensity = 200
209+
print("Calculating mask with default values.")
207210

208211
mask_key = "mask"
209212
if mask_key in f:
@@ -373,6 +376,7 @@ def run_unet_prediction(
373376
center_distance_threshold: float = 0.4,
374377
boundary_distance_threshold: Optional[float] = None,
375378
fg_threshold: float = 0.5,
379+
seg_class: Optional[str] = None,
376380
) -> None:
377381
"""Run prediction and segmentation with a distance U-Net.
378382
@@ -391,12 +395,12 @@ def run_unet_prediction(
391395
boundary_distance_threshold: The threshold applied to the boundary predictions to derive seeds.
392396
By default this is set to 'None', in which case the boundary distances are not used for the seeds.
393397
fg_threshold: The threshold applied to the foreground prediction for deriving the watershed mask.
398+
seg_class: Specifier for exclusion criterias for mask generation.
394399
"""
395400
os.makedirs(output_folder, exist_ok=True)
396401

397402
if use_mask:
398-
find_mask(input_path, input_key, output_folder)
399-
403+
find_mask(input_path, input_key, output_folder, seg_class=seg_class)
400404
original_shape = prediction_impl(
401405
input_path, input_key, output_folder, model_path, scale, block_shape, halo
402406
)

0 commit comments

Comments
 (0)