Skip to content
Snippets Groups Projects
Commit 3bddfa58 authored by Alán Muñoz's avatar Alán Muñoz
Browse files

add background_max5

parent 11496d3a
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,7 @@ def exparams_from_meta(meta: Union[dict, PosixPath, str], extras=["ph"]):
"mean",
"median",
"imBackground",
"background_max5",
"max2p5pc",
"max2p5pc_med",
"max5px",
......
......@@ -4,13 +4,26 @@ import numpy as np
def imBackground(cell_masks, trap_image):
'''
"""
:param cell_masks: (numpy 3d array) cells' segmentation mask
:param trap_image: the image for the trap in which the cell is (all
channels)
'''
"""
if not len(cell_masks):
cell_masks = np.zeros_like(trap_image)
background = ~cell_masks.sum(axis=2).astype(bool)
return (np.median(trap_image[np.where(background)]))
return np.median(trap_image[np.where(background)])
def background_max5(cell_masks, trap_image):
"""
:param cell_masks: (numpy 3d array) cells' segmentation mask
:param trap_image: the image for the trap in which the cell is (all
channels)
"""
if not len(cell_masks):
cell_masks = np.zeros_like(trap_image)
background = ~cell_masks.sum(axis=2).astype(bool)
return np.mean(np.sort(trap_image[np.where(background)])[-5:])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment