From 70c00042c11b6fbafaf1ca0c4089a62d2f1fdd27 Mon Sep 17 00:00:00 2001 From: Jakub Kaczmarzyk Date: Thu, 29 Jun 2023 11:50:53 -0400 Subject: [PATCH] scale step size and print info Fixes https://github.com/SBU-BMI/wsinfer/issues/135 --- wsinfer/patchlib/create_patches_fp.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/wsinfer/patchlib/create_patches_fp.py b/wsinfer/patchlib/create_patches_fp.py index d488e06..1023925 100644 --- a/wsinfer/patchlib/create_patches_fp.py +++ b/wsinfer/patchlib/create_patches_fp.py @@ -305,17 +305,31 @@ def seg_and_patch( slide_mpp = get_avg_mpp(full_path) except CannotReadSpacing: print("!" * 40) - print("SKIPPINg this slide because the spacing cannot be read") + print("SKIPPING this slide because the spacing cannot be read") print("!" * 40) continue patch_size = orig_patch_size * patch_spacing / slide_mpp patch_size = round(patch_size) + print( + "Scaled patch size by the patch spacing (result is patches of" + f" {patch_size * patch_spacing} microns)" + ) + + if step_size is not None: + step_size = step_size * patch_spacing / slide_mpp + step_size = round(step_size) + print( + "Scaled step size by the patch spacing (result is steps of" + f" {step_size * patch_spacing} microns)" + ) # Use non-overlapping patches by default. # FIXME: step_size is in base pixels. But patch_size is in pixels at a # particular resolution step_size = step_size or patch_size + print(f"Using patch size = {patch_size} @ {patch_spacing} MPP") + print(f"Using step size = {step_size} @ {patch_spacing} MPP") # ---------------------------------------------------------------------- current_patch_params.update(