napari-feature-classifier
https://github.com/fractal-napari-plugins-collection/napari-feature-classifier
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.2%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: fractal-napari-plugins-collection
- License: bsd-3-clause
- Language: Jupyter Notebook
- Default Branch: main
- Size: 406 KB
Statistics
- Stars: 23
- Watchers: 7
- Forks: 6
- Open Issues: 18
- Releases: 8
Metadata Files
README.md
napari-feature-classifier
An interactive classifier plugin that allows the user to assign objects in a label image to multiple classes and train a classifier to learn those classes based on a feature dataframe.
Usage
To use the napari-feature-classifier, you need to have a label image and corresponding measurements: as a csv file, loaded to layer.features or in an OME-Zarr Anndata table loaded with another plugin. Your feature measurements need to contain a label column that matches the label objects in the label image.
These interactive classification workflows are well suited to visually define cell types, find mitotic cells in images, do quality control by automatically detecting missegmented cells and other tasks where a user can easily assign objects to groups.
Prepare the label layer:
- Load your label layer into napari and add the features measurements to layer.features of the corresponding label layer. You can have multiple label layers with their features open at the same time
- To load features from a CSV file:
Plugins -> napari-feature-classifier -> CSV Feature Loader, then load the features for the correct label image. - To load features from an OME-Zarr file: Get both the label layer into memory as a normal label layer (not a pyramidal label layer, currently untested) and the corresponding features. If your OME-Zarr file is created by Fractal, you can use this ROI loader plugin.
- To load features from anywhere else, load them manually to your label_layer.features
- To load features from a CSV file:
- Your feature table should have 2 columns used for indexing (but stored as normal columns in layer.features):
- The
labelcolumn to match the object in the label image - The
roi_idcolumn to identify the image you're currently classifying (used when a classifier is trained on multiple label images)
- The
Initialize a classifier:
- Start the classifier in napari by going to
Plugins -> napari-feature-classifier -> Initialize a Classifier - Select the features you want to use for the classifier (you need to do the feature selection before initializing. The feature selection can't be changed after initialization anymore). Hold the command key to select multiple features. Feature options are always shown for the features available in the last selected label layer, based on layer.features available features.
- (Optional) Give your classes recognizable names (e.g. Mitotic & Interphase, Cell Type a, b and c etc.)
Classify objects:
- Make sure you have the label layer selected on which you want to classify
- Select the current class with the radio buttons or by pressing 0, 1, 2, etc.
- Click on label objects in the viewer to assign them to the currently selected class
- Once you have trained enough examples, click "Run Classifier" to run the classifier and have it make a prediction for all objects. Aim for at least a dozen annotations per class, as the classifier divides your annotations 80/20 in training and test sets.
- Once you get predictions, correct mistakes the classifier made and retrain it to improve its performance.
- You can save the classifier under a different name or in a different location. Define the new output location and then click
Save Classifier(you need to click the Save Classifier button. Just defining the new output path does not save it yet. But every run of the classifier triggers an autosave)
Apply the classifier to additional images:
- You can apply a classifier trained on one image to additional label images. Use
Plugins -> napari-feature-classifier -> Load Classifier - Select the classifier (.clf file with the name you gave above) while already having the label images ready (see
Prepare the label layerabove). - Click Load Classifier, proceed as above.
Export classifier results
- To export the training data and the results of the classifier, define an Export Name (full path to an output file or just a filename ending in .csv) where the results of the classifier shall be saved. It defaults to the layer name for the selected layer in the last directory you chose (or the current working directory if none was chosen so far)
- Click
Export Classifier Result(Just selecting a filename is not enough, you need to click the export button). This will export the predictions for the currently selected layer. - The results of the classifier are save in a csv file. The label is an integer of the label object within that image. The prediction column contains predictions of the classifier for all objects (except those that contained NaNs in their feature data) and the annotation column contains the annotations you made (NaN for unclassified objects, -1 for objects you deselected, 1 - 9 for the classes)
Batch mode result export
(To be updated: Create a new notebook to run batch processing, this is for the older version of the classifier)
There is a simple workflow for the classifier in the examples folder:
- Install jupyter-lab (pip install jupyterlab)
- Open the notebook in jupyter lab (Type jupyter-lab in the terminal when you are in the examples folder)
- Follow the instructions to generate an example dataframe and an example label image
- Use the classifier in napari with this simplified data
Initializing the Annotator
You can use the annotation functionality also independently from the classifier
Start the annotator widget by going to Plugins -> napari-feature-classifier -> Annotator
Select names for your classes. You can name up to 9 classes. Only classes that you give a name will be created upon initialization.
Then click Initialize.

A annotator widget opens. Use the Radio-Buttons to select what class you're annotating (or keybindings for 1-9 for classes, 0 for deselect). The annotator will always work on the currently selected label layer. While the annotator is open, you can't edit the labels. Restart napari to allow editing of labels again.

The annotations are saved in the layer.features table of the corresponding label layer as an annotations column.

Installation
This plugin is written for the new napari npe2 plugin engine. Thus, it requires napari >= 0.4.13.
Activate your environment where you have napari installed (or install napari using pip install "napari[all]"), then install the classifier plugin:
pip install napari-feature-classifier
The layer.features dataframes have some issues in napari 0.4.17 (see here). They seem to be working again in the nighlty builds. To set up a nightly builds napari env, do the following:
conda create -n classifier-dev-napari-main -c "napari/label/nightly" -c conda-forge napari python=3.10 -y
Similar napari plugins
If you're looking for other classification approaches, apoc by Robert Haase has a pixel classifier in napari and an object classification workflow:
napari-accelerated-pixel-and-object-classification (APOC)
Alternatively, Clément Cazorla has built napari-svetlana, a deep learning based classifier
Release process
- Update the version number in src/napari-feature-classifier/init.py
- Update the version in setup.cfg
- Add a Github release with a new version tag (matching the version set above)
- Once tests pass, this should automatically be deployed to pypi
- Wait for conda automation to make a PR for an updated conda release (see https://github.com/conda-forge/napari-feature-classifier-feedstock). This can take 1-2 days. Make sure that PR gets merged.
Contributing
Contributions are very welcome.
License
Distributed under the terms of the BSD-3 license, "napari-feature-classifier" is free and open source software
Issues
If you encounter any problems, please [file an issue] along with a detailed description.
Contributors
Owner
- Name: fractal-napari-plugins-collection
- Login: fractal-napari-plugins-collection
- Kind: organization
- Repositories: 11
- Profile: https://github.com/fractal-napari-plugins-collection
Citation (CITATION.cff)
cff-version: 1.2.0 message: If you use this plugin, please cite it using these metadata title: 'napari-feature-classifier: An interactive classifier plugin to use with label images and feature measurements' url: https://github.com/fractal-napari-plugins-collection/napari-feature-classifier authors: - given-names: Joel family-names: Luethi - given-names: Maks family-names: Hess
GitHub Events
Total
- Create event: 8
- Release event: 5
- Issues event: 6
- Watch event: 2
- Delete event: 3
- Issue comment event: 5
- Push event: 6
- Pull request event: 7
- Fork event: 1
Last Year
- Create event: 8
- Release event: 5
- Issues event: 6
- Watch event: 2
- Delete event: 3
- Issue comment event: 5
- Push event: 6
- Pull request event: 7
- Fork event: 1
Committers
Last synced: almost 3 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| jluethi | j****i@u****h | 90 |
| MaksHess | m****s@i****h | 27 |
| Sean Martin | s****m@h****m | 2 |
| Giuseppe Piero Brandino | g****o@g****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 7 months ago
All Time
- Total issues: 36
- Total pull requests: 12
- Average time to close issues: 5 months
- Average time to close pull requests: 12 days
- Total issue authors: 7
- Total pull request authors: 5
- Average comments per issue: 1.36
- Average comments per pull request: 1.17
- Merged pull requests: 10
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 2
- Pull requests: 4
- Average time to close issues: N/A
- Average time to close pull requests: 13 minutes
- Issue authors: 1
- Pull request authors: 2
- Average comments per issue: 0.0
- Average comments per pull request: 0.25
- Merged pull requests: 3
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- jluethi (33)
- MaksHess (3)
- fdsteffen (2)
- haesleinhuepf (1)
- loicsauteur (1)
- goanpeca (1)
- seankmartin (1)
Pull Request Authors
- jluethi (12)
- seankmartin (1)
- rhornb (1)
- MaksHess (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 81 last-month
-
Total dependent packages: 0
(may contain duplicates) -
Total dependent repositories: 1
(may contain duplicates) - Total versions: 12
- Total maintainers: 1
pypi.org: napari-feature-classifier
An interactive classifier plugin to use with label images and feature measurements
- Homepage: https://github.com/fractal-napari-plugins-collection/napari-feature-classifier
- Documentation: https://github.com/fractal-napari-plugins-collection/napari-feature-classifier#napari-feature-classifier
- License: BSD-3-Clause
-
Latest release: 0.3.2
published 10 months ago
Rankings
Maintainers (1)
conda-forge.org: napari-feature-classifier
- Homepage: https://github.com/fractal-napari-plugins-collection/napari-feature-classifier
- License: BSD-3-Clause
-
Latest release: 0.0.1
published almost 4 years ago
Rankings
Dependencies
- GabrielBB/xvfb-action v1 composite
- actions/checkout v2 composite
- actions/setup-python v2 composite
- codecov/codecov-action v2 composite