Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
alibylite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Swain Lab
aliby
alibylite
Commits
54a75131
Commit
54a75131
authored
2 years ago
by
Alán Muñoz
Browse files
Options
Downloads
Patches
Plain Diff
style(extractor): Improve typing
parent
5d439842
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
extraction/core/extractor.py
+10
-11
10 additions, 11 deletions
extraction/core/extractor.py
with
10 additions
and
11 deletions
extraction/core/extractor.py
+
10
−
11
View file @
54a75131
...
@@ -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
t
rap
s
is
not
None
and
len
(
traps
):
if
ch
!=
"
general
"
and
t
ile
s
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
=
t
rap
s
[:,
tree_chs
.
index
(
ch
),
0
]
img
=
t
ile
s
[:,
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
]
=
[]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment