calculate volume of mask 1

calculate volume of mask

import nibabel as nb
import numpy as np
img = nb.load("path/to/img.nii")
num_vox = np.sum(img.get_data() > 0)

Here is what the above code is Doing:
1. Load the image
2. Get the data from the image
3. Sum the number of voxels that are greater than 0

Similar Posts