How to correct for mask volume in ITK?

I use:

shape_stats = sitk.LabelShapeStatisticsImageFilter()
shape_stats.Execute(ROI)
vol_roi = shape_stats.GetPhysicalSize(1)

to get a Region of interest volume. However, I am not sure of the unit. I looked at the same mask in ITK Snap and it is in mm3. But I am not sure if it is accurate as it seems the physical size is the number of voxels within the mask.

Should I multiply it with the voxel size to get accurate volume measurement?

Thanks

Hello @3omarkamal,

The GetPhysicalSize does return the physical object size, no need to multiply by voxel size, that is done by the filter. If your ROI spacing is [1,1] in 2D or [1,1,1] in 3D then the number of voxels coincides with the size, otherwise it will be the physical size.

Short example:

import SimpleITK as sitk

ROI = sitk.Image([2,2], sitk.sitkUInt8)
ROI.SetSpacing([0.5,0.5])

ROI[0,0] = 1
ROI[0,1] = 1

shape_stats = sitk.LabelShapeStatisticsImageFilter()
shape_stats.Execute(ROI)
vol_roi = shape_stats.GetPhysicalSize(1)
print(vol_roi)
2 Likes

Oh sorry. I was wrong.

Sorry, I was wrong too. Apparently the problem is in my Nifti files. I passed the NumPy array into a Nifti file but I think I need to pass the voxel size too.

@zivy

Final thing, I loaded my original dicom files, now the spacing is 1.25 X 1.25 X 1 mm (while the slice spacing in the DICOM header is 3). So while the area should be accurate, the volume calculation assumes that the mask is just multiple 2D layers rather than a true 3D volume. Any thoughts?

Thanks

Hello @3omarkamal,

At what DICOM tag are you looking to obtain spacing? If slice thickness (0018|0050) then that is not the spacing between slices it is the thickness of a single slice and that slice sits in the middle of the region. The spacing in ITK/SimpleITK is based on the Image Position (Patient) and Image Orientation (Patient) tags from multiple images and we assume uniform spacing.

1 Like

Sorry, I meant the slice thickness, It is 3 mm in the DICOM header, but 1 mm in the ITK snap layer info

Hello @3omarkamal,

In ITK-SNAP are you looking under “image information” info tab, “Image Metadata”? If yes, then what you are seeing is the spacing, which as I said is different from slice thickness. If you move to the “Image Metadata” tab in the same dialog you can see the “Slice Thickness” value which should match what you expect.

Again, slice spacing is used to compute the volume, not slice thickness. Hopefully this clarifies things.

2 Likes

Here is a picture explanation of what @zivy is saying. In there they call spacing under different name: increment. In case the link rots, here is the image:

3 Likes

Thanks a lot

Hello,
Is there a formula for computing the spacing in ITK-SNAP?
Here is info of one patient:
image
image

Hello @jizhang02,

Please see this discussion on image spacing. What you highlighted, slice thickness, is a different quantity and is obtained from the DICOM tag (0018|0050).

1 Like