56 r->
trigs.
lst = (
double *)calloc(num_stim,
sizeof(
double));
59 fprintf(stderr,
"Couldn't allocate memory\n");
62 r->
trigs.
pmat = (
bool *)calloc(num_stim,
sizeof(
bool));
65 r->
saveState.
lst = (
double *)calloc(num_decs,
sizeof(
double));
78 for (
int i = 0; i < num_decs; i++) {
96 r->
trigs.
lst = (
double *)calloc(num_stim,
sizeof(
double));
97 r->
trigs.
pmat = (
bool *)calloc(num_stim,
sizeof(
bool) );
100 r->
saveState.
lst = (
double *)calloc(num_decs,
sizeof(
double));
104 double trgTime = 1.0;
113 for (
int i = 0; i < num_decs; i++) {
127 *t_dop =
static_cast<double *
>(malloc(num_decs*
sizeof(
double)));
129 for (
int i = 0; i < num_decs; i++, trgIdx += 2)
130 (*t_dop)[i] = r->
trigs.
lst[trgIdx] - 1;
135 r->
trigs.
lst = (
double *)calloc(num_stim,
sizeof(
double));
136 r->
trigs.
pmat = (
bool *)calloc(num_stim,
sizeof(
bool));
139 r->
saveState.
lst = (
double *)calloc(num_decs,
sizeof(
double));
143 double trgTime = 1.0;
152 for (
int i = 0; i < num_decs; i++) {
155 if ((i > 0) && (j == 0))
171 if (strcmp(r_file,
"")) {
173 log_msg(NULL, 0, 0,
"\n\nError reading protocol definition from %s",r_file);
181 log_msg(NULL, 3, 0,
"Restitution protocol definition file does not match.\n");
182 log_msg(NULL, 3, 0,
"Using default protocol definitions.\n");
226 FILE *pdef = fopen(r_file,
"rt");
228 if (!pdef)
return -1;
232 fgets(buf, BUFSIZE, pdef);
233 }
while ((*buf ==
'\n') || (*buf ==
'#'));
236 sscanf(buf,
"%d", &useS1S2);
240 sscanf(fgets(buf, BUFSIZE, pdef),
"%d", &r->
numppBeats);
242 log_msg(NULL, 2, 0,
"#prepacing beats %d < #calibration beats %d.",
244 log_msg(NULL, 2, 0,
"This may bias the calibration of AP statistics parameters.");
247 sscanf(fgets(buf, BUFSIZE, pdef),
"%f", &r->
rtype.
S1S2.
bcl);
254 sscanf(fgets(buf, BUFSIZE, pdef),
"%d", &r->
numppBeats);
276 char save_name[1024];
279 snprintf(save_name,
sizeof save_name,
"test_%d.sv", cnt++);
void restitution_trigger_list(char *r_file, restitution *r, char *protocol, int *n_dop, double **t_dop)
TrgList trigs
trigger list for defining stim sequence
float bcl_dec
decrement in bcl
r_prtcl prtcl
protocol type
float S2_dec
decrement for S2 beats
void save_sv(MULTI_IF *, int, const char *)
void get_protocol_definition(char *r_file, restitution *r, bool useS1S2)
TrgList saveState
instants at wich we save state vectors
int n
number of pulses required for protocol
union limpet::restitution::@0 rtype
int read_restitution_protocol_def(char *r_file, restitution *r)
float bcl
basic cycle length
float bcl_end
final basic cycle length
double * lst
store instants of pulse delivery
int beats_per_bcl
number of beats for a particular bcl
float S2_end
bcl of last premature beat
void restitution_save_sv(MULTI_IF *miif, int R1, restitution *r, action_potential *AP)
float S2_start
bcl of first premature beat
void log_msg(FILE_SPEC out, int level, unsigned char flag, const char *fmt,...)
float bcl_start
initial basic cycle length
double dur
total duration of protocol
int beats_per_S2
number of beats before S2
bool * pmat
store flag to indicate prematurity
int numppBeats
number of prepaced beats before protocol