function vmbAPs = blankAPs(vm,srate)

vmbAPs = vm;
pre_AP = 60; %3 ms
post_AP = 100; %5 ms
thresh_AP = -0.03; %% -30 mV

[~, AP_ind]= findpeaks(vm,'MINPEAKHEIGHT',thresh_AP,'MINPEAKDISTANCE',0.002*srate); %2 ms refractory period

if(~isempty(AP_ind))
    for k=1 : size(AP_ind,2)
        if(AP_ind(k)<= pre_AP)
            vmbAPs(1:AP_ind(k)+post_AP)=nan;
        end
        if(AP_ind(k)> size(vmbAPs,2)-post_AP)
            vmbAPs(AP_ind(k)-pre_AP:end)=nan;
        end
        if(pre_AP < AP_ind(k) && AP_ind(k)<= size(vmbAPs,2)-post_AP)
            vmbAPs(AP_ind(k)-pre_AP:AP_ind(k)+post_AP)=nan;
        end
    end
end

end