%% Compute NCA Parameters from Concentration-Time Data
% Load a synthetic data set that contains the drug concentration measurements of four individuals after an IV bolus dose.

load data1.mat

%
% Set the dose amounts to NaN at time points when no dose was administered.

data1.Dose(data1.Dose(:) == 0) = NaN;

%
% Display the data.

sbiotrellis(data1,'ID','Time','DrugConc','Marker','o','LineStyle','--');

%
% Categorize the data columns using an NCA options object.

opt = sbioncaoptions;
opt.groupColumnName         = 'ID';
opt.concentrationColumnName = 'DrugConc';
opt.timeColumnName          = 'Time';
opt.IVDoseColumnName        = 'Dose';

%
% Compute NCA parameters for each individual.

ncaparameters = sbionca(data1,opt);

%
% Display the first few columns of the table. Each row of ncaparameters table represents an individual (or group), and each column lists the corresponding NCA parameter value.

ncaparameters(:,1:15)

%
% You can also specify a custom time range to compute T_max and C_max within that time range, say from time = 0 to 20. You can do so by setting the C_max_ranges property as a cell array of two-element row vector.

opt.C_max_ranges    = {[5.5 20]};
ncaparameters2       = sbionca(data1,opt);

%
% The function reports the T_max and C_max values within the range by adding two new columns: T_max_5_5__20 and C_max_5_5__20. Note that in the names of these two columns, the last time point is preceded by two consecutive underscores (__).

ncaparameters2.T_max_5_5__20(:)
ncaparameters2.C_max_5_5__20(:)

%
% Similarly, you can specify a custom time range to compute the partial AUC value for each group.

opt.PartialAreas    = {[0 20]};
ncaparameters3      = sbionca(data1,opt);
ncaparameters3.AUC_0__20(:)

%
% You can also specify multiple time ranges for C_max_ranges and PartialAreas.

opt.C_max_ranges    = {[0 20],[0 10],[0 15]};
opt.PartialAreas    = {[0 12],[0 30]};
ncaparameters4      = sbionca(data1,opt);

% Copyright 2012 The MathWorks, Inc.