You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: ttest.m
    path of file: ./repos/fieldtrip/external/bayesFactor/+bf
    
    the code of the file until where you have to start completion: function [bf10,pValue,CI,stats] = ttest(X,varargin)
%TTEST One-sample and paired-sample t-test.
% function [bf10,p,CI,stats] = ttest(X,varargin)    - one sample
% function [bf10,p,CI,stats] = ttest(X,M,varargin)   -one sample,non-zero mean
%
% Calculates Bayes Factor for a one-sample or paired T-test.
%

    
function [bf10,pValue,CI,stats] = ttest(X,varargin)
%TTEST One-sample and paired-sample t-test.
% function [bf10,p,CI,stats] = ttest(X,varargin)    - one sample
% function [bf10,p,CI,stats] = ttest(X,M,varargin)   -one sample,non-zero mean
%
% Calculates Bayes Factor for a one-sample or paired T-test.
%
% X = single sample observations  (a column vector)
% Y = paired observations (column vector) or a scalar mean to compare the samples in X to.
%       [Defaults to 0]
%
% Optional Parm/Value pairs:
% alpha - significance level for the frequentist test. [0.05]
% tail - 'both','right', or 'left' for two or one-tailed tests [both]
% scale - Scale of the Cauchy prior on the effect size  [sqrt(2)/2]
% stats - A struct containing .tstat  , .df , .pvalue .tail and .N - This allows one to
%               calculate BF10 directly from the results of a standard T-Test output.
%
% OUTPUT
% bf10 - The Bayes Factor for the hypothesis that the mean is different
%           from zero
% p - p value of the frequentist hypothesis test
% CI    - Confidence interval for the true mean of X
% stats - Structure with .tstat, .df,
%
% BK - Nov 2018

if isnumeric(X)
    if mod(numel(varargin),2)==0
        % Only X specified
        Y = 0;
        parms = varargin;
    else
        % X and Y specified
        if numel(varargin)>1
            parms = varargin(2:end