Mat
February 18, 2023, 2:40am
1
Operating system: Windows 11
Slicer version: 5.3
Expected behavior: complete successfully
Actual behavior: fails
I’m trying to create a volume mesh using segmentMesher and it keeps failing:
Generating volumetric mesh…
Error: ‘vtkmodules.vtkFiltersCore.vtkThreshold’ object has no attribute ‘ThresholdByUpper’
Is there something I’m missing out?
Thanks!
Mathieu
lassoan
(Andras Lasso)
February 18, 2023, 4:50am
2
This is due to an incorrect API change in VTK (they removed a very widely used method). The fix should be really simple. I’ll try to get to it within a few days.
Mat
February 19, 2023, 9:20pm
3
Thanks Andras, let me know when it is ready, I’ll give it a try! The goal is to import the geometry in COMSOL software for CFD modelling.
Thanks again!
Mat
Mat
March 14, 2023, 1:28am
4
Hello Iassoan, I was wondering if you had the chance to look at my issue? Your sure are a busy man with all the requests from users
Thanks!
Mathieu
Shajia_Ali
(Shajia Ali)
September 26, 2025, 2:15pm
5
This post is quite Old, I am using Slicer 5.8.1 and I have a similar problem
AttributeError: ‘vtkmodules.vtkFiltersCore.vtkThreshold’ object has no attribute ‘ThresholdBetween’
Is there a solution for that?
I wanted to split my mesh created by Segmented mesher into two meshes.
Edit: My workaround right now:
meshNode = getNode('200µm_Wuerfel')
mesh = meshNode.GetMesh()
cellData = mesh.GetCellData()
labelsRange = cellData.GetArray("labels").GetRange()
for labelValue in range(int(labelsRange[0]), int(labelsRange[1]) + 1):
threshold = vtk.vtkThreshold()
threshold.SetInputData(mesh)
threshold.SetInputArrayToProcess(
0, 0, 0,
vtk.vtkDataObject.FIELD_ASSOCIATION_CELLS,
"labels"
)
# untere & obere Schwelle gleich setzen
threshold.SetLowerThreshold(labelValue)
threshold.SetUpperThreshold(labelValue)
threshold.SetThresholdFunction(vtk.vtkThreshold.THRESHOLD_BETWEEN)
threshold.Update()
if threshold.GetOutput().GetNumberOfPoints() > 0:
modelNode = slicer.mrmlScene.AddNewNodeByClass(
"vtkMRMLModelNode",
f"{meshNode.GetName()}_{labelValue}"
)
modelNode.SetAndObserveMesh(threshold.GetOutput())
modelNode.CreateDefaultDisplayNodes()