Code covered by the BSD License  

Highlights from
Using SimBiology for Mechanism-Based PK/PD Modeling in Preclinical & Discovery

image thumbnail

Using SimBiology for Mechanism-Based PK/PD Modeling in Preclinical & Discovery

by

 

Examples used in the March 2012 webinar: Using SimBiology for Mechanism-Based PK/PD Modeling

antibioticDoseResponseGUI.m
function antibioticDoseResponseGUI
%% This GUI application allows the user to simulate an integrated PKPD model
% for antibacterial drugs to generate the in vivo dose response behavior.
% The antibacterial PK/PD model use in this application is based on the
% reference below:
%
% *Reference*:  Nielsen E.I., Cars O. and Friberg, L.E. _Pharmacokinetic
% /Pharmacodynamic (PK/PD) Indices of Antibiotics Predicted by a
% Semimechanistic PKPD Model: a Step toward Model-Based Dose Optimization.
% (2011) Antimicrobial Agents and Chemotherapy_ , 55(10). p. 46194630

% Copyright 2011 - 2012 MathWorks, Inc.

clc; close all

%% Create GUI figure
f = figure( 'units'     , 'normalized'       , ...
            'position'  , [0.2 0.2 .75 .7]   , ...
            'color'     , [0.95 0.95 0.95]   , ...
            'MenuBar'   , 'none'             , ...
            'ToolBar'   , 'none'             , ...
            'name'      , 'Antibiotic Dose Response GUI',...
            'numbertitle', 'off'              )  ;

%% Add simulate & fit buttons
% Add Simulate Dose Response pushbutton
uicontrol(  'style'             , 'pushbutton'                  , ...
            'parent'            , f                             , ...
            'tag'               , 'pushbutton_simulate'         , ...
            'units'             , 'normalized'                  , ...
            'position'          , [0.05 0.18 0.225 0.075]       , ...
            'backgroundcolor'   , [1 1 1]                       , ...
            'string'            , 'Simulate Dose Response'      , ...
            'fontname'          , 'calibri'                     , ...
            'fontsize'          , 12                            , ...
            'horizontalalignment', 'left'                       , ...
            'callback'          , @simulateDoseResponse         ) ;

% Add Fit Dose Response pushbutton
uicontrol(  'style'         , 'pushbutton'              ,...
            'parent'        ,  f                        ,...
            'tag'           , 'pushbutton_fitCurve'     ,...
            'units'         , 'normalized'              ,...
            'position'      , [0.05 0.1 0.225 0.075]    ,...
            'backgroundcolor', [1 1 1]                  ,...
            'string'        , {'Fit Dose Response'}     ,...
            'callback'      , @fitCurves                ,...
            'fontname'      , 'calibri'                 ,...
            'fontsize'      , 12                        ,...
            'enable'        , 'off'                     ) ;

%% Add drug selection options
% static text 
uicontrol(  'style'         , 'text'                , ...
            'parent'        , f                     , ...
            'tag'           , 'text_DrugName'       , ...
            'units'         , 'normalized'          , ...
            'position'      , [0.05 0.85 0.25 0.075], ...
            'backgroundcolor', [0.95 0.95 0.95]     , ...
            'string'        , 'Drug:'               , ...
            'fontname'      , 'calibri'             , ...
            'fontsize'      , 12                    , ...
            'horizontalalignment', 'left'           ) ;

% pulldown
uicontrol(  'style'         , 'popupmenu'                   , ...
            'parent'        , f                             , ...
            'tag'           , 'pulldown_DrugName'           , ...
            'units'         , 'normalized'                  , ...
            'position'      , [0.115 0.859 0.15 0.075]      , ...
            'backgroundcolor', [1 1 1]                      , ...
            'string'        , {'Drug 1'; 'Drug 2'} , ...
            'callback'      , @selectDrug                   , ...
            'fontname'      , 'calibri'                     , ...
            'fontsize'      , 12 ) ;

%% Add strain selection options
% panel 
h1(1) = uipanel('parent'        , f                             , ...
                'tag'           , 'panel_strain'                , ...
                'units'         , 'normalized'                  , ...
                'position'      , [0.05 0.575 0.225 0.285]      , ...
                'backgroundcolor', [0.95 0.95 0.95]             , ...
                'title'         , 'Bacterial Strain'            , ...
                'fontweight'    , 'bold'                        ) ;

% text: Strain
h1(2) = uicontrol('style'       , 'text'                    , ...
                'parent'        , h1(1)                     , ...
                'tag'           , 'text_StrainName'         , ...
                'units'         , 'normalized'              , ...
                'position'      , [0.1 0.75 0.25 0.2]       , ...
                'backgroundcolor', [0.95 0.95 0.95]         , ...
                'string'        , 'Strain:'                 , ...
                'horizontalalignment', 'left'               ) ;

% pulldown: Select Strain
h1(3) = uicontrol('style'       , 'popupmenu'               , ...
                'parent'        , h1(1)                     , ...
                'tag'           , 'pulldown_StrainName'     , ...
                'units'         , 'normalized'              ,...
                'position'      , [0.45 0.775 0.45 0.2]     ,...
                'backgroundcolor', [1 1 1]                  ,...
                'string'        , {'Strain 1'; 'Strain 2'; 'Unknown'}, ...
                'callback'      , @selectStrain             ) ;

% text: kgrowth
h1(4)=  uicontrol('style'       , 'text'                    , ...
                'parent'        , h1(1)                     , ...
                'tag'           , 'text_kgrowth'            , ...
                'units'         , 'normalized'              , ...
                'position'      , [0.1 0.525 0.35 0.2]      , ...
                'backgroundcolor', [0.95 0.95 0.95]         , ...
                'string'        , 'kgrowth:'                , ...
                'horizontalalignment', 'left'               ) ;

% edit: kgrowth
h1(5) = uicontrol('style'       , 'edit'                    , ...
                'parent'        , h1(1)                     , ...
                'tag'           , 'edit_kgrowth'            , ...
                'units'         , 'normalized'              ,...
                'position'      , [0.45 0.55 0.45 0.2]      ,...
                'backgroundcolor', [1 1 1]                  ,......
                'callback'      , @editStrain               ) ;

% edit: kdeath            
h1(6)=  uicontrol('style'       , 'text'                    , ...
                'parent'        , h1(1)                     , ...
                'tag'           , 'text_kdeath'             , ...
                'units'         , 'normalized'              , ...
                'position'      , [0.1 0.285 0.35 0.2]      , ...
                'backgroundcolor', [0.95 0.95 0.95]         , ...
                'string'        , 'kdeath:'                 , ...
                'horizontalalignment', 'left'               ) ;

% edit: kdeath
h1(7) = uicontrol('style'       , 'edit'                , ...
                'parent'        , h1(1)                 , ...
                'tag'           , 'edit_kdeath'         , ...
                'units'         , 'normalized'          ,...
                'position'      , [0.45 0.3 0.45 0.2]   ,...
                'backgroundcolor', [1 1 1]              ,...
                'callback'      , @editStrain            ) ;

% text: Bmax
h1(8)=  uicontrol('style'       , 'text'                    , ...
                'parent'        , h1(1)                     , ...
                'tag'           , 'text_Bmax'               ,...
                'units'         , 'normalized'              ,...
                'position'      , [0.1 0.025 0.35 0.2]      , ...
                'backgroundcolor', [0.95 0.95 0.95]         ,...
                'string'        , 'Bmax:'                   ,...
                'horizontalalignment', 'left'               ) ;

% edit: Bmax
h1(9) = uicontrol('style'       , 'edit'                    , ...
                'parent'        , h1(1)                     , ...
                'tag'           , 'edit_Bmax'               , ...
                'units'         , 'normalized'              , ...
                'position'      , [0.45 0.05 0.45 0.2]      , ...
                'backgroundcolor', [1 1 1]                  , ...               
                'callback'      , @editStrain               ) ;

set(h1(2:end), 'fontsize', 11, 'fontname', 'calibri')

%% Add PKPD paramters setting panel
% panel
h2(1) = uipanel('parent'        , f                             , ...
                'tag'           , 'panel_strain'                ,...
                'units'         , 'normalized'                  ,...
                'position'      , [0.05 0.275 0.225 0.285]      ,...
                'backgroundcolor', [0.95 0.95 0.95]             ,...
                'title'         , 'Drug/Strain Parameters'      , ...
                'fontweight'    , 'bold'                        ) ;

% text: Emax            
h2(2)=  uicontrol('style'       , 'text'                    , ...
                'parent'        , h2(1)                     , ...
                'tag'           , 'text_Emax'               , ...
                'units'         , 'normalized'              , ...
                'position'      , [0.1 0.455 0.35 0.2]      , ...
                'backgroundcolor', [0.95 0.95 0.95]         , ...
                'string'        , 'Emax:'                   , ...
                'horizontalalignment', 'left'               ) ;
% edit: Emax  
h2(3) = uicontrol('style'       , 'edit'                    , ...
                'parent'        , h2(1)                     , ...
                'tag'           , 'edit_Emax'               , ...
                'units'         , 'normalized'              , ...
                'position'      , [0.45 0.5 0.45 0.2]       , ...
                'backgroundcolor', [1 1 1]                  , ...
                'callback'      , @editPKPD                  ) ;
% text: gamma
h2(4)=  uicontrol('style'       , 'text'                    , ...
                'parent'        , h2(1)                     , ...
                'tag'           , 'text_Gamma'              , ...
                'units'         , 'normalized'              , ...
                'position'      , [0.1 0.225 0.35 0.2]      , ...
                'backgroundcolor', [0.95 0.95 0.95]         , ...
                'string'        , 'Gamma:'                  , ...
                'horizontalalignment', 'left'               ) ;
%edit:gamma
h2(5) = uicontrol('style'       , 'edit'                    , ...
                'parent'        , h2(1)                     , ...
                'tag'           , 'edit_Gamma'              , ...
                'units'         , 'normalized'              , ...
                'position'      , [0.45 0.275 0.45 0.2]     , ...
                'backgroundcolor', [1 1 1]                  , ...
                'callback'      , @editPKPD                  ) ;

% text: EC50
h2(6)=  uicontrol('style'       , 'text'                    , ...
                'parent'        , h2(1)                     , ...
                'tag'           , 'text_EC50'               , ...
                'units'         , 'normalized'              , ...
                'position'      , [0.1 0.001 0.35 0.2]      , ...
                'backgroundcolor', [0.95 0.95 0.95]         , ...
                'string'        , 'EC50:'                   , ...
                'horizontalalignment', 'left'               ) ;

% edit: EC50
h2(7) = uicontrol('style'       , 'edit'                    , ...
                'parent'        , h2(1)                     , ...
                'tag'           , 'edit_EC50'               , ...
                'units'         , 'normalized'              , ...
                'position'      , [0.45 0.055 0.45 0.2]     , ...
                'backgroundcolor', [1 1 1]                  , ...
                'callback'      , @editPKPD                 ) ;

% text: MIC
h2(8)=  uicontrol('style'       , 'text'                    , ...
                'parent'        , h2(1)                     , ...
                'tag'           , 'text_mic'                , ...
                'units'         , 'normalized'              , ...
                'position'      , [0.1 0.7 0.35 0.2]        , ...
                'backgroundcolor', [0.95 0.95 0.95]         , ...
                'string'        , 'MIC:'                    , ...
                'horizontalalignment', 'left'               ) ;
% edit:MIC
h2(9) = uicontrol('style'       , 'edit'                    , ...
                'parent'        , h2(1)                     , ...
                'tag'           , 'edit_mic'                , ...
                'units'         , 'normalized'              , ...
                'position'      , [0.45 0.725 0.45 0.2]     , ...
                'backgroundcolor', [1 1 1]                  , ...             
                'callback'      , @editPKPD                  ) ;

set(h2(2:end), 'fontsize', 12, 'fontname', 'calibri')

%% Add save and compare results buttong
% button: save results
h4(1) = uicontrol( 'parent'     , f                             ,...
                'style'         , 'pushbutton'                  ,...
                'tag'           , 'button_saveResults'          ,...
                'units'         , 'normalized'                  ,...
                'position'      , [0.7 0.185 0.25 0.075]        ,...
                'string'        , 'Save results'                ,...
                'callback'      , @saveResults                  ) ;
            
% button: compare results
h4(2) = uicontrol(  'parent'        , f                             ,...
                    'style'         , 'pushbutton'                  ,...
                    'tag'           , 'button_compareResults'       ,...
                    'units'         , 'normalized'                  ,...
                    'position'      , [0.7 0.1 0.25 0.075]          ,...
                    'string'        , 'Compare Drugs'               ,...
                    'callback'      , @compareResults               ) ;

set(h4, 'fontsize', 12, 'fontweight', 'bold','fontname', 'calibri', 'backgroundcolor', [0.95 0.95 0.95])

%% Add plot selection panel
h5(1) = uibuttongroup(  'parent'        , f                         ,...
                        'tag'           , 'panel_selectPlots'       ,...
                        'units'         , 'normalized'              ,...
                        'position'      , [0.365 0.1 0.3 0.175]     ,...
                        'title'         , 'Select Plots'            ,...
                        'fontweight'    , 'bold'                    ,...
                        'fontsize'      , 11                        ,...
                        'fontname'      , 'calibri'                 ,...
                        'SelectionChangeFcn', @selectPlot            ) ;

h5(2) =  uicontrol('style'          , 'radio'                       , ...
                    'parent'        , h5(1)                         , ...
                    'tag'           , 'toggle_DoseRespPlot'         , ...
                    'units'         , 'normalized'                  , ...
                    'position'      , [0.05 0.5 0.9 0.35]           , ...
                    'string'        , 'Simulation Plots'            ) ;

h5(3) =  uicontrol('style'          , 'radio'                       ,...
                    'parent'        , h5(1)                         ,...
                    'tag'           , 'toggle_SimPLot'              ,...
                    'units'         , 'normalized'                  ,...
                    'position'      , [0.05 0.1 0.9 0.35]           , ...
                    'string'        , 'Dose Response Plots'         ) ;

set(h5, 'fontsize', 10, 'fontname', 'calibri', 'backgroundcolor', [0.95 0.95 0.95])

%% Add axes
axes('parent'   , f                         , ...
    'tag'       , 'axes_responsePlot'       , ...
    'units'     , 'normalized'              , ...
    'position'  , [0.365 0.375 0.6 0.55]    , ...
    'color'     , [1 1 1]               	, ...
    'box',       'on'                       , ...
    'visible',  'off'                       ); 

axes('parent'   , f                         ,...
    'tag'       , 'axes_DrugPlot'           , ...
    'units'     , 'normalized'              , ...
    'position'  , [0.365 0.4 0.6 0.25]      , ...
    'color'     , [1 1 1]                   , ...
    'box'       ,  'on'                     , ...
    'visible'   ,  'on'                     , ...
    'xlim'      ,  [0 25]                   , ...
    'xtick'     ,  0:4:24                   );

axes('parent'   , f                         ,...
    'tag'       , 'axes_CFUPlot'            , ...
    'units'     , 'normalized'              ,...
    'position'  , [0.365 0.7 0.6 0.25]      , ...
    'color'     , [1 1 1]                   , ...
    'box'       ,   'on'                    , ...
    'visible'   ,   'on'                    , ...
    'xlim'      ,     [0 25]                , ...
    'xtick'     ,    0:4:24                 , ...
    'xticklabel', ''                        );

%% Initialize GUI

% Create & updates handles
handles = guihandles(f) ;
guidata(f, handles)

% Load SimBiology model
sbioloadproject('Integrated_Antibacterial_PKPD_model.sbproj')

% Initialize properties
handles.model       = m1                  ; % simbiology model
handles.drug        = 'Drug 1'            ; % selected drug
handles.strain      = 'Strain 1'          ; % selected drug
handles.fitInfo     = []                  ; % fit information is empty
handles.pkprofile   = {} ;
handles.results     = [] ;
handles.parameters  = dataset('xlsfile', 'DrugStrainParameters.xlsx') ;
handles.selectPlot  = 'Simulation Plots';

handles.parameters.Drug = nominal(handles.parameters.Drug);
handles.parameters.Strain = nominal(handles.parameters.Strain);

% set axes labels
ylabel(handles.axes_responsePlot, 'log10CFU @ 24 hour', 'FontName', 'Calibri', 'FontSize', 12);
xlabel(handles.axes_responsePlot, 'Dose', 'FontName', 'Calibri', 'FontSize', 12);

% set axes labels
xlabel(handles.axes_DrugPlot, 'Time (hour)' , 'FontName', 'Calibri', 'FontSize', 12);
ylabel(handles.axes_DrugPlot, 'Drug (mg/ml)', 'FontName', 'Calibri', 'FontSize', 12);

% set axes labels
ylabel(handles.axes_CFUPlot, 'log10(CFU/ml)', 'FontName', 'Calibri', 'FontSize', 12);

%% Set values based on selected strain 

v1 = sbioselect(handles.model, 'type', 'variant', 'Name', 'Strain 1') ;
v2 = sbioselect(handles.model, 'type', 'variant', 'Name', 'Drug 1') ;

vStrain = sbioselect(handles.model, 'type', 'variant', 'Name', 'Strain') ;
vDrug = sbioselect(handles.model, 'type', 'variant', 'Name', 'Drug') ;

set(vStrain, 'Content', v1.Content ) ;
set(vDrug, 'Content', v2.Content   ) ;

ds = handles.parameters;
% Set value of the MIC based on drug selected
handles.mic     = ds.MIC(ds.Drug == handles.drug & ds.Strain == handles.strain);
handles.kdeath  = ds.kdeath(ds.Drug == handles.drug & ds.Strain == handles.strain);
handles.kgrowth = ds.kgrowth(ds.Drug == handles.drug & ds.Strain == handles.strain);
handles.Bmax    = ds.Bmax(ds.Drug == handles.drug & ds.Strain == handles.strain);
handles.EC50    = ds.EC50(ds.Drug == handles.drug & ds.Strain == handles.strain);
handles.Emax    = ds.Emax(ds.Drug == handles.drug & ds.Strain == handles.strain);
handles.Gamma   = ds.Gamma(ds.Drug == handles.drug & ds.Strain == handles.strain);

% Reflect value in the GUI
set(handles.edit_mic    , 'String', handles.mic)
set(handles.edit_kdeath , 'String', handles.kdeath)
set(handles.edit_kgrowth, 'String', handles.kgrowth)
set(handles.edit_Bmax   , 'String', handles.Bmax)
set(handles.edit_EC50   , 'String', handles.EC50)
set(handles.edit_Emax   , 'String', handles.Emax)
set(handles.edit_Gamma  , 'String', handles.Gamma)

guidata(f, handles)

end

%% Callbacks
function selectDrug(hObject, ~)
% hObject    handle to popup_selectDrug (see GCBO)

% Get guidata
handles = guidata(hObject) ;

% Get name of selected drug
drugs = cellstr(get(hObject,'String')) ;
handles.drug = drugs{get(hObject,'Value')} ;

% Set value of the MIC based on drug selected
switch handles.drug
    case 'Drug 1'
        ka = 0.5 ;
        CL = 2.37;
        Vc = 1.29 ;
    case 'Drug 2',
        %         handles.mic = 0.016 ;
        ka = 0.266 ;
        CL = 0.346 ;
        Vc = 0.129 ;
end

ds = handles.parameters;
handles.mic     = ds.MIC(ds.Drug == handles.drug & ds.Strain == handles.strain);
handles.EC50    = ds.EC50(ds.Drug == handles.drug & ds.Strain == handles.strain);
handles.Emax    = ds.Emax(ds.Drug == handles.drug & ds.Strain == handles.strain);
handles.Gamma   = ds.Gamma(ds.Drug == handles.drug & ds.Strain == handles.strain);

var = sbioselect(handles.model, 'type', 'variant', 'Name', 'Drug') ;

set(var, 'Content', {{'parameter'  , 'Cl'       , 'Value'    , CL}
    {'parameter'  , 'ka'       , 'Value'    , ka}
    {'compartment', 'Central'  , 'Capacity' , Vc}}) ;

var2 = sbioselect(handles.model, 'type', 'variant', 'Name', 'PKPD') ;

set(var2, 'Content', {{'parameter' , 'EC50'  , 'Value' , handles.EC50}
    {'parameter'  , 'Emax' , 'Value' , handles.Emax}
    {'parameter'  , 'g'    , 'Value' , handles.Gamma}
    {'parameter'  , 'MIC'    , 'Value' , handles.mic}}) ;

% Reflect value in the GUI
set(handles.edit_mic, 'String', handles.mic)
set(handles.edit_EC50, 'String', handles.EC50)
set(handles.edit_Emax, 'String', handles.Emax)
set(handles.edit_Gamma, 'String', handles.Gamma)


% Reset GUI
handles = resetGUI(handles) ;

% set guidata
guidata(hObject, handles)

end

function selectStrain(hObject, ~)
% hObject    handle to popup_selectDrug (see GCBO)

% Get guidata
handles = guidata(hObject) ;

% Get name of selected drug
strains = cellstr(get(hObject,'String')) ;
handles.strain = strains{get(hObject,'Value')} ;

ds = handles.parameters;
% Set value of the MIC based on drug selected
if ds.Strain ~= 'Unknown'
    handles.mic     = ds.MIC(ds.Drug == handles.drug & ds.Strain == handles.strain);
    handles.kdeath  = ds.kdeath(ds.Drug == handles.drug & ds.Strain == handles.strain);
    handles.kgrowth = ds.kgrowth(ds.Drug == handles.drug & ds.Strain == handles.strain);
    handles.Bmax    = ds.Bmax(ds.Drug == handles.drug & ds.Strain == handles.strain);
    handles.EC50    = ds.EC50(ds.Drug == handles.drug & ds.Strain == handles.strain);
    handles.Emax    = ds.Emax(ds.Drug == handles.drug & ds.Strain == handles.strain);
    handles.Gamma   = ds.Gamma(ds.Drug == handles.drug & ds.Strain == handles.strain);
    
else
    handles.mic     = '---';
    handles.kdeath  = '---';
    handles.kgrowth = '---';
    handles.Bmax    = '---';
    handles.EC50    = '---';
    handles.Emax    = '---';
    handles.Gamma   = '---';
    
end


% Get Parameter Values
var = sbioselect(handles.model, 'type', 'variant', 'Name', 'Strain') ;

set(var, 'Content', {{'parameter' , 'kdeath'  , 'Value' , handles.kdeath}
    {'parameter'  , 'kgrowth' , 'Value' , handles.kgrowth}
    {'parameter'  , 'Bmax'    , 'Value' , handles.Bmax}}) ;

% Get PKPD parameters
var2 = sbioselect(handles.model, 'type', 'variant', 'Name', 'PKPD') ;

set(var2, 'Content', {{'parameter' , 'EC50'  , 'Value' , handles.EC50}
    {'parameter'  , 'Emax' , 'Value' , handles.Emax}
    {'parameter'  , 'g'    , 'Value' , handles.Gamma}
    {'parameter'  , 'MIC'    , 'Value' , handles.mic}}) ;

% Reflect value in the GUI
set(handles.edit_mic, 'String', handles.mic)
set(handles.edit_kdeath, 'String', handles.kdeath)
set(handles.edit_kgrowth, 'String', handles.kgrowth)
set(handles.edit_Bmax, 'String', handles.Bmax)
set(handles.edit_EC50, 'String', handles.EC50)
set(handles.edit_Emax, 'String', handles.Emax)
set(handles.edit_Gamma, 'String', handles.Gamma)

% Reset GUI
handles = resetGUI(handles) ;

% set guidata
guidata(hObject, handles)

end

function handles = resetGUI(handles)

% Clear axes
cla(handles.axes_responsePlot)
cla(handles.axes_DrugPlot)
cla(handles.axes_CFUPlot)
legend(handles.axes_responsePlot, 'off')
title('')

% Clear results
handles.fitInfo = [] ;
handles.results = [] ;

% Clear table
set(handles.pushbutton_fitCurve, 'enable', 'off')

end

function simulateDoseResponse(hObject, ~)

handles = guidata(hObject) ;
handles.results = doseResponse(handles.model, 'Drug', 'Strain', 'PKPD',  handles.mic) ;

% Plot simulation data 
hold([handles.axes_CFUPlot], 'all')
hold([handles.axes_DrugPlot], 'all')
hp(:, 1) = plot(handles.axes_DrugPlot, handles.results.Time, log10(handles.results.drug), 'LineWidth', 1)   ;
hp(:, 2) = plot(handles.axes_CFUPlot, handles.results.Time, handles.results.log10CFU, 'LineWidth', 1)       ;

handles.selectPlot =  get(get(handles.panel_selectPlots, 'selectedObject'), 'string');

% hide plots if plot selection is Dose Response plot
if strcmp(handles.selectPlot, 'Dose Response Plots' )
        plotResponseCurves(handles.axes_responsePlot, handles.results, handles.fitInfo );
        set(hp, 'Visible', 'off')
end

set(handles.pushbutton_fitCurve, 'enable', 'on')
guidata(hObject, handles)

end

function fitCurves(hObject, ~)

% Get handles
handles = guidata(hObject) ;

% Fit dose vs. response data
fitInfo = fitDose(handles.results.Dose, handles.results.log10CFU_at_24hr) ;
fitInfo.bstat = fitInfo.bstat ;
fitInfo.bcid  = fitInfo.bcid  ;

% update fitInfo on handles
handles.fitInfo = fitInfo;

% Plot results
plotResponseCurves(handles.axes_responsePlot, handles.results, handles.fitInfo)
guidata(hObject, handles)

end

function editStrain(hObject, ~)

% get guidata
handles = guidata(hObject) ;

% set parameter values based on inputs
handles.kdeath  = str2double(get(handles.edit_kdeath , 'String')) ;
handles.kgrowth = str2double(get(handles.edit_kgrowth, 'String')) ;
handles.Bmax    = str2double(get(handles.edit_Bmax   , 'String')) ;

%  set values on strain variant
var = sbioselect(handles.model, 'type', 'variant', 'Name', 'Strain') ;

set(var, 'Content', {{'parameter' , 'kdeath'  , 'Value' , handles.kdeath }
                    {'parameter'  , 'kgrowth' , 'Value' , handles.kgrowth}
                    {'parameter'  , 'Bmax'    , 'Value' , handles.Bmax   }}) ;

% reset GUI
handles = resetGUI(handles) ;

% updata guidata
guidata(hObject, handles)

end

function editPKPD(hObject, ~)

% get guidata
handles = guidata(hObject) ;

handles.Emax    = str2double(get(handles.edit_Emax, 'String'))  ;
handles.EC50    = str2double(get(handles.edit_EC50, 'String'))  ;
handles.Gamma   = str2double(get(handles.edit_Gamma, 'String')) ;
handles.mic     = str2double(get(handles.edit_mic  , 'String')) ; 

% set values of PKPD variant 
var = sbioselect(handles.model, 'type', 'variant', 'Name', 'PKPD') ;

set(var, 'Content', {{'parameter' , 'EC50'  , 'Value' , handles.EC50}
                    {'parameter'  , 'Emax' , 'Value' , handles.Emax}
                    {'parameter'  , 'g'    , 'Value' , handles.Gamma}}) ;
                
% Reset GUI
handles = resetGUI(handles) ;

% updata guidata
guidata(hObject, handles)


end

function selectPlot(hObject, ~)

% get guidata
handles = guidata(hObject) ;

% get plot selection
handles.selectPlot =  get(get(hObject, 'SelectedObject'), 'string') ;

switch handles.selectPlot
    case 'Simulation Plots'
        % make DrugPlot and CFUPLot axes and plots visibile 
        set(handles.axes_DrugPlot                   , 'visible', 'on') ;
        set(handles.axes_CFUPlot                    , 'visible', 'on') ;
        set(get(handles.axes_CFUPlot , 'Children')  , 'visible', 'on')
        set(get(handles.axes_DrugPlot, 'Children')  , 'visible', 'on')
        
        % hide reponsePlot axes and plots  
        set(handles.axes_responsePlot                   , 'visible', 'off') ;        
        set(get(handles.axes_responsePlot, 'Children')  , 'visible', 'off') ;
        
    case 'Dose Response Plots'
         % hide DrugPlot and CFUPLot axes and plots  
        set(handles.axes_DrugPlot                   , 'visible', 'off') ;
        set(handles.axes_CFUPlot                    , 'visible', 'off') ;
        set(get(handles.axes_CFUPlot, 'Children')   , 'visible', 'off') ;
        set(get(handles.axes_DrugPlot, 'Children')  , 'visible', 'off') ;
        
        % make reponsePlot axes and plots visible
        set(handles.axes_responsePlot                   , 'visible', 'on') ;
        set(get(handles.axes_responsePlot , 'Children') , 'visible', 'on') ;
        
        % Change label on axes
        xlabel(handles.axes_responsePlot, 'Dose' , 'FontName', 'Calibri', 'FontSize', 12);
        plotResponseCurves(handles.axes_responsePlot, handles.results, handles.fitInfo )
        
end

% update guidata
guidata(hObject, handles) ;

end

function saveResults(hObject, ~)

handles = guidata(hObject) ;

tag = [handles.drug, '/' ,handles.strain] ;
results = handles.results' ;
uisave({'results', 'tag'})

guidata(hObject, handles)
end

function compareResults(hObject, ~)

handles = guidata(hObject) ;
fname = uigetfile('.mat', 'Select Result Files', 'multiselect', 'on') ;
nf = figure() ;
lgnd = {} ;
for i = 1:length(fname)
    load(fname{i})
    lgnd =[lgnd,  tag] ;
    doseResponsePlot(results.Dose, results.log10CFU_at_24hr)

end
legend(lgnd); box off
guidata(hObject, handles)
end

Contact us