The Extractor applies a metric, such as area or median, to image tiles using the cell masks.
Its methods therefore require both tile images and masks.
Usually one metric is applied per mask, but there are tile-specific backgrounds, which apply one metric per tile.
Extraction follows a three-level tree structure. Channels, such as GFP, are the root level; the second level is the reduction algorithm, such as maximum projection; the last level is the metric -- the specific operation to apply to the cells in the image identified by the mask, such as median -- the median value of the pixels in each cell.
"""
importlogging
importlogging
importtypingast
fromtimeimportperf_counter
fromtimeimportperf_counter
fromtypingimportCallable,Dict,List
fromtypingimportCallable,Dict,List
...
@@ -323,23 +333,24 @@ class Extractor(ProcessABC):
...
@@ -323,23 +333,24 @@ class Extractor(ProcessABC):
masks=None,
masks=None,
labels=None,
labels=None,
**kwargs,
**kwargs,
)->dict:
)->t.Dict[str,t.Dict[str,pd.Series]]:
"""Core extraction method for an individual time-point.
"""
Core extraction method for an individual time-point.
Parameters
Parameters
----------
----------
tp : int
tp : int
Time-point being analysed.
Timepoint being analysed.
tree : dict
tree : dict
Nested dictionary indicating channels, reduction functions and
Nested dictionary indicating channels, reduction functions and
metrics to use during extraction.
metrics to be used.
tile_size : int
tile_size : int
size of the tile to be extracted.
size of the tile to be extracted.
masks : np.ndarray
masks : np.ndarray
3-D boolean numpy array with dimensions (ncells, tile_size,
A 3-D boolean numpy array with dimensions (ncells, tile_size,
tile_size.
tile_size).
labels : t.List[t.List[int]]
labels : t.List[t.List[int]]
List of list of ints indicating the ids of masks.
List of lists of ints indicating the ids of masks.
**kwargs : Additional keyword arguments to be passed to extractor.reduce_extract.
**kwargs : Additional keyword arguments to be passed to extractor.reduce_extract.
Returns
Returns
...
@@ -352,11 +363,12 @@ class Extractor(ProcessABC):
...
@@ -352,11 +363,12 @@ class Extractor(ProcessABC):
"""
"""
iftreeisNone:
iftreeisNone:
# use default
tree=self.params.tree
tree=self.params.tree
# dictionary with channel: {reduction algorithm : metric}