Area Under the Curve (AUC) of a graph is an important statistical measure with many applications. Often times, the AUC of a hand-drawn graph must be measured, but there is too much "noise" on the page for it be fed through an OCR software. Hence, a common alternative is to tediously record the coordinates of each individual point in a spreadsheet. This new solution reduces the hassle of having to parse through each individual data point and can exponentially speed up the time required to process larger amounts of data.
For the purposes of this demonstration, I will use a plot of blood pressures (similar to a record an anesthesiologist may keep during surgery). AUC of blood pressure readings is often a key measurement used to diagnose patients with hypotension/hypertension in clinical research.
Download ImageJ distributed by the National Institutes of Health (NIH).
Save the hand-drawn graph in .PNG
format. Below is the graph to be used in this demonstration:
Open ImageJ and navigate to Files
> Open
and choose the .PNG
file saved from Step 2.
Click on the Polygon selections
tool in the toolbar and draw a polygon on the opened image around the region whose area you wish to determine. Then, click Analyze
> Measure
.
Click on the Straight*, segmented or freehand lines
tool and draw a horizontal line across the width of the graph. Then, click Analyze
> Measure
.
Navigate to the Results
window and press Ctrl+S
on your keyboard and save the measurements as a CSV
file. If there are multiple graphs, repeat Steps 2 to 6 and save the measurements for each subsequent graph in the same location. After all graph measurements have been saved, download calculate_area.py
from this repository and save it in the same location as the saved CSV
files.
In the same way as the previous steps, take the following measurements:
- Area of a single unit square on the grid
- Length of a single unit square on the grid These measurements will be used in Step 8.
Run calculate_area.py
via the terminal or the IDE of your choice and you will be prompted to enter the following parameters in the Console:
Pixels per unit square
: the area of a single unit square on the grid (measured in Step 7)Area per unit square
: the area of each square in the units of the given context- In our example, the area per unit square is
5*10=50
since each unit width represents 5 minutes and each unit height represents 10 mm Hg.
- In our example, the area per unit square is
Value represented by each unit length
: the value of each unit length in the given context.- In our example, this parameter is equal to
5
.
- In our example, this parameter is equal to
Number of pixels per unit length
: the length of a single unit square on the grid (measured in Step 7)Starting value on the y-axis
: the y-value at the x-axis- In our example, this value is
50
. After inputting the parameters, the rest of the program should run and the AUC value will be found in theCSV
file with the name inputted by the user.
- In our example, this value is