function ann_indxs=Ann_cleaner(t,processed_signal,num_of_stds,ann_indxs)
%%  Cleans signals with low derivative
input_signal_diff=diff(processed_signal);
input_signal_diff=input_signal_diff(~isnan(input_signal_diff));
mean_abs_sig_diff=mean(abs(input_signal_diff));
std_abs_sig_diff=std(abs(input_signal_diff));
% 
% plot(t,processed_signal(1:numel(t)))
% hold all
% plot(t(ann_indxs),processed_signal(ann_indxs))
% plot(t(2:end),abs(input_signal_diff))
is_R_Peak=[];

%%  Filter
max_aerial_diffs=[];
for counter=1:numel(ann_indxs)
    try
    max_aerial_diffs(counter)=max(abs(input_signal_diff(ann_indxs(counter)-5:ann_indxs(counter)+5)));
    catch
        try
        max_aerial_diffs(counter)=max(abs(input_signal_diff(ann_indxs(counter)-5:ann_indxs(counter))));        
        catch
             max_aerial_diffs(counter)=0;
        end
    end
    if max_aerial_diffs(counter)>(mean_abs_sig_diff+num_of_stds*std_abs_sig_diff)
        is_R_Peak(counter)=1;
    else
        is_R_Peak(counter)=0;        
    end
end
% plot(t(ann_indxs),max_aerial_diffs)
ann_indxs=ann_indxs(is_R_Peak>0);