


Multi-taper fourier transform - binned point process data
Usage:
[J,f,Msp]=mtfftptb(data,tapers,nfft) - all arguments required
Input:
data (in form samples x channels/trials)
tapers (precalculated tapers from dpss)
nfft (length of padded data)
Output:
J (fft in form frequency index x taper index x channels/trials)
Msp (number of spikes per sample in each channel)
Nsp (number of spikes in each channel)

0001 function [J,Msp,Nsp]=mtfftpb(data,tapers,nfft) 0002 % Multi-taper fourier transform - binned point process data 0003 % 0004 % Usage: 0005 % 0006 % [J,f,Msp]=mtfftptb(data,tapers,nfft) - all arguments required 0007 % Input: 0008 % data (in form samples x channels/trials) 0009 % tapers (precalculated tapers from dpss) 0010 % nfft (length of padded data) 0011 % Output: 0012 % J (fft in form frequency index x taper index x channels/trials) 0013 % Msp (number of spikes per sample in each channel) 0014 % Nsp (number of spikes in each channel) 0015 0016 if nargin < 3; error('Need all input arguments'); end; 0017 [N,C]=size(data); % size of data 0018 [N K]=size(tapers); % size of tapers 0019 tapers=tapers(:,:,ones(1,C)); % add channel indices to tapers 0020 H=fft(tapers,nfft,1); % fourier transform of the tapers 0021 Nsp=sum(data,1); % number of spikes in each channel 0022 Msp=Nsp'./N; % mean rate for each channel 0023 meansp=Msp(:,ones(1,K),ones(1,size(H,1))); % add taper and frequency indices to meansp 0024 meansp=permute(meansp,[3,2,1]); % permute to get meansp with the same dimensions as H 0025 data=data(:,:,ones(1,K));% add taper indices to the data 0026 data=permute(data,[1 3 2]); % permute data to be of the same dimensions as H 0027 data_proj=data.*tapers; % multiply data by the tapers 0028 J=fft(data_proj,nfft,1); % fft of projected data 0029 J=J-H.*meansp; % subtract the dc