Volume turns black after applying transform

Version: 4.11
Operating system: win 10

I am trying to transform a 3D volume that I made using the grayscale model maker. However, after I apply a linear transform, the model turns black.

Before:
image
After:
image

What could cause this to happen?

Thank you in advance.

You applied a transform that turned the model inside out (determinant of the matrix is negative). If you are sure that you want to apply this transform then you can use Surface Toolbox module to reorient the cells in the model (Normals / Flip normals).

1 Like

Version: 5.4.0
Operating system: win 11

Hi, I encountered the same issue for a surface model and I was able to fix it by applying the suggested solution. However, I want to automate my workflow using the python console and include this step in the process. I have not been able to find a way to do it. I have looked online for how to access the Surface Toolbox module and I found this as an example: 3D-Slicer-Scripts/mirror.py at master · jzeyl/3D-Slicer-Scripts · GitHub . This script uses the “Mirror” function of the Surface Toolbox. Similarly, I tried this for the “Compute Surface normals” function, but I get an error message. This is the code I used:

# Get the model node by name
model = slicer.util.getNode("model")

#create new empty model
modelnormals = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLModelNode','modelnormals')
modelnormals.CreateDefaultDisplayNodes()
modelnormals.GetDisplayNode().SetVisibility2D(True)

logic = slicer.util.getModuleLogic('SurfaceToolbox')
logic.computeSurfaceNormals.flipNormals(model, modelnormals)

And this is the error message that I got:

Traceback (most recent call last):
  File "<string>", line 10, in <module>
AttributeError: 'SurfaceToolboxLogic' object has no attribute 'computeSurfaceNormals'

I am new to this programming language and I am not sure how to solve a problem I encountered. I appreciate any guidance or feedback from more experienced coders. Would someone be able to help me or point me in the right direction? Thank you in advance

I managed to solve my own problem! Here is the code I used:

# Get the model node by name
model = slicer.util.getNode("model")

#create new empty model
modelNormals = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLModelNode','modelNormals')
modelNormals.CreateDefaultDisplayNodes()
modelNormals.GetDisplayNode().SetVisibility2D(True)

#perform operation flipping normals on second model, using surface toolbox
logic = slicer.util.getModuleLogic('SurfaceToolbox')
logic.computeNormals(model,modelNormals,flip=True)
2 Likes