Segmentation with higher resolution

Hi everyone,

I would like to make a segmentation of the eye, with a resolution of 0.1 mm.
For this purpose, I would like to start my segmentation from building spheres from python code.

I tried to start from this code

import SampleData
# Load master volume
sampleDataLogic = SampleData.SampleDataLogic()
masterVolumeNode = sampleDataLogic.downloadMRBrainTumor1()
# Create segmentation
segmentationNode = slicer.vtkMRMLSegmentationNode()
segmentationNode.CreateDefaultDisplayNodes() # only needed for display
# Create segment sclera
eye = vtk.vtkSphereSource()
eye.SetCenter(30, 68, -31)
segmentationNode.AddSegmentFromClosedSurfaceRepresentation(eye.GetOutput(), "1_Sclera", [1.0,1.0,0.0])

That works, but with a resolution of nearly 1mm.

Then I tried to crop the volume, increasing the resolution (scaling), with success, following this instructions. However, now I don’t know how to link the sphere code to the segmentation with this higher resolution.

Unfortunately, I am not good at programming with python, I tried to find help with the vtk library and tutorials, without success.
Thanks in advance for your help

You did it all right, the only point that was missed that you used the input image resolution as segmentation resolution. The simplest would be to crop&resample the input volume before running your script.

You could create a new volume with 0.1mm spacing and use that as input of segmentationNode.SetReferenceImageGeometryParameterFromVolumeNode to avoid additional step of manual cropping&resampling, but without cropping you would get quite large segmentation volumes (2000-3000 voxels along each axis if you have an image of the entire head) and you may run out of memory and/or segmentation may become slow.

It worked :slight_smile: thanks a lot!

1 Like