Skip to content

Code Standards and Protocols

David Tingley edited this page Jun 14, 2017 · 30 revisions

Functions in this toolbox should be named bz_FunctionName(), the bz_* indicates it is a function that is compatible with our Formatting Standards. When adding a function to the repository, please also add its name and a brief description to the respective Contents.txt file within that directory

ANALYSIS FUNCTION TYPES:
Detectors (i.e. bz_findRipples)
Workspace functions (i.e. bz_WaveSpec)
...

FORMATTING STANDARDS:

DEFAULT FILE HEADER (Documentation)

% USAGE

[outputs] = function(inputs)

% INPUTS

% x - is a variable

% y - is a string

% z - is logical

% OUTPUTS

% a - is a result

% b - isn't

% c - shows your result isn't significant

% HELP % Tips on how to use this function, other useful/related functions, etc.

All functions should be able to take variables from the workspace as inputs. Additionally, a switch/case can be used to pass a folder path (basepath) as the first argument and variables can be loaded from that folder. An example:

if isstr(varargin{1}) % if first arg is basepath ___addRequired(p,'basepath',@isstr) addRequired(p,'channel',@isnumeric) parse(p,varargin{:}) xmlfile = dir([p.Results.basepath '/*xml']); params = bzLoadParameters([p.Results.basepath '/' xmlfile.name]); lfp = bzLoadFLP(p.Results.channel); elseif isnumeric(varargin{1}) % if first arg is filtered LFP lfp = varargin{1}; end

Default input/output arguments:

INPUTS

  • 'basename' -base file name to load
  • 'basepath' -path to recording (where .dat/.clu/etc files are)
  • 'saveMat' - true/false that determines whether the function will save data/output into .mat files or just return outputs
  • 'overwrite' - true/false that determines whether the function will save over pre-existing .mat files from previous function calls
  • 'saveLocation' - path to where you would like output files saved
  • 'rejectChannels' - vector of 'bad' channels that you DO NOT want the function to use
  • 'channels' - vector of channels that you DO want the function to use/return

OUTPUTS