organoid_tracker.core.image_loader module
- class organoid_tracker.core.image_loader.ImageChannel(*, index_zero: Optional[int] = None, index_one: Optional[int] = None)
Bases:
object
Represents an image channel - for example, the bright field channel, the red channel, etc. The image loader is responsible for the numbering. The first channel must have number 1, the second number 2, etc.
- class organoid_tracker.core.image_loader.ImageLoader
Bases:
ABC
Responsible for loading all images in an experiment.
- 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.
- abstract copy() ImageLoader
Copies the image loader, so that you can use it on another thread.
- first_time_point() Optional[TimePoint]
Gets the first time point for which images are available. Uses first_time_point_number() under the hood.
- abstract first_time_point_number() Optional[int]
Gets the first time point for which images are available.
- abstract 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.
- abstract 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_channels() List[ImageChannel]
Gets a list of all available image channels.
- abstract get_image_size_zyx() Optional[Tuple[int, int, int]]
Gets the image size. Returns None if there are no images.
- has_images() bool
Returns True if there are any images loaded, False otherwise.
The default implementation just checks if get_image_size_zyx() returns something. If yes, then it is assumed that there are images stored.
- last_time_point() Optional[TimePoint]
Gets the last time point for which images are available. Uses last_time_point_number() under the hood.
- abstract 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(…).
- abstract 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.core.image_loader.NullImageLoader
Bases:
ImageLoader
- copy() ImageLoader
Copies the image loader, so that you can use it on another thread.
- 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_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.