Rendering spherical glyphs

Operating system: OSX
Slicer version: 4.10.0
Expected behavior:
Actual behavior:

Can Slicer render spherical glyphs associated with VTK polydata (verts). For example, given the following data file (.vtk) of 4 vertices:

# vtk DataFile Version 2.0
Verts example
ASCII
DATASET POLYDATA
POINTS 4 float
0.0 0.0 0.0
1.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
VERTICES 4 8
1 0
1 1
1 2
1 3
POINT_DATA 4
SCALARS phenotype float 
LOOKUP_TABLE default
0.0
1.0
2.0
3.0

can Slicer render something similar to the attached image (rendered w/ ParaView)? If so, what are the steps? I’ve found the “Data” panel which sort of show the contents of the data, but where do I go to render glyphs associated with vertices?

pv_4verts

You can display colored polydata using models module. If your polydata has only points then you need to write a few lines of Python code to run the input through a VTK glyph filter.

What wouod you like to achieve?

We typically render biological cells as spheres in our open source PhysiCell software. And we’re beginning a new project which will require visualizing/analyzing/interacting with tissue maps (images). So I was exploring Slicer, to see if it meets some of our needs.

I’d like to learn more about the Python option for rendering spheres. I see Slicer provides a built-in Python (2.7.x) interpreter and that I can import vtk there.

Later, I may want to install additional 3rd party Python libs, e.g., scipy, if that’s possible.

Slicer should be able to visualize these models quite well. There are many visualization modes, both for 2D and 3D.

I’d like to learn more about the Python option for rendering spheres.

You can create a colored model using a short script as shown in this notebook: https://github.com/lassoan/SlicerNotebookDemos/blob/master/ColoredSpheres.ipynb Binder

inputPointFileName = os.getcwd()+"/data/ColoredPoints.vtk"

glyph = vtk.vtkGlyph3D()

pointSourceNode = slicer.modules.models.logic().AddModel(inputPointFileName)
glyph.SetInputConnection(pointSourceNode.GetMeshConnection())

glyphSource = vtk.vtkSphereSource()
glyphSource.SetRadius(0.1)
glyph.SetSourceConnection(glyphSource.GetOutputPort())

glyphedModelNode = slicer.modules.models.logic().AddModel(glyph.GetOutputPort())
glyphedModelNode.GetDisplayNode().SetActiveScalarName("phenotype")
glyphedModelNode.GetDisplayNode().SetScalarVisibility(True)

# Display in 3D view
slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUp3DView)
slicer.util.resetThreeDViews()
display()

Later, I may want to install additional 3rd party Python libs, e.g., scipy, if that’s possible.

For now, you need to launch Python scripts that use scipy in an external process (as it is done in SlicerRadiomics), but hopefully in a couple of months Slicer will switch to Python3 and then you can use scipy directly in the Slicer process.