46 using ::opencarp::timer_manager;
156 fprintf(stderr,
"Parameter sequence written to action potential statistics file.\n");
210 for(
int i=1;i<vm_hist_len;i++) {
231 double AP_amplitude = vm_mx-vm_mn;
232 double thresh90 = vm_mn+AP_amplitude*(1.-90./100.);
233 double thresh30 = vm_mn+AP_amplitude*(1.-30./100.);
235 log_msg(NULL, 0, 0,
"Measuring AP parameters for calibration." );
238 log_msg(NULL, 0, 0,
"Changing activation threshold xAPD90 (%.1f->%.1f).",
239 e[
xAPD90].c.x_thresh.threshold,thresh90);
243 log_msg(NULL, 0, 0,
"Changing repolarisation threshold APD90 (%.1f->%.1f).",
244 e[
APD90].c.x_thresh.threshold,thresh90);
247 log_msg(NULL, 0, 0,
"Changing repolarisation threshold APD30 (%.1f->%.1f).",
248 e[
APD30].c.x_thresh.threshold,thresh30);
268 bool act_triggered =
false;
280 fprintf( stderr,
"Not implemented yet.\n" );
290 fprintf( stderr,
"Not implemented yet.\n" );
298 fprintf( stderr,
"Not implemented yet.\n" );
304 if((AP->
beat==AP->
calBeat) && (tm->time - prevAct < 5.))
313 act_triggered =
true;
323 log_msg( NULL, 0, 0,
"Activation event %s triggered at %.3f ms.",
343 return act_triggered;
358 bool is_stedy =
false;
360 #define NUM_STEADY_APs 5 361 #define SS_PERC_ERR 0.01 373 AP->
ss.
c[1] = AP->
DI;
380 float r_err = fabs(AP->
ss.
c[i]-AP->
ss.
p[i])/AP->
ss.
c[i]*100.;
382 AP->
ss.
p[i] = AP->
ss.
c[i];
418 double *s = e->
trace;
448 double *s = e->
trace;
452 e->
t = tm->time - tm->time_step*0.5;
459 e->
t = tm->time - tm->time_step*0.5;
478 double *s = e->
trace;
480 if(e->
s<s[0]) { e->
s = s[0]; e->
t = tm->time; }
483 if(e->
s>s[0]) { e->
s = s[0]; e->
t = tm->time; }
506 fprintf(AP->
stats,
"%d %1s %1d %.2f %.2f %.2f %.2f %.2f %.2f %.3f\n",
508 AP->
triang,vm_mx, vm_mn, act_tm);
512 fprintf(AP->
rstats,
"%d %1s %1d %.2f %.2f %.2f %.2f %.2f %.2f %.3f\n",
514 AP->
triang,vm_mx, vm_mn, act_tm);
529 fprintf(outbuf,
"# Beat Prematurity(P||*) steady_state ");
530 fprintf(outbuf,
"APD(n) DI(n) DI(n-1) Triangulation VmMax VmMin tAct\n" );
void calibrate_thresholds(action_potential *AP)
int calBeat
beat number used to calibrate thresholds
bool check_steady_state(steady_state_ap *ss)
bool pmat
indiacte premature AP
int cnt
count number of beats in steady state
ap_events ampls
amplitude events (mx or mn found in a signal)
enum limpet::_act_events act_events
char * dupstr(const char *old_str)
float * p
array of parameters at previous AP
FILE * rstats
output restitution statistics only
float triang
AP triangulation, APD90-APD30.
enum limpet::_repol_events repol_events
void print_AP_stats_header(action_potential *AP, FILE *outbuf)
double dvm_trc[VM_HIST_LEN]
bool check_events(double vm, action_potential *AP, timer_manager *tm)
double t
time when event was observed
double * trace
short trace of signal to analyze
event_x_threshold x_thresh
bool check_threshold(ap_event *e, timer_manager *tm)
double s
value of signal when event occurred
float * c
array of parameters at current AP
float APD
standard APD as measured by APD90
int initialize_AP_analysis(action_potential *AP)
void print_AP_stats(action_potential *AP)
int num_APs
minimum number of APs for steady state
void cleanup_AP_analysis(action_potential *AP)
double vm_trc[VM_HIST_LEN]
enum limpet::_ampl_events ampl_events
ap_events repols
repolarization events
bool update_steady_state(action_potential *AP)
ap_events acts
activation events
FILE * stats
output statistics for each AP
ap_states state
current state of AP, ongoing AP or diastole
bool p_slope
toggle max min search
steady_state_ap ss
steady state detection
int num_params
number of parameters we use to decide steady state
void shift_vm_trace(double vm, action_potential *AP, timer_manager *tm)
void log_msg(FILE_SPEC out, int level, unsigned char flag, const char *fmt,...)
float DIp
DI of the previous AP.
bool check_mx_rate(ap_event *e, timer_manager *tm)
bool check_mx_val(ap_event *e, timer_manager *tm)
Basic utility structs and functions, mostly IO related.
int get_rank(MPI_Comm comm=PETSC_COMM_WORLD)