Package: bioimageloader
bioimageloaderLoad bioimages for machine learning applicationsbioimageloaderis a python library to make it easy to load bioimage datasets for
machine learning and deep learning. Bioimages come in numerous and inhomogeneous forms.bioimageloaderattempts to wrap them in unified interfaces, so that you can easily
concatenate, perform image augmentation, and batch-load them.bioimageloaderprovidescollections of interfaces for popular and public bioimage datasetsimage augmentation usingalbumentations, which is popular and powerful
image augmentation library (for 2D images)compatibility withpytorchand with others such asscikit-learnandtensorflowTable of ContentsQuick overviewLoad a single datasetLoad multiple datasetsBatch-load datasetsbioimageloader is not/does notWhy bioimageloaderInstallationDocumentationAvailable collectionsQnAContributingContactQuick overviewFind full guides atbioimageloader-docs:User GuidesLoad a single datasetLoad and iterate2018 Data Science Bowlfrombioimageloader.collectionsimportDSB2018importalbumentationsasAtransforms=A.Compose([A.RandomCrop(width=256,height=256),A.HorizontalFlip(p=0.5),A.RandomBrightnessContrast(p=0.2),])dsb2018=DSB2018('path/to/root_dir',transforms=transforms)fordataindsb2018:image=data['image']mask=data['mask']Load multiple datasetsLoad DSB2018 andTriple Negative Breast Cancer (TNBC)frombioimageloaderimportConfig,ConcatDatasetfrombioimageloader.collectionsimportDSB2018,TNBCimportalbumentationsasAtransforms=A.Compose([A.RandomCrop(width=256,height=256),A.HorizontalFlip(p=0.5),A.RandomBrightnessContrast(p=0.2),])cfg={'DSB2018':{'root_dir':'path/to/root_dir'},'TNBC':{'root_dir':'path/to/root_dir'},}config=Config.from_dict(cfg)datasets=config.load_datasets(transforms=transforms)cat=ConcatDataset(datasets)formeowincat:image=meow['image']mask=meow['mask']Batch-load datasetfrombioimageloaderimportBatchDataloadercall_cat=BatchDataloader(cat,batch_size=16,drop_last=True,num_workers=8)formeowincall_cat:batch_image=meow['image']batch_mask=meow['mask']or directly use pytorch'sDataLoaderfromtorch.utils.dataimportDataLoadercall_cat=Dataloader(cat,batch_size=16,drop_last=True,num_workers=8)formeowincall_cat:batch_image=meow['image']batch_mask=meow['mask']bioimageloader is not/does notnota full pipeline for ML/DLnota hub to bioimage datasets (if it ever becomes one, it would be awesome though)does nothost data (only interfaces)does notprovide one-click links for downloading datadoes notoverwrite the source dataWhybioimageloaderbioimagesloaderis a by-product of my thesis. This library collected bioimage datasets
for machine learning and deep learning. I needed a lot of diverse bioimages for
self-supervised neural networks for my thesis. While I managed to find many great
datasets, they all came with different folder structures and formats. In addition, I
encountered many issues to load and process them, which were sometimes technical or just
rooted from the nature of bioimages.For instances of technical issues, some datasets were missing one or two pairs of image
and annotation, had broken files, had very specific file formats that cannot be easily
read in python, or provided mask annotation not in image format but in .xml format. Some
filenames have typos, so sometimes I failed to iterate them.For an example of intrinsic issues of bioimages, selecting a certain channel was an
important functionality that I needed, and it was not easy for bioimage datasets. When a
dataset provided separate files for each channel image, it was easy to select one. But
in many cases, they just put all channels together in one image file. And even worse for
2 channel images (which are quite common), if they chose to use RGB(A) image formats
such as JPEG or PNG other than TIFF, I needed to figure out manually which channel
refers to what and which channel is the empty one.There were other issues not mentioned above of course. It was rather painful to deal
with all these edge cases one by one. But anyway I did it and I thought it would be
valuable to package and share it with community so that others do not have to suffer,
even though the number of implemented datasets is small for the moment,InstallationInstall the latest version from PyPI.bioimageloaderrequires Python 3.8 or higher.
Find more options atbioimageloader-docs:InstallationpipinstallbioimageloaderDocumentationFull documentation is available atbioimageloader-docsAvailable collectionsGo tobioimageloader-docs:CatalogueQnAWhy no direct download link to each dataset?bioimageloaderprovides only codes (interfaces) to load data but not data itself. We
believe that it is important for you to go there, read papers, understand terms and
licenses toappreciate their works, because bioimages themselves are sciences and
results of time, efforts, and resources. You still can find links to their project pages
or papers atbioimageloader-docs:Catalogue, and you need to follow their instruction
to get data. Once you downloaded a dataset and unzipped it, (if it is supported bybioimageloader) you simply pass its root directory as the first argument to
corresponding class from collectionsbioimageloader.collections.Dataset that I want is not in thebioimageloader-docs:CatalogueFirst of all, I named each dataset class rather arbitrary. Try to find the
dataset you want with authors' names or with other keywords (if it has any), and
you may find it having an unexpected name. If it is the case, I apologize for
bad naming.If you still cannot find it, then you have two options: either you do it yourself (see
below question and please consider contributing!), or you can file an issue so that the
community can help.Don't know how to write my own dataloader.Writing a dataloader requires a bit of Python skills. No easy way. Please readtemplatescarefully and see how others are implemented. File anissue, and I am
willing to help.How to run a ML/DL model?bioimageloaderonly helps loading images/annotations, not running ML/DL
models. Still, you may find some useful examples atbioimageloader-docs:User Guides.
Also check outZeroCostDL4Mic.I want more granular control over datasets individuallyEach bioimage dataset is very unique and it is natural that users want more controls
and it was true for my work as well. Good news is thatbioimageloadersuggests a
template that you can extend from and make a subclass in your liking. Bad news is
that you need to know how to make a subclass in Python (not so bad I hope. I suppose
that you may have knowledge of Python, if you want to develop ML/DL in Python
anyway). This guideModifying existing collectionscovers it.ContributingFind guide atbioimageloader-docs:ContributingAlso check outTODO list.ContactI am open to any feedbacks, suggestions, and discussions. Reach out to me by github or
email.Seongbin LimHomepage:https://sbinnee.github.io/Email: seongbin.limatpolytechnique.edu, sungbin246atgmail.com