Skip to main content

GPU-accelerated image processing in napari using OpenCL

Project description

napari-pyclesperanto-assistant

Image.sc forum website License PyPI Python Version tests codecov

The py-clEsperanto-assistant is a yet experimental napari plugin for building GPU-accelerated image processing workflows. It is part of the clEsperanto project and thus, aims at removing programming language related barriers between image processing ecosystems in the life sciences. It uses pyclesperanto and with that pyopencl as backend for processing images. This plugin was generated with Cookiecutter using with napari's cookiecutter-napari-plugin template.

Installation

It is recommended to install the assistant via conda:

conda create --name bio11 python==3.8.5 
conda activate bio11 
conda install -c conda-forge pyopencl==2021.2.1
pip install napari-pyclesperanto-assistant
pip install "napari[all]"

Alternatively, you can install the assistant using napari's plugin installer in the menu Plugins > Install/uninstall Packages. Windows users should paste this URL

https://github.com/clEsperanto/napari_pyclesperanto_assistant/blob/master/installation_help/pyopencl-2020.3.1+cl12-cp38-cp38-win_amd64.whl?raw=true

in this field and click on Install before proceeding:

Afterwards, click install clEsperanto like by clicking on Install here:

You can then start napari, e.g. from command line, and find the assistant in the Plugins menu.

napari

Features

pyclesperanto offers various possibilities for processing images. It comes from developers who work in life sciences and thus, it may be focused towards processing two- and three-dimensional microscopy image data showing cells and tissues. A selection of pyclesperanto's functionality is available via the assistant user interface. Typical workflows which can be built with this assistant include

  • image filtering
    • denoising / noise reduction (mean, median, Gaussian blur)
    • background subtraction for uneven illumination or out-of-focus light (bottom-hat, top-hat, subtract Gaussian background)
    • grey value morphology (local minimum, maximum. variance)
    • gamma correction
    • Laplace operator
    • Sobel operator
  • combining images
    • masking
    • image math (adding, subtracting, multiplying, dividing images)
    • absolute / squared difference
  • image transformations
    • translation
    • rotation
    • scale
    • reduce stack
    • sub-stacks
  • image projections
    • minimum / mean / maximum / sum / standard deviation projections
  • image segmentation
    • binarization (thresholding, local maxima detection)
    • labeling
    • regionalization
    • instance segmentation
    • semantic segmentation
    • detect label edges
    • label spots
    • connected component labeling
    • Voronoi-Otsu-labeling
  • post-processing of binary images
    • dilation
    • erosion
    • binary opening
    • binary closing
    • binary and / or / xor
  • post-processing of label images
    • dilation (expansion) of labels
    • extend labels via Voronoi
    • exclude labels on edges
    • exclude labels within / out of size / value range
    • merge touching labels
  • parametric maps
    • proximal / touching neighbor count
    • distance measurements to touching / proximal / n-nearest neighbors
    • pixel count map
    • mean / maximum / extension ratio map
  • label measurements / post processing of parametric maps
    • minimum / mean / maximum / standard deviation intensity maps
    • minimum / mean / maximum / standard deviation of touching / n-nearest / neighbors
  • neighbor meshes
    • touching neighbors
    • n-nearest neighbors
    • proximal neighbors
    • distance meshes
  • measurements based on label images
    • bounding box 2D / 3D
    • minimum / mean / maximum / sum / standard deviation intensity
    • center of mass
    • centroid
    • mean / maximum distance to centroid (and extension ratio shape descriptor)
    • mean / maximum distance to center of mass (and extension ratio shape descriptor)
  • code export
    • python / Fiji-compatible jython
    • python jupyter notebooks
  • pyclesperanto scripting
    • cell segmentation
    • cell counting
    • cell differentiation
    • tissue classification

Usage

Start up the assistant

Start up napari, e.g. from the command line:

napari

Load example data, e.g. from the menu File > Open Samples > clEsperanto > CalibZAPWfixed and start the assistant from the menu Plugins > clEsperanto > Assistant. Select a GPU in case you are asked to.

In case of two dimensional timelapse data, an initial conversion step might be necessary depending on your data source. Click the menu Plugins > clEsperanto > Convert to 2d timelapse. In the dialog, select the dataset and click ok. You can delete the original dataset afterwards:

Set up a workflow

Choose categories of operations in the top right panel, for example start with denoising using a Gaussian Blur with sigma 1 in x and y.

Continue with background removal using the top-hat filter with radius 5 in x and y.

For labeling the objects, use Voronoi-Otsu-Labeling with both sigma parameters set to 2.

The labeled objects can be extended using a Voronoi diagram to derive a estimations of cell boundaries.

You can then configure napari to show the label boundaries on top of the original image:

When your workflow is set up, click the play button below your dataset:

Code generation

You can also export your workflow as Python/Jython code or as notebook.

After exporting your workflow as Jupyter notebook, you can start the notebook from the command line using

jupyter notebook my_notebook.ipynb

In some cases you need to replace the command cle.imread('None)` with a command loading your image data. After that, you can execute the notebook.

You can also export code to the clipboard or as python code to disc. This python code can also be executed in Fiji`s Jython, in case the CLIJx-assistant is installed.

Also note: The generated python/jython code is not capable of processing timelapse data, you need to program a for-loop processing timepoints individually yourself.

Work in progress, contributions welcome.

For developers

Getting the recent code from github and locally installing it

git clone https://github.com/clesperanto/napari_pyclesperanto_assistant.git

pip install -e ./napari_pyclesperanto_assistant

Optional: Also install pyclesperantos recent source code from github:

git clone https://github.com/clEsperanto/pyclesperanto_prototype.git

pip install -e ./pyclesperanto_prototype

Feedback welcome!

clEsperanto is developed in the open because we believe in the open source community. See our community guidelines. Feel free to drop feedback as github issue or via image.sc

Imprint

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

napari_pyclesperanto_assistant-0.10.3.tar.gz (61.1 MB view details)

Uploaded Source

Built Distribution

File details

Details for the file napari_pyclesperanto_assistant-0.10.3.tar.gz.

File metadata

  • Download URL: napari_pyclesperanto_assistant-0.10.3.tar.gz
  • Upload date:
  • Size: 61.1 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

Hashes for napari_pyclesperanto_assistant-0.10.3.tar.gz
Algorithm Hash digest
SHA256 d388d1f86db5aeed5c748e53673db6e6b958d516236a8aa1f275d283861b5121
MD5 5b564d55543b670efa34066d77d42127
BLAKE2b-256 4868db1e9796a66a455ee26c73c74821d300f19707f566a7696adfe18f84fcd7

See more details on using hashes here.

File details

Details for the file napari_pyclesperanto_assistant-0.10.3-py3-none-any.whl.

File metadata

  • Download URL: napari_pyclesperanto_assistant-0.10.3-py3-none-any.whl
  • Upload date:
  • Size: 18.6 MB
  • 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

Hashes for napari_pyclesperanto_assistant-0.10.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4662c86e38b09d13fe33fca483119a8a7cb3a95ed88a93a5190ff9dbf0d4fb8b
MD5 eebd624ee4fa89d0863fb39ceab23e4a
BLAKE2b-256 b6f4ba303065c02a63e1b6dc7c6fdb7c49182b7c48de6fa75a60ac5ea208a26f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page