From 57b145c6ab9013213cb32a2f8b7e1992d48446a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Al=C3=A1n=20Mu=C3=B1oz?= <amuoz@ed.ac.uk> Date: Thu, 3 Feb 2022 10:57:57 +0000 Subject: [PATCH] add foci_area_otsu extraction cellfun --- extraction/core/functions/cell.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/extraction/core/functions/cell.py b/extraction/core/functions/cell.py index 19f13940..5d9ca018 100644 --- a/extraction/core/functions/cell.py +++ b/extraction/core/functions/cell.py @@ -70,6 +70,15 @@ def max2p5pc_med(cell_mask, trap_image): return max2p5pc / med if med else max2p5pc +def foci_area_otsu(cell_mask, trap_image): + # Use otsu threshold to calculate the are of high-expression blobs inside a cell. + cell_pixels = trap_image[cell_mask] + cell_pixels = cell_pixels[~np.isnan(cell_pixels)] + threshold = threshold_otsu(cell_pixels) + + return np.sum(cell_pixels > threshold) + + def std(cell_mask, trap_image): return np.std(trap_image[np.where(cell_mask)], dtype=float) -- GitLab