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