for rh_idx = 1: l
corr_RH(rh_idx,:,:) = corrcoef(squeeze(bp_RH(rh_idx,:,:)));
end
for rf_idx = 1:r
corr_RF(rf_idx,:,:) = corrcoef(squeeze(bp_RF(rf_idx,:,:)));
end
mean_corr_RH = squeeze(mean(corr_RH, 1));
mean_corr_RF = squeeze(mean(corr_RF, 1));
freedom = l + r - 2;
for rh_idx = 1: l
s_temp_rh(rh_idx, :,:) = (squeeze(corr_RH(rh_idx,:,:)) - mean_corr_RH).^2;
end
for rf_idx = 1: l
s_temp_rf(rf_idx, :,:) = (squeeze(corr_RF(rf_idx,:,:)) - mean_corr_RH).^2;
end
s_rh = sum(s_temp_rh,1) ./ (l-1) ;
s_rf = sum(s_temp_rf,1) ./ (r-1) ;
s_p = sqrt( ((l-1).*squeeze(s_rh) + (r-1).*squeeze(s_rf)) ./ freedom );
t_value = ( mean_corr_RH - mean_corr_RF ) ./ s_p * sqrt( 1/l + 1/r );
P_thr = 0.05;