{"name":"napari-cellposesam","display_name":"napari-cellposesam","visibility":"public","icon":null,"categories":[],"schema_version":"0.1.0","on_activate":null,"on_deactivate":null,"contributions":{"commands":[{"id":"napari-cellposesam.widget_wrapper","title":"Create cellpose","python_name":"napari_cellposesam._dock_widget:widget_wrapper","short_title":null,"category":null,"icon":null,"enablement":null},{"id":"napari-cellposesam.data.rgb_3D","title":"Generate RGB 3D sample","python_name":"napari_cellposesam._sample_data:make_rgb_3d_sample","short_title":null,"category":null,"icon":null,"enablement":null},{"id":"napari-cellposesam.data.rgb_2D","title":"Generate RGB 2D sample","python_name":"napari_cellposesam._sample_data:make_rgb_2d_sample","short_title":null,"category":null,"icon":null,"enablement":null}],"readers":null,"writers":null,"widgets":[{"command":"napari-cellposesam.widget_wrapper","display_name":"cellpose","autogenerate":false,"default_dock_area":"right","tabify":false}],"sample_data":[{"command":"napari-cellposesam.data.rgb_2D","key":"rgb_2D","display_name":"Cells (2D+2Ch)"},{"command":"napari-cellposesam.data.rgb_3D","key":"rgb_3D","display_name":"Cells (3D+2Ch)"}],"themes":null,"menus":{},"submenus":null,"keybindings":null,"configurations":{}},"package_metadata":{"metadata_version":"2.4","name":"napari-cellposesam","version":"0.2.3","dynamic":["license-file"],"platform":null,"supported_platform":null,"summary":"napari plugin for cellpose and Cellpose-SAM segmentation","description":"# napari-cellposesam <img src=\"docs/_static/favicon.ico\" width=\"50\" title=\"cellpose\" alt=\"cellpose\" align=\"right\" vspace = \"50\">\n\n[![Documentation Status](https://readthedocs.org/projects/napari-cellposesam/badge/?version=latest)](https://napari-cellposesam.readthedocs.io/en/latest/)\n[![tests](https://github.com/jeskowagner/napari-cellposesam/actions/workflows/test_and_deploy.yml/badge.svg)](https://github.com/jeskowagner/napari-cellposesam/actions)\n[![PyPI version](https://img.shields.io/pypi/v/napari-cellposesam)](https://pypi.org/project/napari-cellposesam/)\n[![Python version](https://img.shields.io/pypi/pyversions/napari-cellposesam)](https://pypi.org/project/napari-cellposesam/)\n[![License](https://img.shields.io/pypi/l/napari-cellposesam.svg?color=green)](https://github.com/jeskowagner/napari-cellposesam/raw/main/LICENSE)\n[![website](https://img.shields.io/website?url=https%3A%2F%2Fwww.cellpose.org)](https://www.cellpose.org)\n\nA [napari] plugin for cell segmentation with [cellpose], including Cellpose-SAM (cellpose 4).\n\nThis is a fork of [MouseLand/cellpose-napari](https://github.com/MouseLand/cellpose-napari), the original plugin by Carsen Stringer. It adds:\n\n- support for Cellpose-SAM (`cpsam`) and Cellpose3 models in the same\n  environment and UI\n- z/channel axis selection for 3D and 4D images\n- compatibility with new napari versions\n\nThe cellpose code was written by Carsen Stringer and Marius Pachitariu. To learn about Cellpose, read the [**paper**](https://t.co/kBMXmPp3Yn?amp=1) or watch this [**talk**](https://t.co/JChCsTD0SK?amp=1).\n\nFor problems with this plugin, open an [issue](https://github.com/jeskowagner/napari-cellposesam/issues). For problems with cellpose itself, open an [issue](https://github.com/MouseLand/cellpose/issues) on the cellpose repo.\n\nIf you use this plugin, please cite the [cellpose paper](https://www.nature.com/articles/s41592-020-01018-x), the Cellpose3 paper if you use the Cellpose3 models, and the Cellpose-SAM paper if you use the `cpsam` models (see the [cellpose repo](https://github.com/MouseLand/cellpose) for the references):\n\n```bibtex\n@article{stringer2021cellpose,\n  title={Cellpose: a generalist algorithm for cellular segmentation},\n  author={Stringer, Carsen and Wang, Tim and Michaelos, Michalis and Pachitariu, Marius},\n  journal={Nature Methods},\n  volume={18},\n  number={1},\n  pages={100--106},\n  year={2021},\n  publisher={Nature Publishing Group}\n}\n```\n\n![napari-cellposesam segmenting the 2D sample image](https://raw.githubusercontent.com/jeskowagner/napari-cellposesam/main/docs/_static/gui.png)\n\n## Installation\n\nRequires Python 3.11 or newer. We recommend a fresh environment, e.g. with conda:\n\n```\nconda create -n napari-cellposesam python=3.12\nconda activate napari-cellposesam\n```\n\nInstall napari and the plugin with pip:\n\n```\npip install \"napari[all]\" napari-cellposesam\n```\n\nOr install the plugin from the napari plugin manager (Plugins > Install/Uninstall Plugins).\n\nTo install the latest development version from GitHub:\n\n```\npip install git+https://github.com/jeskowagner/napari-cellposesam\n```\n\nIf you have issues installing cellpose, see the [cellpose installation docs](https://cellpose.readthedocs.io/en/latest/installation.html).\n\n### Cellpose3 models\n\nThe plugin installs cellpose 4, which provides the Cellpose-SAM and CPDINO models. The Cellpose3 models (`cyto3`, `nuclei`, etc.) are in the same model list. They need cellpose 3, which the plugin offers to download the first time you run one. It downloads cellpose 3.1.1.3 into a private folder without touching the installed cellpose, and installs [numba](https://numba.pydata.org) if it is missing. The plugin then picks the right cellpose version for each model, including custom models.\n\nThe private copy is in `~/.cellpose/napari-cellposesam/cellpose-3.1.1.3-format1/_cellpose3` (`~` is your user folder, also on Windows). To keep it elsewhere, set the environment variable `NAPARI_CELLPOSESAM_CACHE` to a folder that then takes the place of `~/.cellpose/napari-cellposesam`. To reset it, delete `~/.cellpose/napari-cellposesam` (or the folder `NAPARI_CELLPOSESAM_CACHE` names): the plugin offers to download cellpose 3 again the next time you run a Cellpose3 model.\n\nTo run the same download ahead of time, so that napari never prompts:\n\n```\npython -m napari_cellposesam fetch-cellpose3\n```\n\nThe download goes to the home folder of whoever runs the command. For an environment shared by several users, set `NAPARI_CELLPOSESAM_CACHE` to a shared folder, both when running the command and for everyone who uses the environment. Users only need read access to it.\n\nBoth need internet access and pip in the environment. If the environment has no pip, as in some uv-created ones, the plugin asks you to install it first.\n\nDon't install `cellpose-napari` next to this plugin. It lists the Cellpose3\nmodels, but with cellpose 4 installed it ignores the selected model and runs\nCellpose-SAM, thus breaking it.\n\n### GPU\n\ncellpose runs on CPU, NVIDIA GPUs (CUDA) and Apple silicon (MPS). The plugin uses a GPU automatically if torch can see one, for both the cellpose 4 and the Cellpose3 models.\n\n- **Apple silicon:** nothing to do, the torch from PyPI supports MPS.\n- **NVIDIA on Linux:** the torch from PyPI is a CUDA build, so it usually works as installed.\n- **NVIDIA on Windows:** the torch from PyPI is CPU-only. In a fresh environment, install torch and torchvision from the PyTorch index first, with the CUDA version the [PyTorch selector](https://pytorch.org/get-started/locally/) gives for your driver, then napari and the plugin, e.g.:\n\n  ```\n  pip install torch torchvision --index-url https://download.pytorch.org/whl/cu126\n  pip install \"napari[all]\" napari-cellposesam\n  ```\n\n  If the plugin is already installed, reinstall torch and torchvision together instead:\n\n  ```\n  pip install --force-reinstall --no-deps torch torchvision --index-url https://download.pytorch.org/whl/cu126\n  ```\n\nCheck that torch sees the GPU:\n\n```\npython -c \"import torch; print('cuda', torch.cuda.is_available(), 'mps', torch.backends.mps.is_available())\"\n```\n\n### Optional: CPDINO models\n\nThe CPDINO models need [DINOv3](https://github.com/facebookresearch/dinov3), which is not on PyPI and so is not installed automatically. The plugin offers to install it when you run segmentation with a CPDINO model, or install it yourself:\n\n```\npip install git+https://github.com/facebookresearch/dinov3\n```\n\nWithout it, cellpose logs a `Could not import CPDINO` warning on startup. This is harmless if you don't use those models.\n\n### Upgrading\n\n```\npip install --upgrade napari-cellposesam cellpose\n```\n\nIf you installed a CUDA build of torch, upgrade torch the same way you installed it, or pip may replace it with the CPU-only build.\n\nComing from 0.1.x with a separate cellpose 3 environment (`cellpose<4`): from 0.2.0 that environment is no longer needed, since one environment runs both the Cellpose3 and the cellpose 4 models. Upgrading it with the command above moves it to cellpose 4, and the plugin downloads cellpose 3 the first time you run a Cellpose3 model.\n\n## Usage\n\nOpen napari with the plugin docked:\n\n```\nnapari -w napari-cellposesam\n```\n\nSample data is available under File > Open Sample > napari-cellposesam.\n\nDetailed usage is described in the [documentation](https://napari-cellposesam.readthedocs.io/).\n\n## Contributing\n\nContributions are welcome. For development, clone the repo and install it in editable mode with the test dependencies:\n\n```\npip install -e \".[testing]\"\npytest\n```\n\n## License\n\nDistributed under the terms of the [BSD-3] license, \"napari-cellposesam\" is free and open source software.\n\n## Dependencies\n\nnapari-cellposesam relies on:\n- [napari](https://napari.org)\n- [magicgui](https://napari.org/magicgui/)\n- [cellpose], which in turn uses [torch](https://pytorch.org/), [numpy](https://numpy.org/), [scipy](https://scipy.org/), [opencv](https://opencv.org/) and others\n- [numba](https://numba.pydata.org), which the plugin installs the first time you run a Cellpose3 model\n\n[napari]: https://github.com/napari/napari\n[cellpose]: https://github.com/MouseLand/cellpose\n[BSD-3]: http://opensource.org/licenses/BSD-3-Clause\n","description_content_type":"text/markdown","keywords":null,"home_page":null,"download_url":null,"author":null,"author_email":"Carsen Stringer <stringerc@janelia.hhmi.org>, Jesko Wagner <35219306+jeskowagner@users.noreply.github.com>","maintainer":null,"maintainer_email":null,"license":"BSD-3-Clause","classifier":["Programming Language :: Python","Programming Language :: Python :: 3","Programming Language :: Python :: 3.11","Programming Language :: Python :: 3.12","Programming Language :: Python :: 3.13","Programming Language :: Python :: 3.14","Operating System :: OS Independent","License :: OSI Approved :: BSD License","Framework :: napari"],"requires_dist":["napari>=0.6","magicgui","cellpose==4.*","imagecodecs","sphinx>=3.0; extra == \"docs\"","sphinxcontrib-apidoc; extra == \"docs\"","sphinx_rtd_theme; extra == \"docs\"","sphinx-prompt; extra == \"docs\"","sphinx-autodoc-typehints; extra == \"docs\"","tox; extra == \"testing\"","pytest; extra == \"testing\"","pytest-cov; extra == \"testing\"","pytest-qt; extra == \"testing\"","napari; extra == \"testing\"","pyqt6; extra == \"testing\"","numba; extra == \"testing\""],"requires_python":">=3.11","requires_external":null,"project_url":["Homepage, https://github.com/jeskowagner/napari-cellposesam","Source Code, https://github.com/jeskowagner/napari-cellposesam","Bug Tracker, https://github.com/jeskowagner/napari-cellposesam/issues"],"provides_extra":["docs","testing"],"provides_dist":null,"obsoletes_dist":null},"npe1_shim":false}