Plot Nodes in Slicer

Hi everyone,

I am working on a module to generate a 2D Visualization of the Brain Connectome Network.

I am trying to understand all the 2D plot options in Slicer with Python. So my question is the following:
What are all the node classes that can be added in slicer.mrmlScene.AddNewNodeByClass( ? ) ?

Also, if I would like to plot a vtkSpiderPlot() in an existing window of Slicer, would that be possible? Until now I’ve only managed to plot it in a pop up window that uses the OpenGL Visualization ToolKit.

Thank you all in advance!

Currently line, scatter, and bar plots are available via the GUI. To show spider plots, you would need to do some Python scripting. I would recommend to show this plot first in a plain VTK render window. Once you have that working, then I can help with making that window show up in the view layout.

Thank you for your reply Andras.

I am pretty new to VTK and Slicer.

I have generated the spider plot in a plain VTK render window, which is the pop up window I was talking about before. To do so I used vtkRenderer(), vtkRenderWindow(), vtkRenderWindowInteractor().

So as I would like to make that window show up in Slicer you suggest me to use the view layout.
Should I look at the ? If so, could you help me understand how that should be implemented and what vtkMRML Node to use?

@Sunderlandkyl could you advise how the view class that you recently added to Slicer could be used for this? Thank you.

You can add your vtkRenderWindow to a QVTKWidget, and then add that widget to a layout using qSlicerSingletonViewFactory.


  • Add view factory to layout manager:

      singletonViewFactory = slicer.qSlicerSingletonViewFactory()
  • Add custom layout to layout manager:

      yourLayoutID = 1234
      layoutManager =
      layout = (
        "<layout type=\"horizontal\">"
        " <item>"
        "  <yourtagname></yourtagname>"
        " </item>"
      layoutNode =
        yourLayoutID, layout)
  • Switch to layout with custom widget:
1 Like

Hi @Sunderlandkyl,

Thank you for your response.

I think I am close. I just can’t access QVTKWidget or QVTKRenderWindowInteractor.
I am using 3D Slicer version 4.10.1-2019-01-16. with qt5.
Do you know how I can access those ?
I tried calling defining it like this :

qWidget = vtk.QVTKWidget()

But I get:

AttributeError: ‘module’ object has no attribute ‘QVTKWidget’

@lassoan Do you know of an alternative to QVTKWidget that is wrapped in python?

Alternatively, is there a better way to embed a vtkRenderWindow() in a QWidget?

ctkVTKOpenGLNativeWidget can be used for this.

1 Like