#TODO: problem here: /!\ level 3- spline does not with many samples, maybe a random beats trigger a condition that breake ecgpwuave (not halting)
# IT IS SOLVED BY TERMINATING (CTRL-C ing) ONCE WE USE THE LEVEL 3 --> arresting ecgpuwave stop only the delineator and everything else works
# TO ANALYZE BY NOT DELETING LEVELS AND TEST FROM TERMINAL --> there are annotations where level 3 fails to have any reconizable peak around the given annotation !
print(f"\tOld templates kept, representative of new clusters (but already present): {new_templates_substituted}/{len(old_templates)}")
print(f"\tOld templates removed for old clusters (with new defined params): {len(old_templates) - (old_templates_kept+old_templates_substituted+new_templates_substituted)}/{len(old_templates)}")
print(f"\tOld templates removed for new clusters: {old_templates_substituted}/{len(old_templates)}")
print(f"\tNew templates kept, representative of old clusters (with new params): {len(lbls_new_templates) - (new_templates_kept+new_templates_substituted)}/{len(lbls_new_templates)}")
print(f"\tNew templates removed for old clusters: {new_templates_substituted}/{len(lbls_new_templates)}")
print(f"\n\tFinal lenght of the new tempalte set: {len(new_template_set)}")
else:
new_template_set=old_templates
print("\tNo new template found, keeping the previously computed ones")
all_templates_collection,measurements_id_coupling,initial_templates,time_info,QRS_pos_new=reconstruct_beats(data_orig,lvl,file_name=file.split(".")[0],init_templates=initial_templates,start_after=SEC_FOR_INITIAL_TEMPLATES,resample_type=interpolation_type,num_beats_analyzed=NUM_BEAT_ANALYZED,verbose=False,log_dir=log_dir_this_lvl)#resample_type = flat vs linear