% Analysis of MU-spiking coherence load('all_files') s=2; % analyze normal, MPTP and DRT LFP segment data coherence=cell(1,3); coherence_shifted=cell(1,3); num_traces_per_pair_shift=cell(1,3); num_traces_per_pair=cell(1,3); f_coher_spike_FP=[]; for r=1:3 for ff=1:length(all_files{s,r}) load(all_files{s,r}{1,ff},'data2plot','SWS_stats') for unitnum=1:length(data2plot.FR) if ~isempty(data2plot.FR{1,unitnum}) && ~isempty(SWS_stats{1,unitnum}.NREM_bins{1,1}) NREM_bins=[]; for ss=1:length(SWS_stats{1,unitnum}.NREM_bins) if ss==1 NREM_bins=[NREM_bins,SWS_stats{1,unitnum}.NREM_bins{1,1}]; else NREM_bins=[NREM_bins,SWS_stats{1,unitnum}.NREM_bins{1,ss}+sum(data2plot.FR{1,unitnum}.stable_period_lengths_in_bs(1,1:ss-1))]; end end if NREM_bins(1,end)>length(data2plot.beta_segment_analysis.MU_beta_total_segment_length{1,unitnum}) NREM_bins=NREM_bins(1,1:end-1); end NREM_bins=NREM_bins(1:find(NREM_bins