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_dirPath to root directory
outputDetermine return(s) when called, fixed to ‘image’
transformsTransform images and masks
num_samplesNumber of calls that will override __len__
grayscaleoptionalFlag for grayscale conversion
grayscale_modeoptionalDetermine grayscale mode one of {‘cv2’, ‘equal’, Sequence[float]}
num_channelsoptionalNumber 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 asacronymand_root_dirfor each subclass.See also
Datasetsuper 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
outputargument- 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]#