Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Autosave files
*.asv
*.m~
*.autosave
*.slx.r*
*.mdl.r*

# Derived content-obscured files
*.p

# Compiled MEX files
*.mex*

# Packaged app and toolbox files
*.mlappinstall
*.mltbx

# Deployable archives
*.ctf

# Generated helpsearch folders
helpsearch*/

# Code generation folders
slprj/
sccprj/
codegen/

# Cache files
*.slxc

# Cloud based storage dotfile
.MATLABDriveTag

# buildtool cache folder
.buildtool/

Binary file modified Lib/Libs_second.slx
Binary file not shown.
Binary file added Lib/Libs_unified.slx
Binary file not shown.
Binary file modified N3Cfg.mat
Binary file not shown.
Binary file added N3Cfg_second.mat
Binary file not shown.
Binary file modified N3Data.mat
Binary file not shown.
Binary file added N3Data_second.mat
Binary file not shown.
File renamed without changes.
Binary file added heartoutline.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified models/CLSfixed.slx
Binary file not shown.
Binary file added models/CLSfixed_nopace.slx
Binary file not shown.
Binary file added models/CLSfixed_pace.slx
Binary file not shown.
Binary file added models/HeartCFGs.slx
Binary file not shown.
Binary file added models/HeartV11.slx
Binary file not shown.
125 changes: 104 additions & 21 deletions models/RunCLSfixed.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,118 @@
% See the License for the specific language governing permissions and
% limitations under the License.
%%
clear;
clear all;
%bdclose('all');
path_var=pwd;
if ~contains('models',path_var)
path_var = [path_var, filesep 'models'];
end
warning('off','all')
% Opening Main GUI which determines whether to edit model network
% structure, parameters, and add pacemaker
global outputs
outputs = main_settings();
Heart_GUI_preset(outputs);
%Millisecond: parasNormal, Multi[2,3,_Bradycardia]
%Second: parasMulti[_second,_AV_block]
if outputs.units == 2
switch outputs.param
case 'Normal' %1
updatePara='parasMulti_second.mat';
case 'AV Block' %2
updatePara='parasMulti_AV_block.mat';
otherwise
updatePara='parasMulti_second.mat';
end
else
switch outputs.param
case 'Normal' %1
updatePara='parasNormal.mat';
case 'parasMulti' %2
updatePara='parasMulti.mat';
case 'parasMulti2' %3
updatePara='parasMulti2.mat';
case 'parasMulti3' %4
updatePara='parasMulti3.mat';
case 'Bradycardia' %5
updatePara = 'parasMulti_Bradycardia.mat';
otherwise
updatePara='parasNormal.mat';
end
end
assignin('base','sens_units',outputs.units) % Sensing charts Chart (unit) subsystem
%Prepare the parameters
if outputs.units == 2
filename='N3Cfg_second.mat';
datafile='N3Data_second.mat';
pathsheet='Path_second';
nodesheet='Node_second';
assignin('base','solvertime',5); % solving time for the GUI cells
assignin('base','stepsize',0.0005); % step size for solving the GUI cells and the CLS sample time
assignin('base','timescale','s'); % time scale for GUI plots
assignin('base','buffer',0.599); % for Libs_unified/Path_V3/Path Buffer_i and Buffer_j
assignin('base','unit_conversion',1); % used with the N node ms/s setting in RR
assignin('base','stoptime',2) % CLSfixed initial stop time
elseif outputs.units == 1
filename='N3Cfg.mat';
datafile='N3Data.mat';
pathsheet='Path';
nodesheet='Node';
assignin('base','solvertime',5000);
assignin('base','stepsize',0.1);
assignin('base','timescale','ms');
assignin('base','buffer',599);
assignin('base','unit_conversion',1000);
assignin('base','stoptime',2000)
end

% Extract the node classification data from the xlsx file
[~,~,nodes_raw]=xlsread('Heart_N3_second.xlsx',nodesheet);
[~,~,path_raw]=xlsread('Heart_N3_second.xlsx',pathsheet);
[~,~,probes_raw]=xlsread('Heart_N3_second.xlsx','Probe');
% Edit the network model
if outputs.editmodel
global node_atts
global node_atts_copy
global path_atts
global path_atts_copy
global params
global nodes_name %potentially join the nodes_name into the front of node_atts
global probes_name
temp = nodes_raw(:,2:end);
temp(:,end-2) = [];
temp(end,:) = [];
assignin('base','node_atts',temp);
assignin('base','node_atts_copy',temp);
assignin('base','path_atts',path_raw);
assignin('base','path_atts_copy',path_raw);

temp1 = nodes_raw(:,1:2);
temp1(end,:) = [];
assignin('base','nodes_name',temp1);
temp2 = probes_raw(2:end,1:5);
assignin('base','probes_name',temp2);
Heart_Editing_GUI(filename,nodes_name,probes_name,params,node_atts,node_atts_copy,path_atts,path_atts_copy,timescale,outputs.pacemaker);
end

% contains all configurations of heart model
filename='N3Cfg.mat';
% contains all parameters of heart model
datafile='N3Data.mat';
load(filename);
% contains all parameters of heart model
load(datafile);
path_var=pwd;
% Contains all the range of new parameters for run-time update
updatePara='parasMulti.mat';
% Load in the new parameter range
load(updatePara);
%% Parameter settings
% parasMulti:
% Bradycardia+AV block+premature ventricular complex (PVC), RBBB (slow velocity):
% % SA BCL=1400; the automaticity of Node 24 (RBB) enabled (para48=0); path 10 backward enabled (para7=1.0); Path 15 cv=0.04, path 27 cv=0.4;
% parasMulti2: PVC introduces PMT
% Bradycardia+AV block+premature ventricular complex (PVC), RBBB (complete blockage, i.e.,cv=0):
% % SA BCL=1400; the automaticity of Node 24 (RBB) enabled (para48=0); path 10 backward enabled (para7=1.0); Path 15 cv=0.04, path 27 cv=0;
% parasMulti3: extra VP introduces AVNRT
% % SA BCL=814; CS BCL=1194 enabled (para48=0); path 10 backward enabled (para7=0.8); ppR5
% cfg=[814,1194,2,0,0.100000000000000,0.250000000000000,278,0.0146200000000000,0.00872000000000000,2300,2,1,0.100000000000000,0.250000000000000,1.100000000000000,0.0700000000000000,0.0700000000000000,0.0700000000000000,0.0700000000000000];
%%parasNormal Normal but slight AV delay compared to device AVI.
%% Run the GUI
% Global parameters
assignin('base','paras_length',length(pp))
assignin('base','cfg_length',length(cfgdata))
assignin('base','pNode_length',length(pNode))
assignin('base','pPath_length',length(pPath))
models={'CLSfixed', 'CLSfixed_pace', 'CLSfixed_nopace'};
% Specify the model name
modelName='CLSfixed';
modelName = models{outputs.pacemaker};
% Specify the model path
mdl=[path_var,filesep, modelName];
% Specify the data save path
savepath=[path_var,filesep 'Cells.mat'];

% In the model, there should be a S-function to save data to the same structure of the GUI.
Heart_GUI(mdl,modelName,filename,savepath);
Heart_GUI(mdl,modelName,filename,savepath,nodes_raw,probes_raw);
Binary file modified models/SAcell.slx
Binary file not shown.
Loading