From 8e2efc00654614224a81adfb43c523ed391adaab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Al=C3=A1n=20Mu=C3=B1oz?= <alan.munoz@ed.ac.uk> Date: Fri, 17 Mar 2023 19:42:52 +0000 Subject: [PATCH] docs(readme): refresh RemoteImageViewer info --- README.md | 16 +++++++++++----- src/aliby/utils/imageViewer.py | 24 ++++++++++++------------ 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 98c1d528..4c4e84c7 100644 --- a/README.md +++ b/README.md @@ -80,12 +80,18 @@ It fetches the metadata from the Image object, and uses the TilerParameters valu ```python fpath = "h5/location" -trap_id = 9 -trange = list(range(0, 30)) +tile_id = 9 +trange = range(0, 10) ncols = 8 riv = remoteImageViewer(fpath) -trap_tps = riv.get_trap_timepoints(trap_id, trange, ncols) +trap_tps = [riv.tiler.get_tiles_timepoint(tile_id, t) for t in trange] + +# You can also access labelled traps +m_ts = riv.get_labelled_trap(tile_id=0, tps=[0]) + +# And plot them directly +riv.plot_labelled_trap(trap_id=0, channels=[0, 1, 2, 3], trange=range(10)) ``` Depending on the network speed can take several seconds at the moment. @@ -95,8 +101,8 @@ For a speed-up: take fewer z-positions if you can. Alternatively, if you want to get all the traps at a given timepoint: ```python -timepoint = 0 -seg_expt.get_tiles_timepoints(timepoint, tile_size=96, channels=None, +timepoint = (4,6) +tiler.get_tiles_timepoint(timepoint, channels=None, z=[0,1,2,3,4]) ``` diff --git a/src/aliby/utils/imageViewer.py b/src/aliby/utils/imageViewer.py index f97f2fb0..5e9f0a04 100644 --- a/src/aliby/utils/imageViewer.py +++ b/src/aliby/utils/imageViewer.py @@ -6,12 +6,12 @@ Example of usage: fpath = "/home/alan/Documents/dev/skeletons/scripts/data/16543_2019_07_16_aggregates_CTP_switch_2_0glu_0_0glu_URA7young_URA8young_URA8old_01/URA8_young018.h5" -trap_id = 9 -trange = list(range(0, 30)) +tile_id = 9 +trange = list(range(0, 10)) ncols = 8 riv = remoteImageViewer(fpath) -riv.plot_labelled_trap(trap_id, trange, [0], ncols=ncols) +riv.plot_labelled_trap(tile_id, trange, [0], ncols=ncols) """ @@ -224,7 +224,7 @@ class RemoteImageViewer(BaseImageViewer): def get_labelled_trap( self, - trap_id: int, + tile_id: int, tps: t.Union[range, t.Collection[int]], channels=None, concatenate=True, @@ -234,12 +234,12 @@ class RemoteImageViewer(BaseImageViewer): Core method to fetch traps and labels together """ imgs = self.get_pos_timepoints(tps, channels=channels, **kwargs) - imgs_list = [x[trap_id] for x in imgs.values()] + imgs_list = [x[tile_id] for x in imgs.values()] outlines = [ - self.cells.at_time(tp, kind="edgemask").get(trap_id, []) + self.cells.at_time(tp, kind="edgemask").get(tile_id, []) for tp in tps ] - lbls = [self.cells.labels_at_time(tp).get(trap_id, []) for tp in tps] + lbls = [self.cells.labels_at_time(tp).get(tile_id, []) for tp in tps] lbld_outlines = [ np.stack([mask * lbl for mask, lbl in zip(maskset, lblset)]).max( axis=0 @@ -253,7 +253,7 @@ class RemoteImageViewer(BaseImageViewer): imgs_list = np.concatenate(imgs_list, axis=1) return lbld_outlines, imgs_list - def get_images(self, trap_id, trange, channels, **kwargs): + def get_images(self, tile_id, trange, channels, **kwargs): """ Wrapper to fetch images """ @@ -262,13 +262,13 @@ class RemoteImageViewer(BaseImageViewer): for ch in self._find_channels(channels): out, imgs[ch] = self.get_labelled_trap( - trap_id, trange, channels=[ch], **kwargs + tile_id, trange, channels=[ch], **kwargs ) return out, imgs def plot_labelled_trap( self, - trap_id: int, + tile_id: int, channels, trange: t.Union[range, t.Collection[int]], remove_axis: bool = False, @@ -288,7 +288,7 @@ class RemoteImageViewer(BaseImageViewer): Parameters ---------- - trap_id : int + tile_id : int Identifier of trap channels : Union[str, int] Channels to use @@ -325,7 +325,7 @@ class RemoteImageViewer(BaseImageViewer): nrows = int(np.ceil(len(trange) / ncols)) width = self.tiler.tile_size * ncols - out, images = self.get_images(trap_id, trange, channels, **kwargs) + out, images = self.get_images(tile_id, trange, channels, **kwargs) # dilation makes outlines easier to see out = dilation(out).astype(float) -- GitLab