# dpsschk

## PURPOSE

Helper function to calculate tapers and, if precalculated tapers are supplied,

## SYNOPSIS

function [tapers,eigs]=dpsschk(tapers,N,Fs)

## DESCRIPTION

     Helper function to calculate tapers and, if precalculated tapers are supplied,
     to check that they (the precalculated tapers) the same length in time as
     the time series being studied. The length of the time series is specified
     as the second input argument N. Thus if precalculated tapers have
     dimensions [N1 K], we require that N1=N.
     Usage: tapers=dpsschk(tapers,N,Fs)
     Inputs:
     tapers        (tapers in the form of:
                                       (i) precalculated tapers or,
                                       (ii) [NW K] - time-bandwidth product, number of tapers)

     N             (number of samples)
     Fs            (sampling frequency - this is required for nomalization of
                                         tapers: we need tapers to be such
                                         that integral of the square of each taper equals 1
                                         dpss computes tapers such that the
                                         SUM of squares equals 1 - so we need
                                         to multiply the dpss computed tapers
                                         by sqrt(Fs) to get the right
                                         normalization)
     Outputs:
     tapers        (calculated or precalculated tapers)
     eigs          (eigenvalues)

## CROSS-REFERENCE INFORMATION

This function calls:

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
- cohgramc Multi-taper time-frequency coherence,cross-spectrum and individual spectra - continuous processes
- cohmatrixc Multi-taper coherency,cross-spectral matrix - continuous process
- fitlinesc fits significant sine waves to data (continuous data).
- ftestc computes the F-statistic for sine wave in locally-white noise (continuous data).
- mtdspecgramc Multi-taper derivative of the time-frequency spectrum - continuous process
- mtdspectrumc Multi-taper frequency derivative of the spectrum - continuous process
- mtpowerandfstatc Multi-taper computation of the power and the fstatistic for a particular frequency - continuous process
- mtspecgramc Multi-taper time-frequency 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
- rmlinesmovingwinc fits significant sine waves to data (continuous data) using overlapping windows.
- spsvd Space frequency SVD of input data - continuous processes
- 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
- cohgramcpb Multi-taper time-frequency coherence,cross-spectrum and individual spectra
- cohgramcpt Multi-taper time-frequency coherence,cross-spectrum and individual spectra
- CrossSpecMatpb
- coherencypb Multi-taper coherency,cross-spectrum and individual spectra - binned point process
- cohgrampb Multi-taper time-frequency coherence,cross-spectrum and individual spectra - two binned point processes
- cohmatrixpb Multi-taper coherency matrix - binned point process
- mtdspecgrampb Multi-taper derivatives of time-frequency spectrum - binned point process
- mtdspectrumpb Multi-taper spectral derivative - binned point process
- mtspecgrampb Multi-taper time-frequency spectrum - binned point process
- mtspectrumpb Multi-taper spectrum - binned point process
- mtspectrumsegpb Multi-taper segmented spectrum for a univariate binned point process
- CrossSpecMatpt
- coherencypt Multi-taper coherency - point process times
- cohgrampt Multi-taper time-frequency coherence - two point processes given as times
- cohmatrixpt Multi-taper coherency matrix - point process times
- mtdspecgrampt Multi-taper derivative time-frequency spectrum - point process times
- mtdspectrumpt Multi-taper spectral derivative - point process times
- mtspecgrampt Multi-taper time-frequency spectrum - point process times
- mtspectrumpt Multi-taper spectrum - point process times
- mtspectrumsegpt Multi-taper segmented spectrum for a univariate binned point process
- specscope record and plot audio spectrogram
- specscopepp
- mtspecgramc_fast Multi-taper time-frequency spectrum - continuous process
- mtspecgramc_slow Multi-taper time-frequency spectrum - continuous process

## SOURCE CODE

    0001 function [tapers,eigs]=dpsschk(tapers,N,Fs)
    0002 % Helper function to calculate tapers and, if precalculated tapers are supplied,
    0003 % to check that they (the precalculated tapers) the same length in time as
    0004 % the time series being studied. The length of the time series is specified
    0005 % as the second input argument N. Thus if precalculated tapers have
    0006 % dimensions [N1 K], we require that N1=N.
    0007 % Usage: tapers=dpsschk(tapers,N,Fs)
    0008 % Inputs:
    0009 % tapers        (tapers in the form of:
    0010 %                                   (i) precalculated tapers or,
    0011 %                                   (ii) [NW K] - time-bandwidth product, number of tapers)
    0012 %
    0013 % N             (number of samples)
    0014 % Fs            (sampling frequency - this is required for nomalization of
    0015 %                                     tapers: we need tapers to be such
    0016 %                                     that integral of the square of each taper equals 1
    0017 %                                     dpss computes tapers such that the
    0018 %                                     SUM of squares equals 1 - so we need
    0019 %                                     to multiply the dpss computed tapers
    0020 %                                     by sqrt(Fs) to get the right
    0021 %                                     normalization)
    0022 % Outputs:
    0023 % tapers        (calculated or precalculated tapers)
    0024 % eigs          (eigenvalues)
    0025 if nargin < 3; error('Need all arguments'); end
    0026 sz=size(tapers);
    0027 if sz(1)==1 && sz(2)==2;
    0028     [tapers,eigs]=dpss(N,tapers(1),tapers(2));
    0029     tapers = tapers*sqrt(Fs);
    0030 elseif N~=sz(1);
    0031     error('seems to be an error in your dpss calculation; the number of time points is different from the length of the tapers');
    0032 end;