clEsperanto / napari_pyclesperanto_assistant

GPU-accelerated general purpose image processing and image analysis in napari
http://clesperanto.net
BSD 3-Clause "New" or "Revised" License
31 stars 9 forks source link

using pyclesperanto_assistant operations in other napari plugins #38

Open pr4deepr opened 2 years ago

pr4deepr commented 2 years ago

Hi @haesleinhuepf Great work with the napari assistant.

I have a question about translating a workflow generated in napari_pyclesperanto_assistant within other napari plugins.

Say, if I have a plugin to deskew a lattice lightsheet file, I'd like the user to test an image processing workflow using clesperanto_assistant on a few stacks. For example, filtering and binarising a deskewed image. Once the user is happy with the settings, they would then run a batch process, where

is applied to the whole file and the final processed stack is saved. This is all to be done within the napari environment (for now).

I really like this idea of defining workflows and wondering if I can access it from clesperanto_assistant? https://github.com/clEsperanto/pyclesperanto_prototype/blob/master/demo/optimization/workflow_dask.ipynb

Perhaps via this function? https://github.com/clEsperanto/napari_pyclesperanto_assistant/blob/38505600819f3b3e6eb12e93a9095e6949afc9ca/napari_pyclesperanto_assistant/_gui/_Assistant.py#L209

Cheers Pradeep

haesleinhuepf commented 2 years ago

Hi Pradeep,

great timing! I just moved the Workflow class into the napari-time-slicer plugin. Check out its readme. There you find a list of plugins that are compatible and we should add yours! If you use time_slicer in your plugin, it will then allow users to knit workflows which contain your deskew step and others. It also allows to apply the deskewing to multiple time frames, e.g. if the whole time lapse is loaded as 4D dask array. And, you can generate code from a workflow that's open in napari.

Your code should then roughly look like this:

@time_slicer
def deskew(image:napari.types.ImageData, angle, direction, viewer:napari.Viewer) -> napari.types.ImageData:
    ...

Oh and, the napari-assistant (note: clesperanto will be missing in the name) will later bring a new user interface with buttons, where all plugins are available, that are annotated with time_slicer or some others I have in mind...

Let me know if this makes sense!

Cheers, Robert

pr4deepr commented 2 years ago

Hi Robert Thanks for this. This is what I'm looking for. This looks really good. I saw the plugin earlier, but didn't realise immediately what it did. Pretty sure I'll be getting in touch regarding getting it working!

Cheers Pradeep