% Sample Analysis of Experiment 3 % Cursor and LFP power spectra, cursor-LFP coherence and LFP-LFP imaginary coherence % Generates Figure 6 % from 'Extrinsic and Intrinsic Dynamics in Movement Intermittency' % by Susilaradeya et al. % % Experiment3.mat contains data from Monkey S... % % cond(1..4). Data for 4 conditions % delay with feedback delays of 0ms, 200ms, 400ms, 600ms % session(1..?). and multiple sessions % trial(1..?). comprising approximately 50 trials c_pos Cursor position % lfp 6 local field potential recordings % c_pos Cursor position % t_pos Target position % c_rad_speed Radial cursor speed % c_rad_speed_filt Filtered radial cursor speed % % s_rate 488Hz sampling rate close all clear all load Experiment3 nfft=2^14; noverlap=2^14-2^12; num_cond=4; num_lfp=6; for d=1:num_cond num_session=length(cond(d).session); c_sect_all=[];l_sect_all=[]; for s=1:num_session num_trial=length(cond(d).session(s).trial); % Concatenate trials within each session c_sect=[];l_sect=[]; for t=1:num_trial c_sect=[c_sect;cond(d).session(s).trial(t).c_rad_speed]; l_sect=[l_sect;cond(d).session(s).trial(t).lfp]; end sect_len=1024; % Remove task-locked components and concatenate across sessions ms=mean(reshape(c_sect,sect_len,length(c_sect)/sect_len),2); c_sect_all=[c_sect_all;c_sect-repmat(ms,length(c_sect)/sect_len,1)]; ms=squeeze(mean(reshape(l_sect,sect_len,length(l_sect)/sect_len,num_lfp),2)); l_sect_all=[l_sect_all; l_sect-repmat(ms,length(l_sect)/sect_len,1,1)]; end % Perform FFT [c_fft freq]=spectrogram(c_sect_all,nfft,noverlap,nfft,s_rate); c_fft2=mean(c_fft.*conj(c_fft),2); % Calculate cursor power spectra c_pow=pwelch(c_sect_all,nfft,noverlap,nfft,s_rate); lfp_fft=[]; for l=1:num_lfp [lfp_fft(:,:,l) freq]=spectrogram(l_sect_all(:,l),nfft,noverlap,nfft,s_rate); lfp_fft2(:,l)=mean(lfp_fft(:,:,l).*conj(lfp_fft(:,:,l)),2); % Calculate LFP power spectra lfp_pow(:,l)=pwelch(l_sect_all(:,l),nfft,noverlap,nfft,s_rate); % Calculate Cursor-LFP coherence lfp_c_coh(:,l)=(abs(mean(lfp_fft(:,:,l).*conj(c_fft),2)).^2)./(lfp_fft2(:,l).*c_fft2); end count=0; for l1=1:num_lfp-1 for l2=l1+1:num_lfp count=count+1; % Calculate LFP-LFP imaginary coherence lfp_lfp_imagcoh(:,count)=(imag(mean(lfp_fft(:,:,l1).*conj(lfp_fft(:,:,l2)),2))).^2./(lfp_fft2(:,l1).*lfp_fft2(:,l2)); end end % Average across LFP channels mean_lfp_pow=mean(lfp_pow,2); mean_lfp_c_coh=mean(lfp_c_coh,2); mean_lfp_lfp_imagcoh=mean(lfp_lfp_imagcoh,2); % Smooth spectra smooth_c_pow=conv(c_pow,hanning(16),'same')/sum(hanning(16)); smooth_lfp_pow=conv(mean_lfp_pow,hanning(16),'same')/sum(hanning(16)); smooth_lfp_c_coh=conv(mean_lfp_c_coh,hanning(16),'same')/sum(hanning(16)); smooth_lfp_lfp_imagcoh=conv(mean_lfp_lfp_imagcoh,hanning(16),'same')/sum(hanning(16)); % Plot cursor power spectra subplot(4,4,(d-1)*4+1) plot(freq,smooth_c_pow); axis([0 8 0 6500]); if d==1 title('Cursor power') end % Plot LFP power spectra subplot(4,4,(d-1)*4+2) plot(freq,smooth_lfp_pow); axis([0 8 0 420]); if d==1 title('LFP power') end % Plot Cursor-LFP coherence spectra subplot(4,4,(d-1)*4+3) plot(freq,smooth_lfp_c_coh); axis([0 8 0 0.2]); if d==1 title('Cursor-LFP coherence') end % Plot LFP-LFP imaginary coherence spectra subplot(4,4,(d-1)*4+4) plot(freq,smooth_lfp_lfp_imagcoh); axis([0 8 0 0.2]); if d==1 title('LFP-LFP imag coherence') end end