
clear all;

datafile = {'F:\oxytocin\ACh_OXT004\ACh_OXT004_015_230411_150537',
            'F:\oxytocin\ACh_OXT004\ACh_OXT004_016_230412_145104',
            'F:\oxytocin\ACh_OXT004\ACh_OXT004_017_230412_151435'}
Ch = [62,62,62]

for ii = 1:length(datafile)
    cd(datafile{ii,:})
    
    basepath = pwd;
    basename = bz_BasenameFromBasepath(basepath);
    

    % get alighment
    info = read_Intan_RHD2000_file(basepath);
    digitalin = read_Intan_digitalin_file('digitalin.dat',info.num_board_dig_in_channels)';
    lfp_fbtime = find(digitalin(1,:)>(max(digitalin)+min(digitalin))/2,1);
    % get name 
    
    %get LFPs
    THLFPs = bz_GetLFP(Ch(ii),'basepath',basepath,'noPrompts',true);
    lfp = double(THLFPs.data);
    lfp(abs(lfp)>5000) = nan;
    lfp = fillmissing(lfp,'linear');
    THLFPs.data = lfp;

    datpath = 'G:\My Drive\Paper_ACh_OXT\Fig1\Data\Figure1F\OXT_theta'
    save(fullfile(datpath,[basename,'_LFPs.mat']),'THLFPs','lfp_fbtime');
end
