# mtfftc

## PURPOSE

Multi-taper fourier transform - continuous data

## SYNOPSIS

function J=mtfftc(data,tapers,nfft,Fs)

## DESCRIPTION

     Multi-taper fourier transform - continuous data

     Usage:
     J=mtfftc(data,tapers,nfft,Fs) - all arguments required
     Input:
           data (in form samples x channels/trials or a single vector)
           tapers (precalculated tapers from dpss)
           nfft (length of padded data)
           Fs   (sampling frequency)

     Output:
           J (fft in form frequency index x taper index x channels/trials)

## CROSS-REFERENCE INFORMATION

This function calls:

- change_row_to_column Helper routine to transform 1d arrays into column vectors that are needed

This function is called by:

- CrossSpecMat
- CrossSpecMatc Multi-taper cross-spectral matrix - another routine, allows for multiple trials and channels
- coherencyc Multi-taper coherency,cross-spectrum and individual spectra - continuous process
- coherencyc_unequal_length_trials This routine computes the average multi-taper coherence for a given set of unequal length segments. It is
- cohmatrixc Multi-taper coherency,cross-spectral matrix - continuous process
- ftestc computes the F-statistic for sine wave in locally-white noise (continuous data).
- mtdspectrumc Multi-taper frequency derivative of the spectrum - continuous process
- mtspectrumc Multi-taper spectrum - continuous process
- mtspectrumc_unequal_length_trials This routine computes the multi-taper spectrum for a given set of unequal length segments. It is
- mtspectrumsegc Multi-taper segmented spectrum for a univariate continuous process
- nonst_stat Nonstationarity test - continuous process
- coherencycpb Multi-taper coherency,cross-spectrum and individual spectra - continuous and binned point process data
- coherencycpt Multi-taper coherency,cross-spectrum and individual spectra -continuous data and point process as times

## SOURCE CODE

    0001 function J=mtfftc(data,tapers,nfft,Fs)
    0002 % Multi-taper fourier transform - continuous data
    0003 %
    0004 % Usage:
    0005 % J=mtfftc(data,tapers,nfft,Fs) - all arguments required
    0006 % Input:
    0007 %       data (in form samples x channels/trials or a single vector)
    0008 %       tapers (precalculated tapers from dpss)
    0009 %       nfft (length of padded data)
    0010 %       Fs   (sampling frequency)
    0011 %
    0012 % Output:
    0013 %       J (fft in form frequency index x taper index x channels/trials)
    0014 if nargin < 4; error('Need all input arguments'); end;
    0015 data=change_row_to_column(data);
    0016 [NC,C]=size(data); % size of data
    0017 [NK K]=size(tapers); % size of tapers
    0018 if NK~=NC; error('length of tapers is incompatible with length of data'); end;
    0019 tapers=tapers(:,:,ones(1,C)); % add channel indices to tapers
    0020 data=data(:,:,ones(1,K)); % add taper indices to data
    0021 data=permute(data,[1 3 2]); % reshape data to get dimensions to match those of tapers
    0022 data_proj=data.*tapers; % product of data with tapers
    0023 J=fft(data_proj,nfft)/Fs;   % fft of projected data