function criterion_matrix=spontaneous_event_finder(raw_values);

tic
criterion_matrix=[];
template=lsqfit_template_generator([3 8 52 225 0 0],[1:(200-1)]);template=[0 template];
for i=1:size(raw_values,2)
%     hi=find(raw_values(:,i+1)>2);
%     a=min(raw_values(hi(1)+[0:99999],i));
%     criterion_matrix=[criterion_matrix a];
%     dcz=template_based_mini_detector(raw_values(hi(1)+[0:99999],i));
    dcz=template_based_mini_detector(raw_values(:,i),template');
    criterion_matrix=[criterion_matrix dcz'];
    s=num2str(i);
    disp(strcat('Processed', s, ' traces')) 
end
toc