{"name":"napari-feature-classifier","display_name":"napari feature classifier","visibility":"public","icon":"","categories":[],"schema_version":"0.2.0","on_activate":null,"on_deactivate":null,"contributions":{"commands":[{"id":"napari-feature-classifier.annotator_init_widget","title":"Annotator","python_name":"napari_feature_classifier.annotator_init_widget:InitializeLabelAnnotatorWidget","short_title":null,"category":null,"icon":null,"enablement":null},{"id":"napari-feature-classifier.initialize_classifier_new","title":"Initialize a Classifier","python_name":"napari_feature_classifier.classifier_widget:ClassifierWidget","short_title":null,"category":null,"icon":null,"enablement":null},{"id":"napari-feature-classifier.load_classifier","title":"Load a Classifier","python_name":"napari_feature_classifier.classifier_widget:LoadClassifierContainer","short_title":null,"category":null,"icon":null,"enablement":null},{"id":"napari-feature-classifier.load_csv_features","title":"CSV Feature loader","python_name":"napari_feature_classifier.feature_loader_widget:load_features_factory","short_title":null,"category":null,"icon":null,"enablement":null}],"readers":null,"writers":null,"widgets":[{"command":"napari-feature-classifier.annotator_init_widget","display_name":"Annotator","autogenerate":false},{"command":"napari-feature-classifier.initialize_classifier_new","display_name":"Initialize a Classifier","autogenerate":false},{"command":"napari-feature-classifier.load_classifier","display_name":"Load Classifier","autogenerate":false},{"command":"napari-feature-classifier.load_csv_features","display_name":"CSV Feature loader","autogenerate":false}],"sample_data":null,"themes":null,"menus":{},"submenus":null,"keybindings":null,"configuration":[]},"package_metadata":{"metadata_version":"2.1","name":"napari-feature-classifier","version":"0.1.1","dynamic":null,"platform":null,"supported_platform":null,"summary":"An interactive classifier plugin to use with label images and feature measurements","description":"# napari-feature-classifier\n\n[![License](https://img.shields.io/pypi/l/napari-feature-classifier.svg?color=green)](https://github.com/fractal-napari-plugins-collection/napari-feature-classifier/raw/main/LICENSE)\n[![PyPI](https://img.shields.io/pypi/v/napari-feature-classifier.svg?color=green)](https://pypi.org/project/napari-feature-classifier)\n[![Python Version](https://img.shields.io/pypi/pyversions/napari-feature-classifier.svg?color=green)](https://python.org)\n[![tests](https://github.com/fractal-napari-plugins-collection/napari-feature-classifier/workflows/tests/badge.svg)](https://github.com/fractal-napari-plugins-collection/napari-feature-classifier/actions)\n[![codecov](https://codecov.io/gh/fractal-napari-plugins-collection/napari-feature-classifier/branch/main/graph/badge.svg)](https://codecov.io/gh/fractal-napari-plugins-collection/napari-feature-classifier)\n[![napari hub](https://img.shields.io/endpoint?url=https://api.napari-hub.org/shields/napari-feature-classifier)](https://napari-hub.org/plugins/napari-feature-classifier)\n\nAn 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.\n\n## Usage\n

\n\nTo 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](https://github.com/jluethi/napari-ome-zarr-roi-loader). Your feature measurements need to contain a `label` column that matches the label objects in the label image.\nThese 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.\n\n#### Prepare the label layer:\n- 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\n - To load features from a CSV file: `Plugins -> napari-feature-classifier -> CSV Feature Loader`, then load the features for the correct label image.\n - 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](https://fractal-analytics-platform.github.io/), you can use [this ROI loader plugin](https://github.com/jluethi/napari-ome-zarr-roi-loader).\n - To load features from anywhere else, load them manually to your label_layer.features\n- Your feature table should have 2 columns used for indexing (but stored as normal columns in layer.features):\n - The `label` column to match the object in the label image\n - The `roi_id` column to identify the image you're currently classifying (used when a classifier is trained on multiple label images)\n\n\n#### Initialize a classifier:\n- Start the classifier in napari by going to `Plugins -> napari-feature-classifier -> Initialize a Classifier` \n- 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.\n- (Optional) Give your classes recognizable names (e.g. Mitotic & Interphase, Cell Type a, b and c etc.)\n\"Screenshot\n\n\n\n\n#### Classify objects:\n\"Classifier_annotation\"\n\n- Make sure you have the label layer selected on which you want to classify\n- Select the current class with the radio buttons or by pressing 0, 1, 2, etc.\n- Click on label objects in the viewer to assign them to the currently selected class\n- 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. \n- Once you get predictions, correct mistakes the classifier made and retrain it to improve its performance.\n- 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)\n\"Classifier_prediction\"\n\n\n\n#### Apply the classifier to additional images:\n- You can apply a classifier trained on one image to additional label images. Use `Plugins -> napari-feature-classifier -> Load Classifier` \n- Select the classifier (.clf file with the name you gave above) while already having the label images ready (see `Prepare the label layer` above).\n- Click Load Classifier, proceed as above.\n\"Screenshot\n\n\n\n#### Export classifier results\n- 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)\n- 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.\n- 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)\n\"Classifier_prediction\"\n\n\n#### Batch mode result export\n(To be updated: Create a new notebook to run batch processing, this is for the older version of the classifier)\nThere is a simple workflow for the classifier in the examples folder:\n- Install jupyter-lab (`pip install jupyterlab`)\n- Open the notebook in jupyter lab (Type `jupyter-lab` in the terminal when you are in the examples folder)\n- Follow the instructions to generate an example dataframe and an example label image\n- Use the classifier in napari with this simplified data\n\n\n#### Initializing the Annotator\nYou can use the annotation functionality also independently from the classifier\nStart the annotator widget by going to `Plugins -> napari-feature-classifier -> Annotator`\nSelect names for your classes. You can name up to 9 classes. Only classes that you give a name will be created upon initialization.\nThen click `Initialize`.\n\n\"Screenshot\n\nA annotator widget opens. Use the Radio-Buttons to select what class you're annotating (or keybindings for 1-9 for classes, 0 for deselect).\nThe 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.\n\n\"Screenshot\n\nThe annotations are saved in the `layer.features` table of the corresponding label layer as an `annotations` column.\n\"Screenshot\n\n\n## Installation\n\nThis plugin is written for the new napari npe2 plugin engine. Thus, it requires napari >= 0.4.13.\nActivate your environment where you have napari installed (or install napari using `pip install \"napari[all]\"`), then install the classifier plugin:\n\n pip install napari-feature-classifier\n\nThe layer.features dataframes have some issues in napari 0.4.17 (see [here](https://github.com/napari/napari/issues/5617)). They seem to be working again in the nighlty builds. To set up a nightly builds napari env, do the following:\n\n```\nconda create -n classifier-dev-napari-main -c \"napari/label/nightly\" -c conda-forge napari python=3.10 -y\n```\n \n## Similar napari plugins\nIf you're looking for other classification approaches, [apoc](https://github.com/haesleinhuepf/apoc) by [Robert Haase](https://github.com/haesleinhuepf) has a pixel classifier in napari and an object classification workflow: \n[napari-accelerated-pixel-and-object-classification (APOC)](https://github.com/haesleinhuepf/napari-accelerated-pixel-and-object-classification) \nAlternatively, Clément Cazorla has built [napari-svetlana, a deep learning based classifier](https://www.napari-hub.org/plugins/napari-svetlana)\n\n## Release process\n1. Update the version number in src/napari-feature-classifier/__init__.py\n2. Update the version in setup.cfg\n3. Add a Github release with a new version tag (matching the version set above)\n4. Once tests pass, this should automatically be deployed to pypi\n5. 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.\n\n\n## Contributing\n\nContributions are very welcome.\n\n## License\n\nDistributed under the terms of the [BSD-3] license,\n\"napari-feature-classifier\" is free and open source software\n\n## Issues\n\nIf you encounter any problems, please [file an issue] along with a detailed description.\n\n## Contributors\n[Joel Lüthi](https://github.com/jluethi) & [Max Hess](https://github.com/MaksHess)\n\n[napari]: https://github.com/napari/napari\n[Cookiecutter]: https://github.com/audreyr/cookiecutter\n[@napari]: https://github.com/napari\n[MIT]: http://opensource.org/licenses/MIT\n[BSD-3]: http://opensource.org/licenses/BSD-3-Clause\n[GNU GPL v3.0]: http://www.gnu.org/licenses/gpl-3.0.txt\n[GNU LGPL v3.0]: http://www.gnu.org/licenses/lgpl-3.0.txt\n[Apache Software License 2.0]: http://www.apache.org/licenses/LICENSE-2.0\n[Mozilla Public License 2.0]: https://www.mozilla.org/media/MPL/2.0/index.txt\n[cookiecutter-napari-plugin]: https://github.com/napari/cookiecutter-napari-plugin\n\n[napari]: https://github.com/napari/napari\n[tox]: https://tox.readthedocs.io/en/latest/\n[pip]: https://pypi.org/project/pip/\n[PyPI]: https://pypi.org/\n","description_content_type":"text/markdown","keywords":null,"home_page":"https://github.com/fractal-napari-plugins-collection/napari-feature-classifier","download_url":null,"author":"Joel Luethi and Max Hess","author_email":"joel.luethi@uzh.ch","maintainer":null,"maintainer_email":null,"license":"BSD-3-Clause","classifier":["Development Status :: 2 - Pre-Alpha","Intended Audience :: Developers","Framework :: napari","Topic :: Software Development :: Testing","Programming Language :: Python","Programming Language :: Python :: 3","Programming Language :: Python :: 3.7","Programming Language :: Python :: 3.8","Programming Language :: Python :: 3.9","Programming Language :: Python :: 3.10","Operating System :: OS Independent","License :: OSI Approved :: BSD License"],"requires_dist":["numpy","napari","matplotlib","magicgui","pandas","scikit-learn (>=1.2.2)","pandera","xxhash","hypothesis"],"requires_python":">=3.9","requires_external":null,"project_url":["Bug Tracker, https://github.com/fractal-napari-plugins-collection/napari-feature-classifier/issues","Documentation, https://github.com/fractal-napari-plugins-collection/napari-feature-classifier#napari-feature-classifier","Source Code, https://github.com/fractal-napari-plugins-collection/napari-feature-classifier","User Support, https://github.com/fractal-napari-plugins-collection/napari-feature-classifier/issues"],"provides_extra":null,"provides_dist":null,"obsoletes_dist":null},"npe1_shim":false}