Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wela
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
wela
Commits
718a9419
Commit
718a9419
authored
10 months ago
by
pswain
Browse files
Options
Downloads
Patches
Plain Diff
change: to accommodate renaming in agora
agora.dispatch_metadata_parser to parse_metadata
parent
51b193b6
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
imageviewer.py
+18
-8
18 additions, 8 deletions
imageviewer.py
with
18 additions
and
8 deletions
imageviewer.py
+
18
−
8
View file @
718a9419
...
...
@@ -6,7 +6,7 @@ import h5py
import
napari
import
numpy
as
np
from
agora.io.cells
import
Cells
from
agora.io.metadata
import
dispatch
_metadata
_parser
from
agora.io.metadata
import
parse
_metadata
from
aliby.io.image
import
dispatch_image
from
aliby.tile.tiler
import
Tiler
...
...
@@ -43,7 +43,8 @@ class BaseImageViewer(ABC):
tiles_dict
[
ch
]
=
tiles
else
:
masks
=
[
self
.
cells
.
at_time
(
tp
,
kind
=
"
mask
"
).
get
(
trap_id
,
[])
for
tp
in
tps
self
.
cells
.
at_time
(
tp
,
kind
=
"
mask
"
).
get
(
trap_id
,
[])
for
tp
in
tps
]
# some masks may be empty
default_mask
=
[
np
.
ones
(
self
.
cells
.
tile_size
).
astype
(
bool
)]
...
...
@@ -65,10 +66,13 @@ class BaseImageViewer(ABC):
"""
Get uniquely labelled outlines for each cell time point.
"""
# get outlines for each time point
outlines
=
[
self
.
cells
.
at_time
(
tp
,
kind
=
"
edgemask
"
).
get
(
trap_id
,
[])
for
tp
in
tps
self
.
cells
.
at_time
(
tp
,
kind
=
"
edgemask
"
).
get
(
trap_id
,
[])
for
tp
in
tps
]
# get cell labels for each time point
cell_labels
=
[
self
.
cells
.
labels_at_time
(
tp
).
get
(
trap_id
,
[])
for
tp
in
tps
]
cell_labels
=
[
self
.
cells
.
labels_at_time
(
tp
).
get
(
trap_id
,
[])
for
tp
in
tps
]
# generate one image with all cell outlines uniquely labelled per tile
labelled_outlines
=
[
(
...
...
@@ -114,12 +118,16 @@ class BaseImageViewer(ABC):
channels
=
list
(
tiles_dict
.
keys
())
# put time series into one array with dimensions TCZYX
ydim
,
xdim
=
tiles_dict
[
list
(
tiles_dict
.
keys
())[
0
]][
0
].
shape
ts_images
=
np
.
zeros
((
tps
.
size
,
len
(
tiles_dict
),
1
,
ydim
,
xdim
)).
astype
(
int
)
ts_images
=
np
.
zeros
(
(
tps
.
size
,
len
(
tiles_dict
),
1
,
ydim
,
xdim
)
).
astype
(
int
)
ts_labels
=
np
.
zeros
((
tps
.
size
,
1
,
ydim
,
xdim
)).
astype
(
int
)
# make array of time series of tiles
for
ch_index
,
channel
in
enumerate
(
tiles_dict
):
for
tp_index
in
range
(
tps
.
size
):
ts_images
[
tp_index
,
ch_index
,
0
,
...]
=
tiles_dict
[
channel
][
tp_index
]
ts_images
[
tp_index
,
ch_index
,
0
,
...]
=
tiles_dict
[
channel
][
tp_index
]
# make array of time series of outlines with no channels dimension
for
tp_index
in
range
(
tps
.
size
):
ts_labels
[
tp_index
,
0
,
...]
=
outlines
[
tp_index
]
...
...
@@ -145,7 +153,9 @@ class BaseImageViewer(ABC):
tps
=
np
.
arange
(
self
.
cells
.
ntimepoints
)
elif
type
(
tps
)
is
int
:
tps
=
np
.
arange
(
tps
)
ts_images
,
ts_labels
,
channels
=
self
.
get_data_for_viewing
(
trap_id
,
tps
)
ts_images
,
ts_labels
,
channels
=
self
.
get_data_for_viewing
(
trap_id
,
tps
)
# launch napari
viewer
=
napari
.
Viewer
()
viewer
.
add_image
(
...
...
@@ -207,7 +217,7 @@ class RemoteImageViewer(BaseImageViewer):
server_info
=
server_info
or
{
k
:
self
.
attrs
[
"
parameters
"
][
"
general
"
][
k
]
for
k
in
self
.
credentials
}
logfiles_meta
=
dispatch
_metadata
_parser
(
h5file_path
.
parent
)
logfiles_meta
=
parse
_metadata
(
h5file_path
.
parent
)
image_id
=
logfiles_meta
.
get
(
"
image_id
"
)
if
image_id
is
None
:
with
h5py
.
File
(
h5file_path
,
"
r
"
)
as
f
:
...
...
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