Remotely interacts with napari
- Enable remote interaction in napari
- Start remote interaction in napari with using either of the following menus:
- Tools → Utilities → Remote interaction
- Plugins → napari-remote-interaction: Remote interaction
- Set hostname, port and key arguments, then click "Connect"
- Start remote interaction in napari with using either of the following menus:
- Create RemoteInteractor in external process or on external host
from napari_remote_interaction import RemoteInteractor viewer = RemoteInteractor(hostname="*", port=5555, key="#mykey789")
RemoteInteractor
is intended to eventually mirror the API of napari.Viewer
as closely and completely as feasible.
Currently, there are a few peculiarities:
# Create random test image
import numpy as np
image_czyx = np.random.randint(0, 255, (2, 32, 64, 64), np.uint8)
# View image with remotely running napari GUI
call = viewer.add_image(image_czyx, scale=[2.0, 1.0, 1.0], channel_axis=0)
viewer(call)
Note that we first called viewer.add_image
normally, and then passed the return value to viewer
. This pattern
should work for most of napari.Viewer
's methods.
We can do a few more things, for example:
# Get nr of layers. The extra call is taken care of in the case of len.
len(viewer.layers)
# Get data from our remote napari GUI (extra call needed again)
viewer(
viewer.layers[0].data[0, :]
)
# Get an exception (IndexError) that is raised inside the remote napari GUI
viewer(
viewer.layers[999]
)
This napari plugin was generated with Cookiecutter using @napari's cookiecutter-napari-plugin template.
To install the latest development version:
pip install git+https://github.com/bhoeckendorf/napari-remote-interaction.git
To update to the latest development version:
pip install --force-reinstall --no-deps git+https://github.com/bhoeckendorf/napari-remote-interaction.git
Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.
Distributed under the terms of the Apache Software License 2.0 license, "napari-remote-interaction" is free and open source software
If you encounter any problems, please file an issue along with a detailed description.