How to contribute
In this section, the structure of BiaPy and the various steps involved in executing a workflow are outlined. The goal is to provide guidance to future contributors on where to modify the library in order to add new features. It is recommended to first read the How it works section, as it provides an overview of the overall functioning of BiaPy. The steps involved are as follows:
In the
biapy/config/config.py
file, all the variables that the user can define in the.yaml
file are defined. This is where new workflow-specific variables should be added.In the
biapy/engine/check_configuration.py
file, the checks for the workflow variables should be added.All the workflow extend the class Base_Workflow in
biapy/engine/base_workflow.py
.During training, all the steps that a workflow must follow are listed in the first lines of train() function.
There are two main classes of generators:
PairBaseDataGenerator
which is extended byPair2DImageDataGenerator
(for 2D data) orPair3DImageDataGenerator
(for3D
data). These generators yield the image and its mask, and all data augmentation (DA) techniques are done considering the mask as well. These generators are used for all workflows except classification.SingleBaseDataGenerator
which is extended bySingle2DImageDataGenerator
(for 2D data) orSingle3DImageDataGenerator
(for3D
data). These generators yield the image and its class (integer). These generators are used for classification workflows. BiaPy uses the imgaug library, so when adding new DA methods, it’s recommended to check if it has already been implemented by that library. Custom DA techniques can be placed in thedata/generators/augmentors.py
file.
The next step after the data and generator process is to define the model. A new model should be added to the
biapy.models
folder and constructed in thebiapy.models/init.py
file. Following this, the training process can begin.The model function call is done by model_call_func, where depending on the backend used the model call is adapted.
During test/inference, all the steps that a workflow must follow are listed in the first lines of test() function. There are two ways of do inference:
By using
process_sample()
, where each test image is predicted by patches and reconstructed in an output TIF file. This method aims to deal with small and medium image sizes.By using
process_sample_by_chunks()
, where the model prediction is reconstructed using Zarr/H5 files to avoid large memory footprint. This method is used for large files.