Can anyone let me know how to do it in python? here is my code to create a segment with default (1x1x1) voxel size but I want to change it to 0.004x0.004x0.004
Create segmentation
segmentationNode = slicer.mrmlScene.AddNewNodeByClass(“vtkMRMLSegmentationNode”)
segmentationNode.CreateDefaultDisplayNodes() # only needed for display
segmentationNode.SetName(‘Segmentation’)
You can set the geometry (origin, spacing, axis directions, and extens) of the binary labelmap segmentation as shown in this example in the script repository.
thank you for the reply but in that case I will have to allocate memory to each element which is huge in my case so it gives the error “Unable to allocate 242857881500 elements of size 1 bytes.”
is there a way to create the segmentation like I did before in the simple code and then modify its spacing?
This means that your reference image size would be 226GB. In general, I recommend to have 10x more RAM than your reference image size, which would mean that you would need 2260GB RAM and really, really fast processor to be able to do anything with this data.
These requirements are unrealistic to meet with today’s computing hardware, so I would recommend to reconsider your resolution needs or crop your data to a smaller region.
There might be also some misunderstanding about units. What is the distance unit of your model (meter, milllimeter, …)? What is the distance unit for 0.004?
In the script example, an empty margin of 10mm is added around the model, which corresponds to about 5000 pixels along each axis. Probably you want to change it to something like outputVolumeMarginMm = 0.012.
I am importing an stl file of a cylinder that I created on 3dslicer
I wrote a code where i would draw a 2 points (markups) and then a cylinder of radius 3mm and height 3mm would be created and exported as an stl file but I did not specify any bounds i just specified the points on the GUI to assign the center and direction along these points. this is the code
VolumeMargin is just used in your own code, it is not an effect parameter.
I suspect that the two segments are far from each other, which would make the combined segmentation too large.
I would recommend to work with lower resolution (larger spacing) during development to make everything work faster and let you see the results even if you make some small mistakes.