Pixel and label classification using OpenCL-based Random Forest Classifiers
Project description
Note: This is a decommissioned napari plugin
This project is discontinued. You can still install and use it (last tested with napari 0.4.11) but this project is no longer maintained and supported.
Check out napari-accelerated-pixel-and-object-classification (APOC) to learn more about this plugin's successor.
napari-oclrfc
py-clEsperanto meets scikit-learn
A yet experimental OpenCL-based Random Forest Classifier for pixel and labeled object classification in napari.
The processed example image maize_clsm.tif is licensed by David Legland under CC-BY 4.0 license
For using OpenCL-based Random Forest Classifiers for pixel classification in python, check out oclrfc.
This napari plugin was generated with Cookiecutter using with @napari's cookiecutter-napari-plugin template.
Installation
You can install napari-oclrfc
via pip. Note: you also need pyopencl.
conda install pyopencl
pip install napari-oclrfc
In case of issues in napari, make sure these dependencies are installed properly:
pip install pyclesperanto_prototype
pip install oclrfc
Usage
Open an image in napari and add a labels layer. Annotate foreground and background with two different label identifiers. You can also add a third, e.g. a membrane-like region in between to improve segmentation quality.
Click the menu Plugins > OpenCL Random Forest Classifiers > Train pixel classifier
.
Consider changing the featureset
. There are three options for selecting
small (about 1 pixel sized) objects,
medium (about 5 pixel sized) object and
large (about 25 pixel sized) objects.
Make sure the right image and annotation layers are selected and click on Run
.
The classifier was saved as temp.cl
to disc. You can later re-use it by clicking the menu Plugins > OpenCL Random Forest Classifiers > Predict pixel classifier
Optional: Hide the annotation layer.
Click the menu Plugins > OpenCL Random Forest Classifiers > Connected Component Labeling
.
Make sure the right labels layer is selected. It is supposed to be the result layer from the pixel classification.
Select the object class identifier
you used for annotating objects, that's the intensity you drew on objects in the annotation layer.
Hint: If you want to analyse touching neigbors afterwards, activate the fill gaps between labels
checkbox.
Click on the Run
button.
Optional: Hide the pixel classification result layer. Change the opacity of the connected component labels layer.
Add a new labels layer and annotate different object classes by drawing lines through them. In the following example objects with different size and shape were annotated in three classes:
- round, small
- round, large
- elongated
Click the menu Plugins > OpenCL Random Forest Classifiers > Train label classifier
. Select the right layers for training.
The labels layer should be the result from connected components labeling.
The annotation layer should be the just annotated object classes layer.
Select the right features for training. Click on the Run
button.
After training, the classifier will be stored to disc in the file you specified.
You can later re-use it by clicking the menu Plugins > OpenCL Random Forest Classifiers > Predict label classifier
This is an experimental napari plugin. Feedback is very welcome!
Contributing
Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.
License
Distributed under the terms of the BSD-3 license, "napari-oclrfc" is free and open source software
Issues
If you encounter any problems, please open a thread on image.sc along with a detailed description and tag @haesleinhuepf.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file napari-oclrfc-0.4.6.tar.gz
.
File metadata
- Download URL: napari-oclrfc-0.4.6.tar.gz
- Upload date:
- Size: 2.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a6842002420a8db2e283e6f74ec18830363ea032221f54c4496ed8c97e72499 |
|
MD5 | 5ba6c07de999b1fad534fa8e8e557d85 |
|
BLAKE2b-256 | d19e05827880faf84995ca3dc26fafe2cdca754057f4143ae657d7b8cff6372e |
File details
Details for the file napari_oclrfc-0.4.6-py3-none-any.whl
.
File metadata
- Download URL: napari_oclrfc-0.4.6-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b624bc6f5ad597c77d94afd368da00d5a77c49fa2ba205f03fd8067eb44622c4 |
|
MD5 | 12d63844cb500f57442a355528e3eeac |
|
BLAKE2b-256 | 59d03f332b6a50e2bd5b1d81ec5733436485151171a7838ed7354b99f918c895 |