Hello. I´m an absolute newbie to Slicer so forgive me if my questions are a bit daft.
I found 3D Slicer by chance searching for a solution to a problem I have.
We have a lot of different cylindrical “connectors” that we need to spot weld in place. In an effort to pre select welding parameters, and to find possible troublesome connectors, I´m trying to estimate the total resistivity of all our connectors (hundreds of different) and one way I found to do that is to calculate the average cross section area through the components z-axis and then divide the total height of the components with this average area.
Enter 3D Slicer…
I found that the module Segment Cross-section Area gives me a table with the area of a bunch of slices if used on our STL-files. This table I copy to excel for further calculations.
Now, a few questions.
If I do this on components with the same height but different diameters I seem to get different amount of rows in the table. I guess based of it being sliced in different slice thickness? What sets this “thickness”? Can I set it somehow?
I open the STL-file by drag and drop and then state “Segmentation” in the pop-up.
I have a lot of these models to analyze. Is it possible to do it in batch?
Preferably with the average slice area of each file as the only output.
Thank you in advance!
Hello again.
I started to do some learning by trail and error in Python Console.
Managed to select module by:
slicer.util.selectModule(“SegmentCrossSectionArea”)
and then load my stl-file by:
segmentNode = slicer.util.loadSegmentation(r"C:\Swep\00070105.ipt.stl")
Now, trying to actually execute the module, I got stuck:
slicer.util.getModuleLogic(‘SegmentCrossSectionArea’).run(segmentNode, “None”, “slice”, “Create”, “Create”)
Following the error I found that it probably misses a table and a chart to put the result in but I´m very new to python and do not have a clue on how to create those.
If someone could point me in the right direction, maybe have some example to refer to, I would be very thankful!
Oh, well.
After quite a bit of trial and error I got where I wanted.
slicer.util.selectModule(“SegmentCrossSectionArea”)
segmentNode = slicer.util.loadSegmentation(r"C:\Anslutningar STL\00070105.ipt.stl")
tableNode = slicer.mrmlScene.AddNewNodeByClass(“vtkMRMLTableNode”)
chartNode = slicer.mrmlScene.AddNewNodeByClass(“vtkMRMLPlotChartNode”)
slicer.util.getModuleLogic(‘SegmentCrossSectionArea’).run(segmentNode, None, “slice”, tableNode, chartNode)
slicer.util.getModuleLogic(‘SegmentCrossSectionArea’).showTable(tableNode)
numCols = tableNode.GetNumberOfColumns()
numRows = tableNode.GetNumberOfRows()
print("Number of Columns: ", numCols)
print("Number of Rows: ", numRows)
print("First Row: ", tableNode.GetCellText(0,2))
print("Last Row: ", tableNode.GetCellText(numRows-1,2))
sumAv = 0.0
for x in range(numRows):
sumAv = sumAv + float(tableNode.GetCellText(x,2))
AverageArea = sumAv/(numRows)
print("Sum Area: ", sumAv)
print("Average Area: ", AverageArea)
But I still wonder if I could state the thickness of the segments/slices and thus set how many rows my table will get, somehow?
Also I wonder if I can preview my posts before posting them…?