organoid_tracker.image_loading.builtin_merging_image_loaders module

Contains image loaders that merge several other image loaders. Examples:

  • An image loader that appends one set of images after another. >>> ChannelSummingImageLoader

  • An image loader that takes channel 1 and 2 from one set of images, and channel 3 of another. >>> ChannelAppendingImageLoader

  • An image loader that appends multiple time lapses after each other >>> TimeAppendingImageLoader

class organoid_tracker.image_loading.builtin_merging_image_loaders.ChannelAppendingImageLoader(image_loaders: List[ImageLoader])

Bases: ImageLoader

Combines multiple image loaders, showing their channels after each other.

can_save_images(image_channel: ImageChannel) bool

Returns True if images can be saved for the given channel via self.save_3d_image_array, False otherwise.

close()

Used when the image loader is no longer needed, because a user closed the tab or switched out the image loader. Closes any file handles.

copy() ImageLoader

Copies the image loader, so that you can use it on another thread.

first_time_point_number() Optional[int]

Gets the first time point for which images are available.

get_2d_image_array(time_point: TimePoint, image_channel: ImageChannel, image_z: int) Optional[ndarray]

Loads one single 2d slice of an image. Returns None if there is no image for this z, time point or channel. Note: the image z always goes from 0 to image_size_z - 1.

get_3d_image_array(time_point: TimePoint, image_channel: ImageChannel) Optional[ndarray]

Loads an image, usually from disk. Returns None if there is no image for this time point or channel.

get_channel_count() int

Gets the number of available channels.

get_image_size_zyx() Optional[Tuple[int, int, int]]

Gets the image size. Returns None if there are no images.

last_time_point_number() Optional[int]

Gets the last time point (inclusive) for which images are available.

save_3d_image_array(time_point: TimePoint, image_channel: ImageChannel, image: ndarray)

Saves the given 3D image stack to disk. If the image already exists, it will be overwritten.

Raises ValueError if the image loader does not support saving images. (Check with can_save_images() first.).

Warning: don’t call this method directly from experiment.images.image_loader().save_3d_image_array(…) because then you bypass the caching mechanism. Instead, call it as experiment.images.save_3d_image_array(…).

serialize_to_config() Tuple[str, str]

Serializes this image loader into a path and a file/series name. This can be stored in configuration files.

Note: not every image loader can be serialized fully using just two strings. There is also a newer method, self.serialize_to_dictionary(), which does contain all information.

serialize_to_dictionary() Dict[str, Any]

Serializes this image loader into a dictionary. The default implementation just uses the output of self.serialize_to_config().

uncached() ImageLoader

If this loader is a caching wrapper around another loader, this method returns one loader below. Otherwise, it returns self.

class organoid_tracker.image_loading.builtin_merging_image_loaders.ChannelSummingImageLoader(original: ImageLoader, channels: Iterable[Collection[ImageChannel]])

Bases: ImageLoader

For summing multiple image channels. Example usage:

>>> old_image_loader: ImageLoader = ...
>>> old_channels = old_image_loader.get_channels()
>>> merged_image_loader = ChannelSummingImageLoader(old_image_loader, [
>>>    [old_channels[0], old_channels[1], old_channels[2]],
>>>    [old_channels[3]]
>>> ])
can_save_images(image_channel: ImageChannel) bool

Returns True if images can be saved for the given channel via self.save_3d_image_array, False otherwise.

close()

Used when the image loader is no longer needed, because a user closed the tab or switched out the image loader. Closes any file handles.

copy() ImageLoader

Copies the image loader, so that you can use it on another thread.

first_time_point_number() Optional[int]

Gets the first time point for which images are available.

get_2d_image_array(time_point: TimePoint, image_channel: ImageChannel, image_z: int) Optional[ndarray]

Loads one single 2d slice of an image. Returns None if there is no image for this z, time point or channel. Note: the image z always goes from 0 to image_size_z - 1.

get_3d_image_array(time_point: TimePoint, image_channel: ImageChannel) Optional[ndarray]

Loads an image, usually from disk. Returns None if there is no image for this time point or channel.

get_channel_count() int

Gets the number of available channels.

get_image_size_zyx() Optional[Tuple[int, int, int]]

Gets the image size. Returns None if there are no images.

get_unmerged_image_loader() ImageLoader
last_time_point_number() Optional[int]

Gets the last time point (inclusive) for which images are available.

save_3d_image_array(time_point: TimePoint, image_channel: ImageChannel, image: ndarray)

Saves the given 3D image stack to disk. If the image already exists, it will be overwritten.

Raises ValueError if the image loader does not support saving images. (Check with can_save_images() first.).

Warning: don’t call this method directly from experiment.images.image_loader().save_3d_image_array(…) because then you bypass the caching mechanism. Instead, call it as experiment.images.save_3d_image_array(…).

serialize_to_config() Tuple[str, str]

Serializes this image loader into a path and a file/series name. This can be stored in configuration files.

Note: not every image loader can be serialized fully using just two strings. There is also a newer method, self.serialize_to_dictionary(), which does contain all information.

serialize_to_dictionary() Dict[str, Any]

Serializes this image loader into a dictionary. The default implementation just uses the output of self.serialize_to_config().

class organoid_tracker.image_loading.builtin_merging_image_loaders.TimeAppendingImageLoader(image_loaders: List[ImageLoader], min_time_point_number: int = - 1000000000.0, max_time_point_number: int = 1000000000.0)

Bases: ImageLoader

Combines to image loaders, showing images after each other.

close()

Used when the image loader is no longer needed, because a user closed the tab or switched out the image loader. Closes any file handles.

copy() ImageLoader

Copies the image loader, so that you can use it on another thread.

first_time_point_number() Optional[int]

Gets the first time point for which images are available.

get_2d_image_array(time_point: TimePoint, image_channel: ImageChannel, image_z: int) Optional[ndarray]

Loads one single 2d slice of an image. Returns None if there is no image for this z, time point or channel. Note: the image z always goes from 0 to image_size_z - 1.

get_3d_image_array(time_point: TimePoint, image_channel: ImageChannel) Optional[ndarray]

Loads an image, usually from disk. Returns None if there is no image for this time point or channel.

get_channel_count() int

Gets the number of available channels.

get_image_size_zyx() Optional[Tuple[int, int, int]]

Gets the image size. Returns None if there are no images.

last_time_point_number() Optional[int]

Gets the last time point (inclusive) for which images are available.

serialize_to_config() Tuple[str, str]

Serializes this image loader into a path and a file/series name. This can be stored in configuration files.

Note: not every image loader can be serialized fully using just two strings. There is also a newer method, self.serialize_to_dictionary(), which does contain all information.

serialize_to_dictionary() Dict[str, Any]

Serializes this image loader into a dictionary. The default implementation just uses the output of self.serialize_to_config().

uncached() ImageLoader

If this loader is a caching wrapper around another loader, this method returns one loader below. Otherwise, it returns self.