function [stat] = timelockstatistics(cfg, varargin)

% TIMELOCKSTATISTICS computes probabilities for a given hypothesis
% using the general linear model or using a non-parametric randomization
% approach for the statistics.
%
% Use as
%   [stat] = timelockstatistics(cfg, timelock1, timelock2, ...)
% where the input data is the result from either TIMELOCKANALYSIS or
% TIMELOCKGRANDAVERAGE.
%
% The configuration can contain the following options for data selection
%   cfg.channel            = cell-array of size Nx1, see CHANNELSELECTION
%   cfg.latency            = [begin end], can be 'all' (default)
%   cfg.avgoverchan        = 'yes' or 'no' (default)
%   cfg.avgovertime        = 'yes' or 'no' (default)
%
% The configuration should contain the following options for the statistics
%   cfg.approach           = string, see below
%   cfg.method             = string, see below
%
% There are two options that you have to specify for the statistical test,
% the "approach" and the "method". The approach determines which statistical
% back-end is used, the method determines which specific statiistical test
% is performed. The statistical approach XXX is described in detail in
% the function STATISTICS_XXX. The only approach that is currently fully
% supported is STATS, which uses the Matlab Statistics toolbox. Other
% approaches will become available in the near future.
%
% The different methods (e.g. ttest, anova) that are available depend
% on the general approach. See the help of STATISTICS_XXX for more details,
% where XXX should be replaced by the approach that you want to take.
%
% See also TIMELOCKANALYSIS, TIMELOCKGRANDAVERAGE

% Copyright (C) 2005, Robert Oostenveld
%
% $Log: timelockstatistics.m,v $
% Revision 1.12  2005/06/17 10:58:49  roboos
% made backward compatibility test optional, depending on presence of cfg.method
%
% Revision 1.11  2005/05/17 17:50:40  roboos
% changed all "if" occurences of & and | into && and ||
% this makes the code more compatible with Octave and also seems to be in closer correspondence with Matlab documentation on shortcircuited evaluation of sequential boolean constructs
%
% Revision 1.10  2005/04/07 17:12:21  roboos
% improved the general help documentation, no code changes
%
% Revision 1.9  2005/04/06 14:29:41  roboos
% added copyrights and a log message placeholder
%

% this is a completely new implementation that is not compatible with the first 
% implementation by Jens Schwartzbach -> catch the old options
if isfield(cfg, 'method')
  if strcmp(cfg.method, 'ttest_samples_vs_const')    || ...
     strcmp(cfg.method, 'ttest_window_avg_vs_const') || ...
     strcmp(cfg.method, 'ttest_2samples_by_timepoint')
    error(sprintf('method %s is not supported any more', cfg.method))
  end
end

% call the general function
[stat] = statistics_wrapper(cfg, varargin{:});
