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

style(extractor): Improve typing

parent 5d439842
No related branches found
No related tags found
No related merge requests found
...@@ -46,7 +46,7 @@ class ExtractorParameters(ParametersABC): ...@@ -46,7 +46,7 @@ class ExtractorParameters(ParametersABC):
def __init__( def __init__(
self, self,
tree: t.Dict[str, t.Dict[reduction_method, t.Collection[str]]], tree: extraction_tree,
sub_bg: set = set(), sub_bg: set = set(),
multichannel_ops: t.Dict = {}, multichannel_ops: t.Dict = {},
): ):
...@@ -260,12 +260,11 @@ class Extractor(ProcessABC): ...@@ -260,12 +260,11 @@ class Extractor(ProcessABC):
# a subset of channels was specified # a subset of channels was specified
channel_ids = [self.tiler.get_channel_index(ch) for ch in channels] channel_ids = [self.tiler.get_channel_index(ch) for ch in channels]
else: else:
# oh oh # a list of the indices of the z stacks
channel_ids = None channel_ids = None
# a list of the indices of the z stacks
if z is None: if z is None:
z = list(range(self.tiler.shape[-1])) # gets the tiles data via tiler
# gets the data via tiler z: t.List[int] = list(range(self.tiler.shape[-1]))
tiles = ( tiles = (
self.tiler.get_tiles_timepoint( self.tiler.get_tiles_timepoint(
tp, channels=channel_ids, z=z, **kwargs tp, channels=channel_ids, z=z, **kwargs
...@@ -456,7 +455,7 @@ class Extractor(ProcessABC): ...@@ -456,7 +455,7 @@ class Extractor(ProcessABC):
""" """
if tree is None: if tree is None:
# use default # use default
tree = self.params.tree tree: extraction_tree = self.params.tree
# dictionary with channel: {reduction algorithm : metric} # dictionary with channel: {reduction algorithm : metric}
ch_tree = {ch: v for ch, v in tree.items() if ch != "general"} ch_tree = {ch: v for ch, v in tree.items() if ch != "general"}
# tuple of the channels # tuple of the channels
...@@ -484,10 +483,10 @@ class Extractor(ProcessABC): ...@@ -484,10 +483,10 @@ class Extractor(ProcessABC):
# find image data at the time point # find image data at the time point
# stored as an array arranged as (traps, channels, timepoints, X, Y, Z) # stored as an array arranged as (traps, channels, timepoints, X, Y, Z)
# Alan: traps does not appear the best name here! tiles = self.get_tiles(tp, tile_shape=tile_size, channels=tree_chs)
traps = self.get_tiles(tp, tile_shape=tile_size, channels=tree_chs)
# generate boolean masks for background as a list with one mask per trap # generate boolean masks for background as a list with one mask per trap
bgs = []
if self.params.sub_bg: if self.params.sub_bg:
bgs = [ bgs = [
~np.sum(m, axis=2).astype(bool) ~np.sum(m, axis=2).astype(bool)
...@@ -501,10 +500,10 @@ class Extractor(ProcessABC): ...@@ -501,10 +500,10 @@ class Extractor(ProcessABC):
self.img_bgsub = {} self.img_bgsub = {}
for ch, red_metrics in tree.items(): for ch, red_metrics in tree.items():
# NB ch != is necessary for threading # NB ch != is necessary for threading
if ch != "general" and traps is not None and len(traps): if ch != "general" and tiles is not None and len(traps):
# image data for all traps and z sections for a particular channel # image data for all traps and z sections for a particular channel
# as an array arranged as (no traps, X, Y, no Z channels) # as an array arranged as (no traps, X, Y, no Z channels)
img = traps[:, tree_chs.index(ch), 0] img = tiles[:, tree_chs.index(ch), 0]
else: else:
img = None img = None
# apply metrics to image data # apply metrics to image data
...@@ -516,7 +515,7 @@ class Extractor(ProcessABC): ...@@ -516,7 +515,7 @@ class Extractor(ProcessABC):
**kwargs, **kwargs,
) )
# apply metrics to image data with the background subtracted # apply metrics to image data with the background subtracted
if ch in self.params.sub_bg and img is not None: if bgs and ch in self.params.sub_bg and img is not None:
# calculate metrics with subtracted bg # calculate metrics with subtracted bg
ch_bs = ch + "_bgsub" ch_bs = ch + "_bgsub"
self.img_bgsub[ch_bs] = [] self.img_bgsub[ch_bs] = []
......
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