haemorrhage computation after segmentation #1166
-
Dear MONAI community, We have used MONAI Label to successfully train a model to segment haemorrhage for CT image. The doctors are looking for a way to get the volume directly after segmentation. Is there any tool in MONAI that be added to automatically calculate the volume of the segmented part? or, do you have any custom/tailored tool for that purpose? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @YuanSingapore , thanks for the question. Such as below simple code for calculating volume from a NIFTI label: import nibabel as nib
import numpy as np
# Get image objects
image_path = <your NIFTI image path>
image_nib = nib.load(image_path)
image_np = np.array(image_nib.dataobj)
# Get image headers, pixdims, voxel volume
image_header = image_nib.header
image_voxel_size = image_header.get_zooms()[:3]
voxel_volumn = image_voxel_size[0] * image_voxel_size[1] * image_voxel_size[1]
# Ge the number of label voxels
idx1 = np.where(image_np == 1)
voxel_number1 = len(idx1[0])
# Get volume of predicted 3D mask
mask_volumn = voxel_number1 * voxel_volumn / 1000 You can customize the MONAI Label app to return the volume automatically, or you could look for client viewers if any volume calculation add-ons are supported. Hope this helps. Thanks |
Beta Was this translation helpful? Give feedback.
Hi @YuanSingapore , thanks for the question.
Are "Get volume of the segments" means to obtain the volumetrics such as cubic centimeters (CC)?
If so, you can calculate the CC from the 3D image by reading the pixdim and segmentation labels:
Such as below simple code for calculating volume from a NIFTI label: