Panel: VtkJS extension of 3D data viewer

Created on 21 Jan 2020  路  12Comments  路  Source: holoviz/panel

Panel is AMAZING project!
All the ideas behind are so great!
Especially this concept of develope -> embed -> serve - truly remarkable modernization of R&D web-python interface!

Recent development with Kitware on VTK support is really amazing.
Especially 3D viewer!

But there are few caveats:

Any thoughts, @philippjfr, @jbednar, @jlstevens ?

enhancement

Most helpful comment

Could look like this
ezgif com-video-to-gif (9)

All 12 comments

I love the fact that it embeds data inside HTML - but is there anyway to pass an optional save/load parameters

In principle, sure, should be a separate feature request though.

Visualizing 3D data using VolumeViewer is really awesome - but is there anyway to implement this 3D slicing example (MultiSliceImageMapper)

A good question for @xavArtley.

Integration with ipyparaview widget

Once bokeh 2.0 is released ipywidgets can be used from within Panel using the ipywidget_bokeh package.

Hello, MultiSliceImageMapper should not be difficult to implement as a separate pane.

Could look like this
ezgif com-video-to-gif (9)

@xavArtley You rock!

@xavArtley , this is simply brilliant! Wow!
Two questions:

  • where can I get it to try on my data
  • will it work on 3D Numpy arrays or it requires something special for that?

For the moment it's in this branch https://github.com/holoviz/panel/tree/xav/multi_slice_image_mapper
And yes it works like the vtkvolume panel on numpy array and vtkImageData

@xavArtley , I just tested it and it looks beautiful. One thing I noticed is that I cannot embed the widgets actions in HTML - it basically doesn't react when I browse it in the HTML and not within notebook.
For example, VTKVolume works even in HTML embedded mode.

One thing I noticed is that I cannot embed the widgets actions in HTML - it basically doesn't react when I browse it in the HTML and not within notebook.

I've just opened https://github.com/holoviz/panel/issues/1003 because this is a prime candidate for that. If the Python based slider -> slice link were converted to JS it would work even in the static export.

Without changing panel code this should do the trick:

import param
import numpy as np
import panel as pn
import pyvista as pv
from pyvista import examples
pn.extension('vtk')
# Download a volumetric dataset
vol = examples.download_head()
p = pn.pane.vtk.VTKSlicer(vol, origin=(-5,-5,-5), spacing=(3,2,1), sizing_mode='stretch_both')
class SlicerController:
    parameters=[('slice_I', pn.widgets.IntSlider),
                ('slice_J', pn.widgets.IntSlider),
                ('slice_K', pn.widgets.IntSlider),
                ('color_level', pn.widgets.FloatSlider),
                ('color_window', pn.widgets.FloatSlider),]

    def __init__(self, slicer):
        for item in self.parameters:
            param_name = item[0]
            param_value = getattr(slicer, param_name)
            param_bounds = slicer.param[param_name].bounds
            widget_type = item[1]
            widget = widget_type(value=param_value,
                                 start=param_bounds[0],
                                 end=param_bounds[1])
            widget.jslink(target=slicer, value=param_name)
            setattr(self, param_name, widget)

    def panel(self):
        return pn.Column(*[getattr(self,item[0]) for item in self.parameters])
pn.Row(SlicerController(p).panel(), p, sizing_mode='stretch_both').save('test.html')

https://xavartley.github.io/#panel/vtk_examples/vtkSlicer.html

Thank you, @xavArtley! This looks beautiful! Really good example of powerful holoviz infrastructure. As far as I understood it is expected this to show at 0.8. Or will it come earlier?

Almost certainly later, I'm still trying to get 0.8 out asap. Although I've trying to get in one last major PR (specifically https://github.com/holoviz/panel/issues/1003), which aims to make jslinks more powerful by default and automatically enable them on embed.

I'll close the save/load has it's own issue and ipywidget integration is on the roadmap (and will just work once we release a version compatible with bokeh 2.0).

Was this page helpful?
0 / 5 - 0 ratings