Biomedical Image Analysis in Python
Stephen Bailey
Instructor
Spatial extent is the product of:
# Calculate volume per voxel d0, d1, d2 = vol.meta['sampling'] dvoxel = d0 * d1 * d2
# Count label voxels nvoxels=ndi.sum(1, label, index=1)
# Calculate volume of label volume = nvoxels * dvoxel volume
1249023
Euclidean Distance
# Create a left ventricle mask mask=np.where(labels == 1, 1, 0) # In terms of voxels d=ndi.distance_transform_edt(mask)
d.max()
12.3847
# In terms of space
d=ndi.distance_transform_edt(mask,
sampling=vol.meta['sampling'])
d.max()
5.8038
com=ndi.center_of_mass(vol, labels, index=1)
com
(5.5235, 128.0590, 128.0993)
plt.imshow(vol[5], cmap='gray')
plt.scatter(com[2], com[1])
plt.show()
Biomedical Image Analysis in Python