Measuring in time
1. Measuring in Time
To cap off this chapter, let's solve our original problem: how to measure the ejection fraction of a person's heart.2. Ejection fraction
To calculate the ejection fraction, we have to find the left ventricle's volume when it's totally relaxed -- its maximum -- and when it's fully squeezed -- its minimum. Taking the difference between these two volumes and dividing by the maximum yields the fraction of blood that is pumped out and into the rest of the circulatory system.3. Ejection fraction
One way to accomplish this is to: First, segment the left ventricle at each time point. Second, calculate the volume at each time point sequentially, using a for loop. This results in a 1D time series from which we can extract our minimum and maximum values. Values in hand, we plug them into the ejection fraction equation.4. Calculate volume for each time point
Let's assume that we have access to both the volumetric time series and the segmented left ventricle. The data are 4-dimensional, with time as the first dimension. First, we calculate the volume of each individual voxel. We extract the sampling rate along each dimension, then multiply the spatial dimensions together to get the space occupied by each element. Next, we instantiate an empty 1D array to record the volume at each time point. We then loop through each time point, counting the number of voxels in the left ventricle. Finally, we multiply the number of voxels by their volume and store the value in the time series array. The plot of the data lines up with our expectations: in the first few time points, there is a squeezing action on the ventricle, followed by relaxation, where it fills up again.5. Calculate ejection fraction
Now, it's simply a matter of selecting the lowest and highest values from the time series and calculating the ejection fraction. Since "ts" is a NumPy array, we can call the min() and max() methods to retrieve these values. Then, we find the difference and divide by the maximum volume. And that's it! We've put together an estimate of the ejection fraction using SciPy - a process that would normally be done by hand by a radiologist. And we've done a pretty good job, even with the simple segmentation method: the expert's estimate was 0.60, quite close to our value.6. Let's practice!
Of course, this analysis was for a high-quality image of a single subject. Evaluating data from many subjects and images allows for more interesting insights about health and disease. We'll discuss techniques and pitfalls of multi-image analysis in the next chapter.Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.