This means the scale of the 3D data (these segmentation) are wrong. Did you create them after you modified the image spacing of your volume or before? Because if you created them before, they will have the wrong scale.
I did the segmentation before putting the ruler bar. So, do I have to do the segmentation again to get the correct ruler in 3D image?
As you are observing, it is important to check that the imported image stack has the correct image spacing as the first step of your workflow. Since everything else (segmentations → models → measurements) are all dependent on this piece of information. This is especially true if you importing these images from 2D formats like PNG/TIFF etc which doesn’t preserve this information.
You don’t have to redo the segmentation but it will take you a few steps to get them in correct alignment. This is what I would suggest (@lassoan is there a simpler fix?)
- Go to
segmentations
module export your current segmentation as a label map - After the export right-click on the exported labelmap and choose “Edit Properties”
- This will take you
Volumes
module where you can cross reference the slice spacing, dimensions, and IJK matrix of the master volume and this labelmap. Expand the Volume Information tab (see below). Everything reported for the labelmap should match to that of the master volume. You can use the dropdown button to switch between the original volume and the labelmap. (see below) - Once the labelmap is fixed, you can right click and choose “Convert to labelmap to segmentation”.
This new segmentation should have the right spacing, Delete everything else…
Next time, you’d help yourself if you use the ImageStacks
from SlicerMorph extension and then enter the correct spacing in the module and then import the stack.
If the segmentation has unit spacing, zero origin, RAS-axis-aligned IJK axes then you can transform it to the correct space by applying the IJKToRAS matrix of the volume. You can type this to the Python console (replace MRHead
and Segmentation
by the name of the volume and segmentation nodes):
ijkToRas = vtk.vtkMatrix4x4()
getNode('MRHead').GetIJKToRASMatrix(ijkToRas)
getNode('Segmentation').ApplyTransformMatrix(ijkToRas)
I tried 3 times the first step and got the same answer:
The computer has 64 RAM memory and I run the 3D Slicer at an SSD
@Andreza when you are reporting an issue, please also report at what step you get this error. Are you following my instructions or @lassoan?
This means you have ran out of memory, probably your volume is very big (or you have too many things open at the same time). You can choose to increase the virtual memory (perhaps something like 128GB) as the error says, and rerun the things. It will take slower, but you shouldn’t encounter this problem.