


Helper function to convert structure params to variables used by the
various routines - also performs checks to ensure that parameters are
defined; returns default values if they are not defined.
Usage: [tapers,pad,Fs,fpass,err,trialave,params]=getparams(params)
Inputs:
params: structure with fields tapers, pad, Fs, fpass, err, trialave
- optional
tapers (precalculated tapers from dpss, or in the form [NW K] e.g [3 5]) -- optional. If not
specified, use [NW K]=[3 5]
pad (padding factor for the FFT) - optional. Defaults to 0.
e.g. For N = 500, if PAD = 0, we pad the FFT
to 512 points; if PAD = 2, we pad the FFT
to 2048 points, etc.
Fs (sampling frequency) - optional. Default 1.
fpass (frequency band to be used in the calculation in the form
[fmin fmax])- optional.
Default all frequencies between 0 and Fs/2
err (error calculation [1 p] - Theoretical error bars; [2 p] - Jackknife error bars
[0 p] or 0 - no error bars) - optional. Default 0.
trialave (average over trials when 1, don't average when 0) - optional. Default 0
Outputs:
The fields listed above as well as the struct params. The fields are used
by some routines and the struct is used by others. Though returning both
involves overhead, it is a safer, simpler thing to do.

0001 function [tapers,pad,Fs,fpass,err,trialave,params]=getparams(params) 0002 % Helper function to convert structure params to variables used by the 0003 % various routines - also performs checks to ensure that parameters are 0004 % defined; returns default values if they are not defined. 0005 % 0006 % Usage: [tapers,pad,Fs,fpass,err,trialave,params]=getparams(params) 0007 % 0008 % Inputs: 0009 % params: structure with fields tapers, pad, Fs, fpass, err, trialave 0010 % - optional 0011 % tapers (precalculated tapers from dpss, or in the form [NW K] e.g [3 5]) -- optional. If not 0012 % specified, use [NW K]=[3 5] 0013 % pad (padding factor for the FFT) - optional. Defaults to 0. 0014 % e.g. For N = 500, if PAD = 0, we pad the FFT 0015 % to 512 points; if PAD = 2, we pad the FFT 0016 % to 2048 points, etc. 0017 % Fs (sampling frequency) - optional. Default 1. 0018 % fpass (frequency band to be used in the calculation in the form 0019 % [fmin fmax])- optional. 0020 % Default all frequencies between 0 and Fs/2 0021 % err (error calculation [1 p] - Theoretical error bars; [2 p] - Jackknife error bars 0022 % [0 p] or 0 - no error bars) - optional. Default 0. 0023 % trialave (average over trials when 1, don't average when 0) - optional. Default 0 0024 % Outputs: 0025 % The fields listed above as well as the struct params. The fields are used 0026 % by some routines and the struct is used by others. Though returning both 0027 % involves overhead, it is a safer, simpler thing to do. 0028 if ~isfield(params,'tapers') || isempty(params.tapers); 0029 params.tapers=[3 5]; 0030 end; 0031 if ~isfield(params,'pad') || isempty(params.pad); 0032 params.pad=2; 0033 end; 0034 if ~isfield(params,'Fs') || isempty(params.Fs); 0035 params.Fs=1; 0036 end; 0037 if ~isfield(params,'fpass') || isempty(params.fpass); 0038 params.fpass=[0 params.Fs/2]; 0039 end; 0040 if ~isfield(params,'err') || isempty(params.err); 0041 params.err=0; 0042 end; 0043 if ~isfield(params,'trialave') || isempty(params.trialave); 0044 params.trialave=0; 0045 end; 0046 0047 tapers=params.tapers; 0048 pad=params.pad; 0049 Fs=params.Fs; 0050 fpass=params.fpass; 0051 err=params.err; 0052 trialave=params.trialave;