From 9161ccbfc5779ffa65b8950d74a67765e220c51e Mon Sep 17 00:00:00 2001 From: Christopher Rhodes <christopher.rhodes@embl.de> Date: Mon, 9 Oct 2023 11:15:11 +0200 Subject: [PATCH] Corrected bounding box annotation --- extensions/chaeo/examples/export_patch_focus_metrics.py | 2 +- extensions/chaeo/products.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/extensions/chaeo/examples/export_patch_focus_metrics.py b/extensions/chaeo/examples/export_patch_focus_metrics.py index 36e2ab76..6c963e8b 100644 --- a/extensions/chaeo/examples/export_patch_focus_metrics.py +++ b/extensions/chaeo/examples/export_patch_focus_metrics.py @@ -121,7 +121,7 @@ if __name__ == '__main__': 'mask_type': 'boxes', 'zmask_filters': {'area': (1e3, 1e8)}, 'zmask_expand_box_by': (128, 3), - 'annotate_focus_metric': 'rms_sobel' + 'annotate_focus_metric': 'max_sobel' } result = export_patch_focus_metrics_from_multichannel_zstack(**export_kwargs) diff --git a/extensions/chaeo/products.py b/extensions/chaeo/products.py index df2ac7dc..d0ec388a 100644 --- a/extensions/chaeo/products.py +++ b/extensions/chaeo/products.py @@ -98,7 +98,7 @@ def export_3d_patches_with_focus_metrics( Export 3D patches as multi-level z-stacks, along with CSV of various focus methods for each z-position :param kwargs: - annotate_focus_metric: name focus metric to use when drawing bounding box at optimal focus z-position + annotate_focus_metric: name focus metric to use when drawing bounding box at optimal focus z-position :return: list of exported files """ @@ -150,7 +150,8 @@ def export_3d_patches_with_focus_metrics( me_df = pd.DataFrame(me_dict).T # drawing bounding box only on focused slice - if ak := kwargs.get('annotate_focus_metric') in me_dict.keys(): + ak = kwargs.get('annotate_focus_metric') + if ak and ak in me_df.columns: zi_foc = me_df.idxmax().to_dict()[ak] patch[:, :, 0, zi_foc] = draw_box_on_patch( patch[:, :, 0, zi_foc], -- GitLab