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.
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.
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.
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.