clear all; clc; close all

datafile = {'F:\oxytocin\ACh_OXT004\ACh_OXT004_007_230306_152436',
            'F:\oxytocin\ACh_OXT004\ACh_OXT004_011_230325_130235',
            'F:\oxytocin\ACh_OXT004\ACh_OXT004_019_230507_140912',             
            'F:\oxytocin\ACh_OXT007\ACh_OXT007_015_230507_172920',
            'H:\Project_ACh_REM\CIRP001\CIRP001_002_231104_104438',
            'H:\Project_ACh_REM\CIRP002\CIRP002_002_231105_133826'};
rho_session = [];
P_session = [];
for i = 1:length(datafile)
    cd(datafile{i})
    basepath = pwd;
    basename = bz_BasenameFromBasepath(basepath);
    load([basename,'_FluoData.mat']);
    ACh = zscore(FluoData.Ach_dFF(1:end-100));
    OXT = zscore(FluoData.Oxt_dFF(1:end-100));
    
    
    [r,p] = corr(ACh,OXT);
    mdl = fitlm(ACh,OXT);
    figure;plot(mdl);title([basename,'-',num2str(i)])
    
    rho_session = [rho_session;r];
    P_session = [P_session;p];

end

mdl = fitlm(REM_ACh_all,REM_OXT_all);
figure;plot(mdl);
[r_all,p_all] = corr(REM_ACh_all,REM_OXT_all);
rho_ave = mean(rho_session)
rho_std = std(rho_session)
