Calculating area under the curve for glucose responses over time

19 views (last 30 days)
Hi,
I'm completely new to MatLab having recently downloaded it to create Bland Altman and Clarke error grid analysis.
We recently performed a randomised, open-label, four-period crossover trial consisting of 23-hour inpatient phases in a medically supervised clinical research facility. On each visit, participants administered either a regular (100%) or reduced (50%) dose (100%; 5.1±2.4 versus 50%; 2.6±1.2 IU, p<0.001) of individualised IAsp one hour before and after a 45-minute bout of evening semi-recumbent cycling.
I would like to plot area under the curve at various aspects of these trials i.e. in response to meals/exercise/insulin doses. I have my raw excel data with the glucose cocnentrations of each person and the time gap inbetween each concentration.
Would someone be able to help me understand how best I can do this please? I have read that the integral AUC would be most appropriate when dealing with glucose. if someone has any experience with how to create the graphical data to support this it would be very helpful.
Any help would be greatly appreciated.
Kind regards,
Olivia
  9 Comments
Star Strider
Star Strider on 2 Jan 2020
As I understand it then you want to know if ‘E’ and ‘K’ are correct.
What data did you use to calculate them?
What assumptions did you use? Is the baseline 0 mmol/L or the concentration at the start of each study?
How did you calculate them?
Olivia McCarthy
Olivia McCarthy on 3 Jan 2020
Yes, and then I can treat these statistically to see whether they differ between the trials.
If you click on the square you can see the formular used. It's the trapzeoid methodology
The baseline is the start of each study i.e. The first glucose value of each participant next to the 'breakfast' row.

Sign in to comment.

Answers (1)

Cameron B
Cameron B on 3 Jan 2020
Looks like your trapezoidal integration is correct. I checked your Excel formula and didn't find anything wrong, and I did the following and got your same numbers for the Delta, patient 4, Venous BG AUC.
xx = [0,3,6,9,10,10.75,11.25,11.5,12.5,13.5,14.5,15.5,17.5,19.5,21.5,22.5]
yy = [10.9,7.2,7.7,6.41,11.4,6.63,7.85,8.92,14.17,15.43,12.01,15.67,15.78,13.42,12.46,9.99];
aa = cumtrapz(xx,yy);
for bb = 2:length(xx)
cc(bb) = aa(bb) - aa(bb-1);
end
disp(cc)
If you're asking to check each integration then that will be a little more work. But as it stands, it looks like your calculations are correct for area under the curve using trapezoidal integration.
  3 Comments
Cameron B
Cameron B on 3 Jan 2020
[file,path] = uigetfile('.xlsx');
cd(path)
[ALPHAdata,~,~]= xlsread(file,1);
[BETAdata,~,~]= xlsread(file,2);
[GAMMAdata,~,~]= xlsread(file,3);
[DELTAdata,~,~]= xlsread(file,4);
mm = 1;
for startval = 1:16:241
[albg,~] = fillmissing(ALPHAdata(startval:startval+15,4),'linear','SamplePoints',ALPHAdata(startval:startval+15,3));
[alsens,~] = fillmissing(ALPHAdata(startval:startval+15,10),'linear','SamplePoints',ALPHAdata(startval:startval+15,9));
alphabg(mm,1) = trapz(ALPHAdata(startval:startval+15,3),albg);
alphasens(mm,1) = trapz(ALPHAdata(startval:startval+15,9),alsens);
[bebg,~] = fillmissing(BETAdata(startval:startval+15,4),'linear','SamplePoints',BETAdata(startval:startval+15,3));
[besens,~] = fillmissing(BETAdata(startval:startval+15,10),'linear','SamplePoints',BETAdata(startval:startval+15,9));
betabg(mm,1) = trapz(BETAdata(startval:startval+15,3),bebg);
betasens(mm,1) = trapz(BETAdata(startval:startval+15,9),besens);
[gmbg,~] = fillmissing(GAMMAdata(startval:startval+15,4),'linear','SamplePoints',GAMMAdata(startval:startval+15,3));
[gmsens,~] = fillmissing(GAMMAdata(startval:startval+15,10),'linear','SamplePoints',GAMMAdata(startval:startval+15,9));
gammabg(mm,1) = trapz(GAMMAdata(startval:startval+15,3),gmbg);
gammasens(mm,1) = trapz(GAMMAdata(startval:startval+15,9),gmsens);
[debg,~] = fillmissing(DELTAdata(startval:startval+15,4),'linear','SamplePoints',DELTAdata(startval:startval+15,3));
[desens,~] = fillmissing(DELTAdata(startval:startval+15,10),'linear','SamplePoints',DELTAdata(startval:startval+15,9));
deltabg(mm,1) = trapz(DELTAdata(startval:startval+15,3),debg);
deltasens(mm,1) = trapz(DELTAdata(startval:startval+15,9),desens);
mm = mm + 1;
end
The above code should do the interpolation for all the patients in all four trials. Open the AUC MATLAB.xlsx file and your results should be in the alphabg, alphasens, betabg, betasens, gammabg, gammasense, deltabg, and deltasens variables. Upon further inspection of your Excel code, I did notice an error. This comes up when you have a blank spot in your y data which is denoted by a red cell. The code above linearly interpolates the values that do not exist in your spreadsheet. If you do not do that, then it will give you the wrong value. It looks like the exercise data is correct, but I did not verify that. I'll also attach a "fixed" version of your Excel workbook. The results from this should be the same as the MATLAB script. I took out your trapezoidal integration when there were no readings so it should be correct now.
Olivia McCarthy
Olivia McCarthy on 3 Jan 2020
Honestly, I can't thank you enough for helping me with this. It's greatly appreciated. I'll follow your instructions now in MATLAB.
Thanks again
Olivia

Sign in to comment.

Categories

Find more on Variables in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!