Skip to content

haemorrhage computation after segmentation #1166

Answered by tangy5
YuanSingapore asked this question in Q&A
Discussion options

You must be logged in to vote

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:

    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] * 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@YuanSingapore
Comment options

Answer selected by YuanSingapore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants