Get Started

Measuring intensity

1. Measuring Intensity

Once objects have been segmented from the background, their properties can be efficiently measured using tools within SciPy.

2. Measuring intensity

For this lesson, we'll step up to measuring a full three-dimensional volume. We have segmented this volume into two parts: label 1 is the left ventricle, shown here in purple. Label 2 is a circular section from the middle of the image, which will be useful for comparison.

3. Functions

SciPy has optimized many of the most common descriptive functions for image data, including the mean, median, and standard deviation. These functions summarize the array across all dimensions of an image, whether it be 2D, 3D, 4D, or more. They are especially useful when you have a labeled image because you can apply the function to every object independently with a single call. For custom calculations, you can also use the labeled_comprehension() function to summarize your data.

4. Calling measurement functions

Which arguments you specify when you call measurement functions determines the pixels used for the calculation. Here, we have loaded the MRI volume and its corresponding labels. To get the mean intensity of the entire image, simply call ndimage dot mean() with the original volume. If you provide a mask or a labeled array, you will restrict the analysis to all non-zero pixels. However, if you provide a set of labels and an index value, you can get the mean intensity for a single label. On the other hand, if you pass a list of values to the index argument, the function will return a list of mean values - one for each object specified.

5. Object histograms

This technique can be applied to some other SciPy tools, including the histogram function. In the previous chapter, we simply passed in our image array and then specified the minimum value, maximum value, and the number of bins to use. However, if you also include a label array and indices, ndimage dot histogram() will return distributions for each of the selected labels.

6. Object histograms

Plotting these object-level histograms is a great way to evaluate your segmentation. If you see very wide distributions or multiple peaks and valleys in your histogram, your labeled object may include many different tissue types. On the other hand, if the histogram resembles a normal distribution, your segmentation may be doing a good job. This is because the physical properties that influence intensity values should be relatively uniform throughout a tissue. For example, we expect that the voxels in our left ventricle label are filled with blood. Although we expect some variation in their intensity, we also expect them to be centered on some mean value. In this case, we can see that the majority of left ventricle intensity values are higher than the other labeled pixels. Although there are some low values, which are likely not part of the ventricle, the segmentation seems to do a good job overall.

7. Let's practice!

Now it's your turn to measure some specific objects.