itk-vtk-viewer icon indicating copy to clipboard operation
itk-vtk-viewer copied to clipboard

Supporting google colab with imjoy-rpc

Open oeway opened this issue 4 years ago • 8 comments

With the latest imjoy-rpc (see https://github.com/imjoy-team/imjoy-rpc/pull/54) you can now run the itk-vtk-viewer inside google colab.

Screenshot 2020-08-20 at 11 08 58

Try it here: Open In Colab

Not only showing the viewer statically, but we can actually support lazy data loading which will be super helpful for visualising multi-scale images in Zarr (see a PR I made for vizarr here).

If we proceed with the imjoy-rpc support in itk-vtk-viewer (see this issue), we will gain capability to run in Google colab right away.

Would you interested in adding some imjoy-rpc code to the hosted PWA here, so we make it officially supported?

oeway avatar Aug 20 '20 09:08 oeway

@oeway awesome!!!

Yes, I will start integrating this now :-D. I have been AFK for a while, but I am back now.

thewtex avatar Sep 29 '20 18:09 thewtex

Great! Welcome back!

BTW, for demonstration purpose in python, which volumetric example data do you usually use? I used random volume but doesn't look nice.

oeway avatar Sep 29 '20 19:09 oeway

Thanks!

I typically use this monkey brain: https://mybinder.org/v2/gh/InsightSoftwareConsortium/itkwidgets/master?urlpath=lab/tree/examples%2F3DImage.ipynb

thewtex avatar Sep 29 '20 20:09 thewtex

OK, thanks!

Just tried, it seems colab has some issue when trying to send large object to the frontend. Will need to wait for the zarr support.

BTW, it seems the itkwidgets binder failed to build:

Enabling notebook extension itkwidgets/extension...
      - Validating: OK
Building jupyterlab assets (build:prod:minimize)
An error occured.
RuntimeError: JupyterLab failed to build
See the log file for details:  /tmp/jupyterlab-debug-gbq_51ua.log
Building jupyterlab assets (build:prod:minimize)
An error occured.
RuntimeError: JupyterLab failed to build

oeway avatar Sep 29 '20 21:09 oeway

Since we already supported ImJoy api, the viewer works directly in Colab, I updated the colab notebook: Open In Colab

However, the official version doesn't support compressed encoding (i.e. zstd compression in itkwidgets), colab will crash if we send a large volume (e.g. the monky brain).

I tested the zstd compression from my forked version, and it works: Screenshot 2020-11-04 at 00 08 12 (this part is also included in the above notebook)

@thewtex What do you think? should we take what you have in the itkwidgets also here? or the plan is to go directly to the zarr + multiscale? I guess the later would be even more scalable for supporting large volumes.

oeway avatar Nov 03 '20 23:11 oeway

BTW, while the colab support works for most cases for visualizing images with the itk-vtk-viewer, we encountered issue when we try to pass callbacks from Kaibu. It appears that the asyncio support in Colab is buggy at the moment, see the issue I reported here: https://github.com/googlecolab/colabtools/issues/1648, hopefully they can fix it soon.

oeway avatar Nov 03 '20 23:11 oeway

@oeway awesome!! -- Adding the ImJoy+Python+zarr+multi-scale support, which we will use in itkwidgets, but we will be able to use it outside, e.g. ImJoy + Python, or pure JavaScript, e.g. Kaibu + itk-vtk-viewer. The compressed chunking should help with Colab reliability. Thanks for the report. I will keep on the improvements and testing, and follow-up in this issue once we have large images working in Colab.

thewtex avatar Nov 04 '20 18:11 thewtex

@bnmajor is looking into this.

thewtex avatar May 19 '22 00:05 thewtex