Skip to content
Snippets Groups Projects
Commit 718a9419 authored by pswain's avatar pswain
Browse files

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
......@@ -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:
......
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