Home > chronux_1_50 > helper > getparams.m

getparams

PURPOSE ^

Helper function to convert structure params to variables used by the

SYNOPSIS ^

function [tapers,pad,Fs,fpass,err,trialave,params]=getparams(params)

DESCRIPTION ^

 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 (can take values -1,0,1,2...). 
                    -1 corresponds to no padding, 0 corresponds to padding
                    to the next highest power of 2 etc.
                       e.g. For N = 500, if PAD = -1, we do not pad; if PAD = 0, we pad the FFT
                       to 512 points, if pad=1, we pad to 1024 points etc.
                       Defaults to 0.
           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.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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 (can take values -1,0,1,2...).
0014 %                    -1 corresponds to no padding, 0 corresponds to padding
0015 %                    to the next highest power of 2 etc.
0016 %                       e.g. For N = 500, if PAD = -1, we do not pad; if PAD = 0, we pad the FFT
0017 %                       to 512 points, if pad=1, we pad to 1024 points etc.
0018 %                       Defaults to 0.
0019 %           Fs   (sampling frequency) - optional. Default 1.
0020 %           fpass    (frequency band to be used in the calculation in the form
0021 %                                   [fmin fmax])- optional.
0022 %                                   Default all frequencies between 0 and Fs/2
0023 %           err  (error calculation [1 p] - Theoretical error bars; [2 p] - Jackknife error bars
0024 %                                   [0 p] or 0 - no error bars) - optional. Default 0.
0025 %           trialave (average over trials when 1, don't average when 0) - optional. Default 0
0026 % Outputs:
0027 % The fields listed above as well as the struct params. The fields are used
0028 % by some routines and the struct is used by others. Though returning both
0029 % involves overhead, it is a safer, simpler thing to do.
0030 if ~isfield(params,'tapers') || isempty(params.tapers); 
0031     params.tapers=[3 5];
0032 end;
0033 if ~isfield(params,'pad') || isempty(params.pad);
0034     params.pad=0;
0035 end;
0036 if ~isfield(params,'Fs') || isempty(params.Fs);
0037     params.Fs=1;
0038 end;
0039 if ~isfield(params,'fpass') || isempty(params.fpass);
0040     params.fpass=[0 params.Fs/2];
0041 end;
0042 if ~isfield(params,'err') || isempty(params.err);
0043     params.err=0;
0044 end;
0045 if ~isfield(params,'trialave') || isempty(params.trialave);
0046     params.trialave=0;
0047 end;
0048 
0049 tapers=params.tapers;
0050 pad=params.pad;
0051 Fs=params.Fs;
0052 fpass=params.fpass;
0053 err=params.err;
0054 trialave=params.trialave;

Generated on Mon 09-Oct-2006 00:54:52 by m2html © 2003