Pyzmq in slicer python

Operating system: Ubuntu 16
Slicer version: 4.7
Expected behavior:
Actual behavior: Can’t Import pyzmq

Is there any way one could import pyzmq into slicer python module ? I want to process 3d scans in my python modules that I can’t install in slicer. At least communication support should be able to do.

Slicer can receive surfaces, volumes, transforms, etc. in real-time through OpenIGTLink protocol. There are a couple of Python implementations of OpenIGTLink (I haven’t tried them, it would be great if you could try them and report back), so it would be probably much simpler to use that protocol instead. You can set up connections in OpenIGTLinkIF module.

At first sight, None of these ( ; implement image sending and receiving using igtlink protocol.

The first one has an example of sending a numpy array as an image message.

For zmq, recent Slicer nightly versions include pip, and should be able to download a pre-compiled (wheel) version. In the slicer python prompt: import pip; pip.main(['install', 'PyZMQ'])

That said, Andras’ suggestion is still better because:

  • you need to very careful with the event loop among python, slicer, qt, etc. and this work has already been done for OpenIGTLink
  • I’m not sure what the Slicer + wheel (pypi) compatibility level is across platforms. I believe there is/was at least one weird shared library compatibility issue on linux for pyradiomics.
1 Like

You’re right. I think i’ll have to mesh both implementation to achieve both send/receive images.
Thank you both!

You cannot get precompiled binary python packages on Windows (Slicer uses Python 2.7 and VS2013).

It would be great if you could test these Python OpenIGTLink implementations. If you find a nice, promising one then we would be happy to help with fixing issues or extending it to additional message types, etc.

1 Like

Be aware that the second implementation is GPL licensed, so you need to abide by the GPL provisions. Practically: any derived code must also be provided under GPL (there are many in-depth discussions on the internet of the implications).

Thanks for checking. I can only afford to spend time with code that we can use without restrictions, so it would be important to choose something based on BSD, MIT or similar license.