From a4ca5e900652d563efa0107342d30b816846720b Mon Sep 17 00:00:00 2001 From: Nikolay Akhmetov Date: Mon, 26 Jan 2026 16:26:45 -0500 Subject: [PATCH] Add logic to handle `has_visualization` for segmentation mask epics --- .../portal/add_assay_details.py | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/hubmap_translation/addl_index_transformations/portal/add_assay_details.py b/src/hubmap_translation/addl_index_transformations/portal/add_assay_details.py index c913195e..7f78e7d6 100644 --- a/src/hubmap_translation/addl_index_transformations/portal/add_assay_details.py +++ b/src/hubmap_translation/addl_index_transformations/portal/add_assay_details.py @@ -203,6 +203,23 @@ def get_assay_type_for_descendants(descendant): _set_soft_assaytype(descendant, soft_assay_info) - if has_visualization(descendant, get_assay_type_for_descendants, parent_uuid): - doc['visualization'] = True - descendant['visualization'] = True + # Determine epic_uuid for segmentation masks + # epic_uuid only gets set if the descendant has segmentation_mask/epic hint + epic_uuid = None + descendant_hints = descendant.get("vitessce-hints", []) + + if ( + "segmentation_mask" in descendant_hints + and "epic" in descendant_hints + and descendant.get("status") != "Error" + ): + epic_uuid = descendant.get("uuid") + + if has_visualization( + descendant, + get_assay_type_for_descendants, + parent=parent_uuid, + epic_uuid=epic_uuid, + ): + doc["visualization"] = True + descendant["visualization"] = True