Skip to main content

OpenCL based GPU-accelerated image processing in napari

Project description

napari-pyclesperanto-assistant

The py-clEsperanto-assistant is a yet experimental napari plugin for building GPU-accelerated image processing workflows. It is part of the clEsperanto project. It uses pyclesperanto as backend for processing images.

Installation

If you have no python/conda environment installed yet, please follow the instructions here first.

Download and install napari-pyclesperanto-assitant uing pip. Windows users should follow the instructions in the section below in case of trouble.

pip install napari-pyclesperanto-assistant

Afterwards, you can start the assistant using the following command. Replace the url with an image file of your choice:

python -m napari_pyclesperanto_assistant https://github.com/clEsperanto/napari_pyclesperanto_assistant/raw/master/napari_pyclesperanto_assistant/data/CalibZAPWfixed_000154_max-16.tif

Installation on windows

On windows some additional steps are necessary. Download a pre-compiled wheel of pyopencl e.g. from here. It is recommended to install pyopencl-...+cl21-cp38-cp38-win_amd64 - the cl12 and cp38 are important when choosing the right download. They stand for OpenCL 1.2 and Python 3.8.

Enter your username and the correct pyopencl-... filename in the following line and execute it from the command line:

C:\Users\<username>\AppData\Local\Programs\napari\python\python.exe -m pip install pyopencl-2020.2.2+cl12-cp38-cp38-win_amd64.whl

In case napari doesn't start up with an error mentioning numpy (see also), execute this from the command line:

pip install numpy==1.19.3

Usage

This short tutorial demonstrates how to generate code using the pyclersperanto-assistant. The whole procedure can be downloaded as video.

Start up the assistant

Open a command line and start up the assistant and pass the image file you want to process. The shown example image can be found online

python -m napari_pyclesperanto_assistant C:\structure\code\napari_pyclesperanto_assistant\napari_pyclesperanto_assistant\data\CalibZAPWfixed_000154_max-16.tif

napari will open with the assistant activated:

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:

Choose more processing steps. Note: You can change the input image/layer for each operation, the operation and its parameters in the bottom right panel. For example, continue with these steps

  • Filter (Background Removal): Top hat, radius 5 in x and y
  • Binarization: Threshold Otsu
  • Label: Voronoi labeling
  • Map: Touching neighbor count map
  • Binarization: Detect label edges, with the result from the second last step as input.

Hide some layers showing intermediate results. Switch the bleinding of the final result layer to "additive" to see through it on the original image.

Code generation

In the plugins menu, you find two entries which allow you to export your workflow as Python/Jython code.

Export your workflow as Jupyter notebook. Start the notebook from the command line using

jupyter notebook my_notebook.ipynb

Alternatively, export the workflow as Jython/Python script. This script can be executed from the command line like this

python my_script.py

It can also be executed in Fiji, in case the CLIJx-assistant is installed.

Note: Depeending on which layers were visible while exporting the code, different code is exported. Only visible layers are shown. Change layer visibility and export the script again. If Fiji asks you if it should reload the script file, click on "Reload".

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

Starting up napari with the pyclesperanto assistant installed:

ipython --gui=qt napari_pyclesperanto_assistant\napari_pyclesperanto_assistant

Feedback welcome!

clEsperanto is developed in the open because we believe in the open source community. 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.2.0.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

File details

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

File metadata

  • Download URL: napari_pyclesperanto_assistant-0.2.0.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.23.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

File hashes

Hashes for napari_pyclesperanto_assistant-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f058581bf0cdbd52f7a8931cd21f967fd16e8443d74c1bbf7b2d2f066e8f61d5
MD5 357e64314b84645b123ad9ab146c92ae
BLAKE2b-256 20e6ffea6928dcb57a8ea20dd021918b912d14b51dc8945b5d325e35df139339

See more details on using hashes here.

File details

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

File metadata

  • Download URL: napari_pyclesperanto_assistant-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.23.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

File hashes

Hashes for napari_pyclesperanto_assistant-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a4f0b1bd8e95b9c77a72edcdc581ff1fb85ae5cced36371d2b7ff0027c82f04
MD5 5478efdc7e67ebbf81db1968fc7d058f
BLAKE2b-256 55b38a4d24e18f267d5e2e42c167111ef494e24d60adbb06048ab5bf9ec38353

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