bioimageloader.common#

(experimental) Easily load unknown datasets as Dataset or as MaskDataset

Common dataset is a dataset which has expected structures that bioimageloader can easily access. Simply provide a path to root directory.

This module is experimental.

Currently it assumes two cases for MaskDataset,

>>> 1. case: only images
    case1/
    ├── image00.tif
    ├── image01.tif
    ├── image02.tif
    ├── image03.tif
    ├── image04.tif
    ├── image05.tif
    ├── image06.tif
    ├── image07.tif
    ├── image08.tif
    └── image09.tif
>>> 2. case: images in "images/" and labels in "labels/"
    case3/
    ├── images
    │   ├── 00.png
    │   ├── 01.png
    │   ├── 02.png
    │   ├── 03.png
    │   └── 04.png
    └── labels
        ├── 00.tif
        ├── 01.tif
        ├── 02.tif
        ├── 03.tif
        └── 04.tif

Examples#

Case 1:

>>> dataset = CommonDataset('./Data/case1')

Case 3:

>>> dataset = CommonMaskDataset('./Data/case3')

see also utils.get_maskdatasets_from_directory

>>> datset = get_maskdataset_from_directory(
        './Data/case3',
        image_dir='images',
        labels='labels',
    )
class bioimageloader.common.CommonDataset(root_dir, *, output: Optional[str] = None, transforms: Optional[albumentations.core.composition.Compose] = None, num_samples: Optional[int] = None, grayscale: Optional[bool] = None, grayscale_mode: Optional[Union[str, Sequence[float]]] = None, **kwargs)[source]#

Load a dataset thas has a common structure

Parameters
root_dir
outputoptional
transformsoptional
num_samplesoptional
grayscaleoptional
grayscale_modeoptional
num_channelsoptional

See also

Dataset

super class

bioimageloader.utils.get_dataset_from_directory

util

Attributes
image_dir
file_list

Methods

get_image(p)

Get an image

_setattr_ifvalue(attr[, value])

Set attribute if value is not None

_filter_known_ext(p)

Filter extensions supported by PIL and tifffile

property file_list#

A list of pathes to image files

get_image(p: pathlib.Path) numpy.ndarray[source]#

Get an image

class bioimageloader.common.CommonMaskDataset(root_dir, *, output: Optional[str] = None, transforms: Optional[albumentations.core.composition.Compose] = None, num_samples: Optional[int] = None, grayscale: Optional[bool] = None, grayscale_mode: Optional[Union[str, Sequence[float]]] = None, **kwargs)[source]#

Load a dataset thas has a common structure with its mask annotation

Call this from bioimageloader.utils.get_maskdataset_from_directory()

Parameters
root_dir
outputoptional
transformsoptional
num_samplesoptional
grayscaleoptional
grayscale_modeoptional
num_channelsoptional

See also

MaskDataset

super class

CommonDataset

super class

bioimageloader.utils.get_maskdataset_from_directory

util

Attributes
image_dir
mask_dir
file_list
anno_dict

Methods

get_image(p)

Get an image

get_mask(p)

Get a mask

property file_list#

A list of pathes to image files

property anno_dict#

Dictionary of pathes to annotation files

get_mask(p: pathlib.Path) numpy.ndarray[source]#

Get a mask