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: add_contrasts.m
    path of file: ./repos/bspm/thirdparty/spm12/toolbox/marsbar-0.44/@mardo
    
    the code of the file until where you have to start completion: function [D,Ic,changef] = add_contrasts(D, C, varargin)
% method to add contrast definitions to design
%
% The function has many different formats
%
% FORMAT [D Ic changef] = add_contrasts(D, D2 [,Ic])
%
% where D2 is a design. If there is no third argument, all the contrasts in
% D2 will be added.  If third argument (Ic) is passed, specifies which
% contrasts in D2 to add. If Ic passed, and empty, or contains the string
% 'ui', contrasts to add are fetched using the GUI
%
% OR
% FORMAT [D Ic changef] = add_contrasts(D, xCon)
%
% where xCon is a structure in SPM contrast format containing contrasts to
% add.  If there is no third argument, all the contrasts in xCon will be
% added.  If third argument (Ic) is passed, specifies which contrasts in xCon
% to add. If Ic passed, and empty, or contains the string 'ui', contrasts to
% add are fetched using the GUI
%

    
function [D,Ic,changef] = add_contrasts(D, C, varargin)
% method to add contrast definitions to design
%
% The function has many different formats
%
% FORMAT [D Ic changef] = add_contrasts(D, D2 [,Ic])
%
% where D2 is a design. If there is no third argument, all the contrasts in
% D2 will be added.  If third argument (Ic) is passed, specifies which
% contrasts in D2 to add. If Ic passed, and empty, or contains the string
% 'ui', contrasts to add are fetched using the GUI
%
% OR
% FORMAT [D Ic changef] = add_contrasts(D, xCon)
%
% where xCon is a structure in SPM contrast format containing contrasts to
% add.  If there is no third argument, all the contrasts in xCon will be
% added.  If third argument (Ic) is passed, specifies which contrasts in xCon
% to add. If Ic passed, and empty, or contains the string 'ui', contrasts to
% add are fetched using the GUI
%
% OR
% FORMAT [D Ic changef] = add_contrasts(D, stat_struct)
% where stat_struct has fields
%      'names',       string, or cell array of strings
%      'types',       string ('T' or 'F'), or cell array
%      'set_actions', string ('c', 'X0' or 'iX0') or array
%                     (see spm_FcUtil)
%                     (field is optional, defaults to 'c')
%      'values',      matrix of values
%
% OR
% FORMAT [D Ic changef] = add_contrasts(D, names, types, values)
% where names, types, values are cell arrays of values, or values
% (defined as above)
%
% OR
% FORMAT [D Ic  changef] = add_contrasts(D, names, types, set_actions, values)
% where names, types, set_actions, values are cell arrays of values, or
% values (defined as above)
%
% Returns
% D       - possibly modified SPM design
% Ic      - indices of specified contrasts as stored in D
% changef - 1 if D has changed during call else 0
%
% Contrast will not be added if it is already present, but the correct
% index will be returned in Ic
%
% $Id$

if nargin < 2
  error('Need contrasts to add');
end