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: modelDiagnostics2.m
    path of file: ./repos/CanlabCore/CanlabCore/OptimizeDesign11/GA3/georges_tourtellot
    
    the code of the file until where you have to start completion: function M = modelDiagnostics2(finput,varargin)
% M = modelDiagnostics2(finput,optional arguments)

    
function M = modelDiagnostics2(finput,varargin)
% M = modelDiagnostics2(finput,optional arguments)
%
% M = modelDiagnostics2(stimList,'stimList','all','ISI',1.2,'TR',2,'contrasts',[1 1 -1 -1;1 -1 1 -1],'screen')
%
%M = 
%        stimlist: your original list of conditions
%           delta: delta matrix sampled at .01 seconds
%           model: model sampled at .01 seconds
%       modelatTR: model sampled at TR
%        smoothed: temporally smoothed model at TR
%        conmodel: predictors for contrasts
%       consmooth: temporally smoothed predictors for contrasts
%           power: power (abs(fft)) matrix for smoothed model
%        conPower: power matrix for smoothed contrasts
%          energy: sum of squared deviations from mean for each predictor
%       conEnergy: sum of squared deviations from mean for each contrast
%             eff: efficiency of design.  1/trace(xtxi)
%  resampleeffinf: efficiency loss due to resampling compared to TR = 1 s.  eff(TR=1) / eff(TR)
%    smootheffinf: loss of efficiency due to smoothing; eff(nosmooth) / eff(smooth)
%         varbeta: variance of each individual beta
%          coneff: efficiency of contrast set
%      convarbeta: efficiency of each contrast beta
%             vif: variance inflation factors for predictors
%          conVif: variance inflation factors for contrasts
%            cond: condition number of model; larger is worse, > 30 is bad
%         conCond: condition number for contrast set
%           colin: correlation coefficients between individual predictors
%        conColin: correlation coefficients between contrasts
%       cbalfreqs: counterbalancing frequencies up to 3rd order
%            freq: frequencies with which each stimulus type occurs
%
% options: inptType is 'stimList', 'sampledModel','plot' (plot only)
%          outptType is 'all', 'short'
%
%
% More examples:
% M = modelDiagnostics2(M.stimlist,'stimList','all','ISI',.85,'TR',2,'contrasts',[1 1 -1 -1],'screen')
% M2 = modelDiagnostics2(M,'plot')
%
% Tor Wager, 11/17/01

%------------------------------------------------------------------------------
% Set up arguments and default values
%------------------------------------------------------------------------------
print2screen = 1;
outptType = 'all';
isfilt = 'n';
doverb = 0;
xc = [];

for i = 1:length(varargin)
    if isstr(varargin{i})
        switch varargin{i}
        case 'ISI', ISI = varargin{i+1};
        case 'TR', TR = varargin{i+1};
        case 'HRF', HRF = varargin{i+1};
        case 'HPlength', HPlength = varargin{i+1};
        case 'LPsmooth',LPsmooth = varargin{i+1};
        case 'contrasts',contrasts = varargin{i+1};
		case 'saturate',satval = varargin{i+1};
		case 'contrastweights',contrastweights = varargin{i+1};
		case 'maxOrder',maxOrder = varargin{i+1};
		case 'xc',xc = varargin{i+1};
		case 'screen',print2screen = 1;
		case 'noplot',print2screen = 0;
		case 'brief',outptType = 'brief';
		case 'plot',outptType = 'plot';
		case 'verbose',doverb = 1;		
        end