function fastandslow_this_trial=fitting_to_fast_and_slow_templates(datatrace,fastemplate,slotemplate)
%called from patchfile analysis, runs across the sweep from nnn ms before the first AP to mmm after the last AP, checking the membrane current trace against two templates
%one of the templates decays quickly, one decays slowly, thus events of almost any kinetics should be identifiable
%the pre-AP time serves as an additional control for bgrd rate
%every event is marked with its trial, preceding AP (if any), time since that AP, and time since the first AP
%the checked portion of the raw trace, the two criterion files, and the individual events are returned
%the goal here is to work with very high quality (low noise, stable patch and low background rate) recordings and extract any and all events, which if then checked as being non-double, short plateau, and fast rise, can be clustered

%zero the stimulus artifacts?

critfast=template_based_mini_detector(datatrace,fastemplate)';
critslow=template_based_mini_detector(datatrace,slotemplate)';
fastandslow_this_trial=[critfast critslow];