Hi,
I need to create a script that splits one segment (e.g. volume lung) into three equal parts to simulate the three different lung lobes. (upper, mid and lower part).
Is there a good example to start or can you provide advice on the key commands to use?
If you want to split to three equal volumes then you can use the new Segment cross-section area extension to compute cross-sections along slices. You can get the positions as a table and get physical position of 0, 1/3, 2/3, full volume like this:
crossSectionsTable = getNode('Segment cross-section area table')
positions = slicer.util.arrayFromTableColumn(crossSectionsTable, 'Position')
areas = slicer.util.arrayFromTableColumn(crossSectionsTable, 'Segment_1')
import numpy as np
volumeRatio = np.cumsum(areas)/np.sum(areas)
slicePositions = np.interp([0.0, 1.0/3.0, 2.0/3.0, 1.0], volumeRatio, positions[:,3])
print("Slice position along IS axis for zero, 1/3, 2/3, and full volumes: "+str(slicePositions))