1. Measuring morphology
Measuring object "morphology," or shape and size, is another principal aim of image analysis.
2. Morphology
For example, if a patient goes in for an MRI and they find out they have a brain tumor, a natural first question might be: "How big is it?". Or, if they have been monitoring it for some time, they may want to know: "Has it grown?"
3. Spatial extent
To measure the amount of space occupied by an object, we need two quantities: the size of each element in the array and the number of those elements in the object.
Let's calculate the volume of the left ventricle in one of our cardiac images. First, we establish the amount of real, physical space taken up by each voxel. Recall that in DICOM images, we can find this in the "sampling" field of the metadata dictionary. Multiplying the lengths of the first, second, and third dimensions will give us the total volume at each voxel. In this case, the measurements are in cubic millimeters.
Next, we want to count the number of voxels in the left ventricle. We can do this by passing a 1 as input to ndimage dot sum() and then providing it with the labeled array and index of our object. The function will weight each left ventricle voxel with a value of 1 and sum them.
Finally, we multiply the number of voxels by their individual size to get the total volume of the object.
4. Distance transformation
Another useful morphological measure is the distance of each voxel to the nearest background value. This information can help you identify the most embedded points within objects or mask out edge areas.
To perform a distance transformation on a mask or label array, use the dist_transform_edt() function. This will return a new array, where each non-zero voxel has been replaced with the distance to the nearest background voxel.
The maximum value, in this case, reflects how far from the edge the most embedded point is.
If you have access to the sampling rates for each dimension, you can include these to generate values that reflect physical distance. You can see here that the max distance is reduced because the sampling rate is less than one millimeter per pixel.
5. Center of mass
A complementary measure is the center of mass, which you can calculate directly. Mass, in this case, refers to intensity values, with larger values pulling the center towards them.
Just like with the intensity measures, the center_of_mass() function accepts "labels" and "index" arguments. The function returns a tuple of coordinates for each object specified.
For our cardiac data, the center of mass for the left ventricle corresponds to the center of the volume in all three dimensions.
6. Let's practice!
Now it's your turn to measure some tissue. Good luck!