The backend for the nucleAIzer nuclei segmentation method.
Project description
nucleaizer_backend
Overview
This package contains the code needed to execute the nucleAIzer nuclei segmentation algorithm. A Mask R-CNN and a pix2pix implementation is embedded.
Description of the method: "Hollandi et al.: nucleAIzer: A Parameter-free Deep Learning Framework for Nucleus Segmentation Using Image Style Transfer, Cell Systems, 2020. https://doi.org/10.1016/j.cels.2020.04.003"
This is a cleaned, simplified python interface for the algorithm (https://github.com/spreka/biomagdsb) (This prediction and training through command line)
If you want to use the web version, visit: http://nucleaizer.org (only prediction).
Requirements
The nucleaizer backend runs on Windows and Linux only. MacOS is not supported yet.
Prediction
Thre prediction runs on any machine where tensorflow
is supported.
Training
Some of the functionalities in our training code are implemented as MATLAB scripts. (See the full training code in https://github.com/spreka/biomagdsb repo.)
Therefore, a MATLAB (or MATLAB Runtime on Linux) is needed to execute the training.
-
If you have MATLAB, the
biomagdsb
repository (containing the code) is pulled from git by the training script automatically to your home folder. Then, the scripts are executed with thematlab
command (in headless mode). This method is supported on Windows an Linux.- If you do not have matlab on the system path, set the
MATLAB_COMMAND
environment variable pointing to thematlab
binary.
- If you do not have matlab on the system path, set the
-
If you do not have a MATLAB license, you can install the MATLAB Runtime. The MATLAB code can execute the compiled version of the sciprt. Currently, we only have compiled versions for Linux. If you choose this option, the training script automatically downoads the compiled code and executes them. This method is only supported on Linux.
- If you did not set the
LD_LIBRARY_PATH
for MATLAB Runtime properly, set theMATLAB_RUNTIME_PATHS
variable to point to your MATLAB Runtime. - If you wish to use the full MATLAB instead of the MATLAB Runtime, set the
USE_MATLAB_SCRIPT
environment variable.
- If you did not set the
Install
Use python3 -m pipi install -e <dir>
to install locally.
Run
The training script can be called using the command line interface (CLI).
python3 -m nucleaizer_backend.training_cli
The only required argument is the input directory. This is where the train
, val
and test
subdirectories are found.
There are two additional paths used by the training script:
- The home directory for the algorithm (
NUCLEAIZER_HOME
). The auxiliary files to execute the training will be downloaded here. If not set it will be under the current urser's home folder with name.nucleaizer
. - The work directoy (workflow), where the intermediate results put. The default is the
workflow
in the current directory.
By default, the whole pipeline is executed, that is exactly: presegment,clustering,style,train
.
presegment
: presegmentation setp. Using the presegmentation model, weak labels are generated for the elements of thetest
set.clustering
: clusters the test set based on image similarities using a pretrained distance predictor network. The clusters correspond to the styles.style
: uses image-to-image translation (pix2pix) to learn the translation from mask to microscopy image, while artificial labelled masks are generated. Then, the model is used to synthesize microscopy images for the generated masks. This is done for each cluster (style) so it can take a bit time.train
: trains a Mask R-CNN model on the concatenation of the samples in thetrain
directory and the previously synthesized set of samples. The trained model will be in theoutput_model
directory under the work dir.
Further help
See the documentation.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file nucleaizer_backend-0.2.6-py3-none-any.whl
.
File metadata
- Download URL: nucleaizer_backend-0.2.6-py3-none-any.whl
- Upload date:
- Size: 98.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a38181d035492a9aa6a94ee9666a490487999c771aa0cb0ae260ab7b6cb6f4f2 |
|
MD5 | 22fac42d13eaf3016927a09b163de1da |
|
BLAKE2b-256 | 0f6d71e5f4ce518d2f6c18337355339102b97f9a704a8b9a8973bc9cb694fc1d |