% The function read_param.m reads a file which contains the % parameter values characterizing the human cardiovascular model % and its execution. % % Note that if the parameters characterizing the model are modified, % then this file must be accordingly modified. % % Function argument % inputfileid - id of the file containing the parameter values % % Function output % th - 113x1 MATLAB vector containing the read-in parameter values % waveform - string of numerical values corresponding to the waveforms % to be viewed on-line % function [th,waveform] = read_param(inputfileid) % Pre-allocating all of the parameters. Cls = []; Cld = []; Ca = []; Cv = []; Crs = []; Crd = []; Cpa = []; Cpv = []; Qlo = []; Qao = []; Qvo = []; Qro = []; Qpao = []; Qpvo = []; Rl = []; Ra = []; Rv = []; Rr = []; Rpa = []; Rpv = []; Qtot = []; F = []; Qlmax = []; Qrmax = []; Ppa = []; Pa = []; Pv = []; Plmax = []; Prmax = []; Pms = []; Qfrs = []; againr = []; bgain = []; pgain = []; Pasp = []; Pratrsp = []; Tr = []; fcp = []; Sa = []; stdwr = []; stdwf = []; dgainp = []; dgains = []; againq = []; cgainr = []; cgainq = []; cgainfp = []; Sc = []; Qt = []; Pvs = []; Crds = []; Pas = []; Pvc = []; again = []; againc = []; cgainc = []; againfs = []; cgainfs = []; againfp = []; Qfr = []; Qds = []; Rair = []; Clu = []; Qluo = []; window = []; annotations = []; numerics = []; alpha = []; step = []; % Reading in each of the values of each of the above parameters % from the input file according to the prescribed format of the % file. line = fgetl(inputfileid); while (strcmp(line,'%%%END OF FILE%%%') == 0) if (isempty(findstr(line,'%')) == 1) if (isempty(line) == 1) ; elseif (isempty(findstr(line,':')) == 1) ; else index = findstr(line,':'); tstr = char(line(1:index-1)); count = 1; x = isspace(tstr(count)); mbintscalar(x) while (x) count=count+1; x = isspace(tstr(count)); mbintscalar(x); end; start = count; count = index-1; x = isspace(tstr(count)); mbintscalar(x) while (x) count=count-1; x = isspace(tstr(count)); mbintscalar(x); end finish = count; tstr = char(tstr(start:finish)); if (strcmp(tstr,'Cls') == 1) tmp = sscanf(line,'%s %f'); Cls = tmp(length(tmp)); elseif (strcmp(tstr,'Cld') == 1) tmp = sscanf(line,'%s %f'); Cld = tmp(length(tmp)); elseif (strcmp(tstr,'Ca') == 1) tmp = sscanf(line,'%s %f'); Ca = tmp(length(tmp)); elseif (strcmp(tstr,'Cv') == 1) tmp = sscanf(line,'%s %f'); Cv = tmp(length(tmp)); elseif (strcmp(tstr,'Crs') == 1) tmp = sscanf(line,'%s %f'); Crs = tmp(length(tmp)); elseif (strcmp(tstr,'Crd') == 1) tmp = sscanf(line,'%s %f'); Crd = tmp(length(tmp)); elseif (strcmp(tstr,'Cpa') == 1) tmp = sscanf(line,'%s %f'); Cpa = tmp(length(tmp)); elseif (strcmp(tstr,'Cpv') == 1) tmp = sscanf(line,'%s %f'); Cpv = tmp(length(tmp)); elseif (strcmp(tstr,'Qlo') == 1) tmp = sscanf(line,'%s %f'); Qlo = tmp(length(tmp)); elseif (strcmp(tstr,'Qao') == 1) tmp = sscanf(line,'%s %f'); Qao = tmp(length(tmp)); elseif (strcmp(tstr,'Qvo') == 1) tmp = sscanf(line,'%s %f'); Qvo = tmp(length(tmp)); elseif (strcmp(tstr,'Qro') == 1) tmp = sscanf(line,'%s %f'); Qro = tmp(length(tmp)); elseif (strcmp(tstr,'Qpao') == 1) tmp = sscanf(line,'%s %f'); Qpao = tmp(length(tmp)); elseif (strcmp(tstr,'Qpvo') == 1) tmp = sscanf(line,'%s %f'); Qpvo = tmp(length(tmp)); elseif (strcmp(tstr,'Rl') == 1) tmp = sscanf(line,'%s %f'); Rl = tmp(length(tmp)); elseif (strcmp(tstr,'Ra') == 1) tmp = sscanf(line,'%s %f'); Ra = tmp(length(tmp)); elseif (strcmp(tstr,'Rv') == 1) tmp = sscanf(line,'%s %f'); Rv = tmp(length(tmp)); elseif (strcmp(tstr,'Rr') == 1) tmp = sscanf(line,'%s %f'); Rr = tmp(length(tmp)); elseif (strcmp(tstr,'Rpa') == 1) tmp = sscanf(line,'%s %f'); Rpa = tmp(length(tmp)); elseif (strcmp(tstr,'Rpv') == 1) tmp = sscanf(line,'%s %f'); Rpv = tmp(length(tmp)); elseif (strcmp(tstr,'Qtot') == 1) tmp = sscanf(line,'%s %f'); Qtot = tmp(length(tmp)); elseif (strcmp(tstr,'F') == 1) tmp = sscanf(line,'%s %f'); F = tmp(length(tmp)); % elseif (strcmp(tstr,'Pth') == 1) % tmp = sscanf(line,'%s %f'); % Pth = tmp(length(tmp)); % elseif (strcmp(tstr,'Ppac') == 1) % tmp = sscanf(line,'%s %f'); % Ppac = tmp(length(tmp)); elseif (strcmp(tstr,'Qlmax') == 1) tmp = sscanf(line,'%s %f'); Qlmax = tmp(length(tmp)); elseif (strcmp(tstr,'Qrmax') == 1) tmp = sscanf(line,'%s %f'); Qrmax = tmp(length(tmp)); elseif (strcmp(tstr,'Ppa') == 1) tmp = sscanf(line,'%s %f'); Ppa = tmp(length(tmp)); elseif (strcmp(tstr,'Pa') == 1) tmp = sscanf(line,'%s %f'); Pa = tmp(length(tmp)); elseif (strcmp(tstr,'Pv') == 1) tmp = sscanf(line,'%s %f'); Pv = tmp(length(tmp)); elseif (strcmp(tstr,'Plmax') == 1) tmp = sscanf(line,'%s %f'); Plmax = tmp(length(tmp)); elseif (strcmp(tstr,'Prmax') == 1) tmp = sscanf(line,'%s %f'); Prmax = tmp(length(tmp)); elseif (strcmp(tstr,'Pms') == 1) tmp = sscanf(line,'%s %f'); Pms = tmp(length(tmp)); elseif (strcmp(tstr,'Qfrs') == 1) tmp = sscanf(line,'%s %f'); Qfrs = tmp(length(tmp)); elseif (strcmp(tstr,'againr') == 1) tmp = sscanf(line,'%s %f'); againr = tmp(length(tmp)); elseif (strcmp(tstr,'bgain') == 1) tmp = sscanf(line,'%s %f'); bgain = tmp(length(tmp)); elseif (strcmp(tstr,'pgain') == 1) tmp = sscanf(line,'%s %f'); pgain = tmp(length(tmp)); elseif (strcmp(tstr,'Pasp') == 1) tmp = sscanf(line,'%s %f'); Pasp = tmp(length(tmp)); elseif (strcmp(tstr,'Pratrsp') == 1) tmp = sscanf(line,'%s %f'); Pratrsp = tmp(length(tmp)); elseif (strcmp(tstr,'Tr') == 1) tmp = sscanf(line,'%s %f'); Tr = tmp(length(tmp)); elseif (strcmp(tstr,'fco') == 1) tmp = sscanf(line,'%s %f'); fco = tmp(length(tmp)); elseif (strcmp(tstr,'Sa') == 1) tmp = sscanf(line,'%s %f'); Sa = tmp(length(tmp)); elseif (strcmp(tstr,'stdwr') == 1) tmp = sscanf(line,'%s %f'); stdwr = tmp(length(tmp)); elseif (strcmp(tstr,'stdwf') == 1) tmp = sscanf(line,'%s %f'); stdwf = tmp(length(tmp)); elseif (strcmp(tstr,'dgainp') == 1) tmp = sscanf(line,'%s %f'); dgainp = tmp(length(tmp)); elseif (strcmp(tstr,'dgains') == 1) tmp = sscanf(line,'%s %f'); dgains = tmp(length(tmp)); elseif (strcmp(tstr,'againq') == 1) tmp = sscanf(line,'%s %f'); againq = tmp(length(tmp)); elseif (strcmp(tstr,'cgainr') == 1) tmp = sscanf(line,'%s %f'); cgainr = tmp(length(tmp)); elseif (strcmp(tstr,'cgainq') == 1) tmp = sscanf(line,'%s %f'); cgainq = tmp(length(tmp)); elseif (strcmp(tstr,'cgainfp') == 1) tmp = sscanf(line,'%s %f'); cgainfp = tmp(length(tmp)); elseif (strcmp(tstr,'Sc') == 1) tmp = sscanf(line,'%s %f'); Sc = tmp(length(tmp)); elseif (strcmp(tstr,'Qt') == 1) tmp = sscanf(line,'%s %f'); Qt = tmp(length(tmp)); elseif (strcmp(tstr,'Pvs') == 1) tmp = sscanf(line,'%s %f'); Pvs = tmp(length(tmp)); elseif (strcmp(tstr,'Crds') == 1) tmp = sscanf(line,'%s %f'); Crds = tmp(length(tmp)); elseif (strcmp(tstr,'Pas') == 1) tmp = sscanf(line,'%s %f'); Pas = tmp(length(tmp)); elseif (strcmp(tstr,'Pvc') == 1) tmp = sscanf(line,'%s %f'); Pvc = tmp(length(tmp)); elseif (strcmp(tstr,'again') == 1) tmp = sscanf(line,'%s %f'); again = tmp(length(tmp)); elseif (strcmp(tstr,'againc') == 1) tmp = sscanf(line,'%s %f'); againc = tmp(length(tmp)); elseif (strcmp(tstr,'cgainc') == 1) tmp = sscanf(line,'%s %f'); cgainc = tmp(length(tmp)); elseif (strcmp(tstr,'againfs') == 1) tmp = sscanf(line,'%s %f'); againfs = tmp(length(tmp)); elseif (strcmp(tstr,'cgainfs') == 1) tmp = sscanf(line,'%s %f'); cgainfs = tmp(length(tmp)); elseif (strcmp(tstr,'againfp') == 1) tmp = sscanf(line,'%s %f'); againfp = tmp(length(tmp)); elseif (strcmp(tstr,'time') == 1) tmp = sscanf(line,'%s %f'); time = tmp(length(tmp)); elseif (strcmp(tstr,'preparation') == 1) tmp = sscanf(line,'%s %f'); preparation = tmp(length(tmp)); elseif (strcmp(tstr,'breathing') == 1) tmp = sscanf(line,'%s %f'); breathing = tmp(length(tmp)); elseif (strcmp(tstr,'dncm') == 1) tmp = sscanf(line,'%s %f'); dncm = tmp(length(tmp)); elseif (strcmp(tstr,'baro') == 1) tmp = sscanf(line,'%s %f'); baro = tmp(length(tmp)); elseif (strcmp(tstr,'dra') == 1) tmp = sscanf(line,'%s %f'); dra = tmp(length(tmp)); elseif (strcmp(tstr,'df') == 1) tmp = sscanf(line,'%s %f'); df = tmp(length(tmp)); elseif (strcmp(tstr,'Fs') == 1) tmp = sscanf(line,'%s %f'); Fs = tmp(length(tmp)); elseif (strcmp(tstr,'Qfr') == 1) tmp = sscanf(line,'%s %f'); Qfr = tmp(length(tmp)); elseif (strcmp(tstr,'Qds') == 1) tmp = sscanf(line,'%s %f'); Qds = tmp(length(tmp)); elseif (strcmp(tstr,'Rair') == 1) tmp = sscanf(line,'%s %f'); Rair = tmp(length(tmp)); elseif (strcmp(tstr,'Clu') == 1) tmp = sscanf(line,'%s %f'); Clu = tmp(length(tmp)); elseif (strcmp(tstr,'Qluo') == 1) tmp = sscanf(line,'%s %f'); Qluo = tmp(length(tmp)); % elseif (strcmp(tstr,'timeql') == 1) % tmp = sscanf(line,'%s %f'); % timeql = tmp(length(tmp)); elseif (strcmp(tstr,'window') == 1) tmp = sscanf(line,'%s %f'); window = tmp(length(tmp)); elseif (strcmp(tstr,'annotations') == 1) tmp = sscanf(line,'%s %f'); annotations = tmp(length(tmp)); elseif (strcmp(tstr,'numerics') == 1) tmp = sscanf(line,'%s %f'); numerics = tmp(length(tmp)); elseif (strcmp(tstr,'waveform') == 1) lnum = findstr(line,':'); waveform = line(lnum+2:length(line)); elseif (strcmp(tstr,'alpha') == 1) tmp = sscanf(line,'%s %f'); alpha = tmp(length(tmp)); elseif (strcmp(tstr,'step') == 1) tmp = sscanf(line,'%s %f'); step = tmp(length(tmp)); end end end tstr = []; line = []; line = fgetl(inputfileid); end % Assigning these values to the th vector. theta = [Cls*((Plmax)/(Qlmax-Qlo)) Cld*((Plmax)/(Qlmax-Qlo)) Ca Cv Crs*((Prmax)/(Qrmax-Qro)) Crd*((Prmax)/(Qrmax-Qro)) Cpa Cpv Qlo Qao Qvo Qro Qpao Qpvo Rl Ra Rv Rr Rpa Rpv Qtot F Pvc-((Qfr-Qluo)/Clu) 1/F Pvc Qlmax Qrmax Ppa Pa Pv Plmax Prmax Pms 3 5 Qfrs againr bgain pgain Pasp Pratrsp Tr 50 fco 2 Sa stdwr stdwf 2 2 2 dgainp dgains againq cgainr cgainq 0 cgainfp alpha Sc 0.05 0.05 6 0.0575 0.1 0.00016 6.75 numerics 0.025 -0.01 865.4 1.45 0.15 647.9687 67.0312 784.2687 Qt step 0 1.25 2.5 5 0.003 2 4 5 0.003 Pvs]'; theta = [theta; Crds; Pas; Pvc; again; againc; cgainc; againfs; cgainfs; againfp; Qfr; Qds; Rair; Clu; Qluo; 300; window; annotations]; th = [theta; time*Fs; preparation; breathing; dncm; baro; dra; df; Fs]; % If 113 parameters have not been assigned numerical values, % then return a scalar -1 which will cause rcvsim to abort. if (length(th) < 113) th = []; th = -1; end