aliby.tile.tiler.Tiler

class Tiler(image, metadata, parameters, trap_locs=None)[source]

Bases: StepABC

Remote Timelapse Tiler.

Finds traps and re-registers images if there is any drifting. Fetches images from a server.

Uses an Image instance, which lazily provides the data on pixels, and, as an independent argument, metadata.

Attributes
n_processed

Returns the number of images that have been processed

n_traps

Returns number of traps

parameters
ref_channel_index
shape

Returns properties of the time-lapse as shown by self.image.shape

Methods

dummy(parameters)

Instantiate dummy Tiler from dummy image

find_drift(tp)

Find any translational drift between two images at consecutive time points using cross correlation.

from_h5(image, filepath[, parameters])

Instantiate Tiler from hdf5 files

from_image(image, parameters)

Instantiate Tiler from an Image instance

get_channel_index(channel)

Find index for channel using regex.

get_tc(t, c)

Load image using dask. Assumes the image is arranged as no of time points no of channels no of z stacks no of pixels in y direction no of pixels in x direction.

get_tiles_timepoint(tp[, tile_shape, ...])

Get a multidimensional array with all tiles for a set of channels and z-stacks.

get_tp_data(tp, c)

Returns all traps corrected for drift.

get_trap_data(trap_id, tp, c)

Returns a particular trap corrected for drift and padding

ifoob_pad(full, slices)

Returns the slices padded if it is out of bounds.

initialise_traps([tile_size])

Find initial trap positions if they have not been initialised.

run([time_dim])

Tile all time points in an experiment at once.

run_tp(**kwargs)

get_traps_timepoint

Initialise Tiler

Parameters
image: an instance of Image
metadata: dictionary
parameters: an instance of TilerPameters
trap_locs: (optional)
Attributes
n_processed

Returns the number of images that have been processed

n_traps

Returns number of traps

parameters
ref_channel_index
shape

Returns properties of the time-lapse as shown by self.image.shape

Methods

dummy(parameters)

Instantiate dummy Tiler from dummy image

find_drift(tp)

Find any translational drift between two images at consecutive time points using cross correlation.

from_h5(image, filepath[, parameters])

Instantiate Tiler from hdf5 files

from_image(image, parameters)

Instantiate Tiler from an Image instance

get_channel_index(channel)

Find index for channel using regex.

get_tc(t, c)

Load image using dask. Assumes the image is arranged as no of time points no of channels no of z stacks no of pixels in y direction no of pixels in x direction.

get_tiles_timepoint(tp[, tile_shape, ...])

Get a multidimensional array with all tiles for a set of channels and z-stacks.

get_tp_data(tp, c)

Returns all traps corrected for drift.

get_trap_data(trap_id, tp, c)

Returns a particular trap corrected for drift and padding

ifoob_pad(full, slices)

Returns the slices padded if it is out of bounds.

initialise_traps([tile_size])

Find initial trap positions if they have not been initialised.

run([time_dim])

Tile all time points in an experiment at once.

run_tp(**kwargs)

get_traps_timepoint

__init__(image, metadata, parameters, trap_locs=None)[source]

Initialise Tiler

Parameters
image: an instance of Image
metadata: dictionary
parameters: an instance of TilerPameters
trap_locs: (optional)

Methods

__init__(image, metadata, parameters[, ...])

Initialise Tiler

dummy(parameters)

Instantiate dummy Tiler from dummy image

find_drift(tp)

Find any translational drift between two images at consecutive time points using cross correlation.

from_h5(image, filepath[, parameters])

Instantiate Tiler from hdf5 files

from_image(image, parameters)

Instantiate Tiler from an Image instance

get_channel_index(channel)

Find index for channel using regex.

get_tc(t, c)

Load image using dask. Assumes the image is arranged as no of time points no of channels no of z stacks no of pixels in y direction no of pixels in x direction.

get_tiles_timepoint(tp[, tile_shape, ...])

Get a multidimensional array with all tiles for a set of channels and z-stacks.

get_tp_data(tp, c)

Returns all traps corrected for drift.

get_trap_data(trap_id, tp, c)

Returns a particular trap corrected for drift and padding

get_traps_timepoint(*args, **kwargs)

ifoob_pad(full, slices)

Returns the slices padded if it is out of bounds.

initialise_traps([tile_size])

Find initial trap positions if they have not been initialised.

run([time_dim])

Tile all time points in an experiment at once.

run_tp(**kwargs)

Attributes

n_processed

Returns the number of images that have been processed

n_traps

Returns number of traps

parameters

ref_channel_index

shape

Returns properties of the time-lapse as shown by self.image.shape

classmethod dummy(parameters)[source]

Instantiate dummy Tiler from dummy image

If image.dimorder exists dimensions are saved in that order. Otherwise default to “tczyx”.

Parameters
parameters: dictionary output of an instance of TilerParameters
find_drift(tp)[source]

Find any translational drift between two images at consecutive time points using cross correlation.

classmethod from_h5(image, filepath, parameters=None)[source]

Instantiate Tiler from hdf5 files

Parameters
image: an instance of Image
filepath: Path instance

Path to a directory of h5 files

parameters: an instance of TileParameters (optional)
classmethod from_image(image, parameters)[source]

Instantiate Tiler from an Image instance

Parameters
image: an instance of Image
parameters: an instance of TilerPameters
get_channel_index(channel)[source]

Find index for channel using regex. Returns the first matched string.

Parameters
channel: string or int

The channel or index to be used

get_tc(t, c)[source]

Load image using dask. Assumes the image is arranged as

no of time points no of channels no of z stacks no of pixels in y direction no of pixels in x direction

Parameters
t: integer

An index for a time point

c: integer

An index for a channel

get_tiles_timepoint(tp, tile_shape=None, channels=None, z=0)[source]

Get a multidimensional array with all tiles for a set of channels and z-stacks.

Used by extractor.

Parameters

tp: int

Index of time point

tile_shape: int or tuple of two ints

Size of tile in x and y dimensions

channels: string or list of strings

Names of channels of interest

z: int

Index of z-channel of interest

Returns
res: array

Data arranged as (traps, channels, timepoints, X, Y, Z)

rtype

ndarray ..

get_tp_data(tp, c)[source]

Returns all traps corrected for drift.

Parameters
tp: integer

An index for a time point

c: integer

An index for a channel

get_trap_data(trap_id, tp, c)[source]

Returns a particular trap corrected for drift and padding

Parameters
trap_id: integer

Number of trap

tp: integer

Index of time points

c: integer

Index of channel

Returns
ndtrap: array

An array of (x, y) arrays, one for each z stack

static ifoob_pad(full, slices)[source]

Returns the slices padded if it is out of bounds.

Parameters
full: array

Slice of OMERO image (zstacks, x, y) - the entire position with zstacks as first axis

slices: tuple of two slices

Delineates indiceds for the x- and y- ranges of the tile.

Returns
trap: array

A tile with all z stacks for the given slices. If some padding is needed, the median of the image is used. If much padding is needed, a tile of NaN is returned.

initialise_traps(tile_size=None)[source]

Find initial trap positions if they have not been initialised. Removes all those that are too close to the edge so no padding is necessary.

Parameters
tile_size: integer

The size of a tile

property n_processed

Returns the number of images that have been processed

property n_traps

Returns number of traps

run(time_dim=None)[source]

Tile all time points in an experiment at once.

property shape

Returns properties of the time-lapse as shown by self.image.shape