function [indAPyes,vmsnoAPs]=remTrialswithAPs(vms,ws,we,srate)
thresh_AP = -0.03;
APinds = cell(size(vms,1),1);
for l=1:size(vms,1)
    [~, APind]= findpeaks(vms(l,:),'MINPEAKHEIGHT',thresh_AP,'MINPEAKDISTANCE',0.002*srate);
    APinds{l}=APind;
end
APindsmsec = cellfun(@(x)(1000*(x-1)./srate),APinds,'UniformOutput',0);
APyes = cellfun(@(x) sum(x>ws & x<we) ,APindsmsec,'UniformOutput',0);
indAPyes=~cell2mat(APyes)~=0;
vmsnoAPs = vms(indAPyes,:);
end