bioimageloader.base#
Define a base class and its interface
Dataset
is the base of all datasets
MaskDataset
is the base of datasets that have mask annotation
- class bioimageloader.base.DatasetInterface[source]#
Dataset interface
- Attributes
Methods
get_image
(key)Get an image
- abstract class property acronym#
Assign acroym for a subclass dataset
- abstract property root_dir#
Path to root directory
- property file_list#
A list of pathes to image files
- class bioimageloader.base.Dataset[source]#
Base to define common attributes and methods for [MaskDataset, …]
Notes
- Required attributes in subclass
anno_dict
__getitem__()
get_image()
- Attributes
__repr__
Print info of dataset
__len__
Length of dataset.
- __iter__
root_dir
Path to root directory
output
Determine return(s) when called, fixed to ‘image’
transforms
Transform images and masks
num_samples
Number of calls that will override __len__
grayscale
optionalFlag for grayscale conversion
grayscale_mode
optionalDetermine grayscale mode one of {‘cv2’, ‘equal’, Sequence[float]}
num_channels
optionalNumber of image channels used for to_gray()
Methods
__getitem__
(ind)Get image
_drop_missing_pairs
()Drop images and reindex the anno list (dict)
to_gray
(arr[, grayscale_mode, num_channels])Convert bioimage to grayscale
- property root_dir: pathlib.Path#
Path to root directory
- property output: str#
Determine return(s) when called, fixed to ‘image’
- property transforms: Optional[albumentations.core.composition.Compose]#
Transform images and masks
- property num_samples: Optional[int]#
Number of calls that will override __len__
- property grayscale: Optional[bool]#
Flag for grayscale conversion
- property grayscale_mode: Optional[Union[str, Sequence[float]]]#
Determine grayscale mode one of {‘cv2’, ‘equal’, Sequence[float]}
- property num_channels: Optional[int]#
Number of image channels used for to_gray()
- static to_gray(arr: numpy.ndarray, grayscale_mode: Optional[Union[str, Sequence[float]]] = None, num_channels: int = 3) numpy.ndarray [source]#
Convert bioimage to grayscale
- Parameters
- arrimage array
Numpy image array whose shape is (h, w, 3)
- grayscale_modestr or sequence of float, optional
Choose a strategy for gray conversion. Three options are availble. Either one of {‘cv2’, ‘equal’} or be a sequence of float numbers, which indicate linear weights of each channel.
- num_channelsint
Explicitly set number of channels for grayscale_mode=’equal’.
- class bioimageloader.base.MaskDataset[source]#
Base for datasets with mask annotation
Define
__getitem__
method to load mask annotation paired with image. Pre-defined attributes are prefixed with a single underscore to distinguish them from those specific to a dataset. It is required to implement two methods:get_image()
andget_mask()
as well asacronym
and_root_dir
for each subclass.See also
Dataset
super class
Notes
- Required attributes in subclass
acronym
_root_dir
_output
_grayscale
(optional)_grayscale_mode
(optional)_num_channels
(optional)get_image()
get_mask()
(optional)
Methods
__getitem__
(ind)Get image, mask, or both depending on
output
argument- property output: str#
Determine return(s) when called
- property anno_dict: Dict[int, Any]#
Dictionary of pathes to annotation files
- class bioimageloader.base.IterDataset(dataset: bioimageloader.base.Dataset)[source]#