clear all;close all;

dataname = ['F:\LIMP003\LIMP003_006_210413_112545', %% good ach and good CA1  optitrack         
           'F:\LIMP018\LIMP018_003_220127_150338', %% good ach and good CA1  
           'F:\LIMP011\LIMP011_008_210622_092807', %% good ach-signal but CA3 neurons   optitrack
           'F:\LIMP013\LIMP013_011_210630_142011', %% good ach-signal but CA3 neurons   optitrack
           'F:\LIMP016\LIMP016_005_220103_130720', %% need correction of signal but good CA1 neurons
           'F:\LIMP019\LIMP019_007_220307_155644'] %% no ach-signal but has CA1 neurons;

RipCh = [11,26,nan,nan,53,1]
%% inhibtion on ACh signal
for ii =[5,6]
    cd(dataname(ii,:))
    basepath = pwd;
    basename = bz_BasenameFromBasepath(basepath);
    load([basename,'.SleepState.states.mat']);
    load([basename,'.pulses.events.mat']);

    info = read_Intan_RHD2000_file(basepath);
    RipLFPs = bz_GetLFP(RipCh(ii),'basepath',basepath,'noPrompts',true);
    RipLFPs.data = double(RipLFPs.data);
    RipLFPs.data(abs(RipLFPs.data)>5000) = nan;
    RipLFPs.data = fillmissing(RipLFPs.data,'linear');

    pulse = pulses.intsPeriods;
    events = pulse(:,1);
    twin = [5 10];
    lfp = RipLFPs;
    [ wavAvg, lfpAvg ] = bz_eventWavelet (lfp, events);  

    datpath = 'G:\My Drive\Paper_ACh_OXT\Fig5\Figure 5B';
    save(fullfile(datpath,[basename,'_event_wavelet.mat']),'wavAvg');
end
