function stat = statfun_parametric(cfg, dat, design)

% STATFUN_PARAMETRIC
%
% This function supports
%   cfg.ivar = number
%   cfg.type = string

% specify the defaults for the options
cfg.type = ft_getopt(cfg, 'type', 'Spearman');
cfg.ivar = ft_getopt(cfg, 'ivar', 1);

trialcode = design(cfg.ivar,:);

% [rho, pval] = corr(trialcode', dat', 'type', 'Spearman');
% [rho, pval] = corr(trialcode', dat', 'type', 'Pearson');
% [rho, pval] = corr(trialcode', dat', 'type', 'Kendall');

[rho, pval] = corr(trialcode', dat', 'type', cfg.type);

stat.stat = rho;  % this is sufficient for method=montecarlo
stat.prob = pval; % this is required   for method=analytic

