IdClean = 1:length(DS2.peaks);
if DS2.flagged
IdClean(DS2.flagged) = [];
DS2clean.peaks = DS2.peaks(IdClean);
DS2clean.timestamps = DS2.timestamps(IdClean,:);
DS2clean.detectorinfo.detectionchannel =DS2.detectorinfo.detectionchannel
end
%DS2.detectorinfo.detectionchannel = 7;
%DS2clean = computeRippleStats('Ripples',DS2clean, 'rippleChannel', DS2.detectorinfo.detectionchannel);
DS2 = DS2clean;
saveas(gcf,['SummaryFigures\DS2cleanDetection.png']);
save([basenameFromBasepath(pwd) , '.DS2clean.events.mat'],'DS2');


[DS2.detectorinfo.ml_channel DS2.detectorinfo.h_channel]