Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Npe2 plugin #37

Merged
merged 2 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 30 additions & 11 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ on:
workflow_dispatch:

jobs:
check-manifest:
name: Check Manifest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- run: pip install check-manifest && check-manifest

# Won't work without GPU

# test:
Expand Down Expand Up @@ -54,25 +62,36 @@ jobs:
# - name: Coverage
# uses: codecov/codecov-action@v1


deploy:
# needs: test
name: Deploy
needs: check-manifest
if: "success() && startsWith(github.ref, 'refs/tags/')"
runs-on: ubuntu-latest
if: ${{ github.repository == 'tlambert03/pycudadecon' && contains(github.ref, 'tags') }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: "3.x"
- name: Install dependencies

- name: install
run: |
python -m pip install --upgrade pip
pip install -U setuptools wheel twine
git tag
pip install -U pip
pip install -U build twine
python -m build
twine check dist/*
ls -lh dist

- name: Build and publish
run: twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }}
run: |
git tag
python setup.py sdist bdist_wheel
twine upload dist/*

- uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
11 changes: 10 additions & 1 deletion pycudadecon/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
__version__ = "0.2.0"
try:
from importlib.metadata import PackageNotFoundError, version
except ImportError:
from importlib_metadata import PackageNotFoundError, version

try:
__version__ = version("pycudadecon")
except PackageNotFoundError:
__version__ = "uninstalled"

from typing import Any

lib: Any
Expand Down
54 changes: 32 additions & 22 deletions pycudadecon/napari.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,44 @@
"""
This module is an example of a barebones QWidget plugin for napari
from typing import TYPE_CHECKING

It implements the ``napari_experimental_provide_dock_widget`` hook specification.
see: https://napari.org/docs/dev/plugins/hook_specifications.html
if TYPE_CHECKING:
import napari.types

Replace code below according to your needs.
"""
from magicgui import magic_factory
from napari_plugin_engine import napari_hook_implementation

from napari.types import ImageData
from pycudadecon.deconvolution import decon


@magic_factory(call_button="Deconvolve")
def deconvolve(
image: ImageData,
psf: ImageData,
image: "napari.types.ImageData",
psf: "napari.types.ImageData",
image_pixel_size=0.1,
image_zstep=0.5,
psf_pixel_size=0.1,
psf_zstep=0.1,
iterations=10,
) -> ImageData:
) -> "napari.types.ImageData":
"""Deconvolve `image` using `psf`.

Parameters
----------
image : ImageData
image array
psf : ImageData
psf array
image_pixel_size : float, optional
image pixel size in microns, by default 0.1
image_zstep : float, optional
image z step in microns, by default 0.5
psf_pixel_size : float, optional
psf pixel size in microns, by default 0.1
psf_zstep : float, optional
psf z step size in microns, by default 0.1
iterations : int, optional
number of iterations, by default 10

Returns
-------
ImageData
deconvolved image.
"""
from pycudadecon.deconvolution import decon

return decon(
image,
psf,
Expand All @@ -32,9 +48,3 @@ def deconvolve(
dzpsf=psf_zstep,
n_iters=iterations,
)


@napari_hook_implementation
def napari_experimental_provide_dock_widget():
# you can return either a single widget, or a sequence of widgets
return deconvolve, {"name": "CUDA-Deconvolution"}
11 changes: 11 additions & 0 deletions pycudadecon/napari.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: pycudadecon
display_name: pyCUDAdecon
contributions:
commands:
- id: pycudadecon.deconvolve
python_name: pycudadecon.napari:deconvolve
title: Deconvolve
widgets:
- command: pycudadecon.deconvolve
display_name: CUDA-Deconvolution
autogenerate: True
14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools-scm>=6.2"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]

[tool.check-manifest]
ignore = [
".pre-commit-config.yaml",
"test/**/*",
"docs/**/*",
"examples/**/*",
"CHANGELOG.md",
]
11 changes: 8 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[metadata]
name = pycudadecon
version = 0.2.0
description = Python wrapper for CUDA-accelerated 3D deconvolution
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down Expand Up @@ -35,15 +34,21 @@ project_urls =

[options]
packages = find:
include_package_data = True
install_requires =
numpy
tifffile
typing_extensions
importlib-metadata;python_version<'3.8'
python_requires = >=3.6

[options.entry_points]
napari.plugin =
pycudadecon = pycudadecon.napari
napari.manifest =
pycudadecon = pycudadecon:napari.yaml

[options.package_data]
* = *.yaml


[options.extras_require]
dev =
Expand Down