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: SumsOfSquares.m
    path of file: ./repos/fieldtrip/external/afni
    
    the code of the file until where you have to start completion: function [err, fstat, intensity_new, dfterm_new, dfdenom, tnames_new, LC] = SumsOfSquares(y, NF, FL, ntot, nterms, Qd, s, sindices, dfbothSS, modw, modwo, tnames, dfterm, dfe, dsgn, N_Brik, Contr)
%
%   [err,] = ss.m ()
%
%Purpose:
%
%
%
%Input Parameters:
%
%	 y: values from all factor combinations at one voxel in vector format
%   ntot: total number of files = length of vector y
%   tername: term names such as
%   termlist:
%   dmat: design matrix in the converted regression model
%   cmat: constraints matrix
%
%Output Parameters:
%   err : 0 No Problem
%       : 1  Problems
%   fstat: a vector of F values for those terms at a voxel
%   intensity_new: intensity for those terms at a voxel, which are defined as the sqare root of MS terms
%   dfterm: vector of degree of freedom for those terms (numerators) at each voxel (but the same for all voxels).
%           This is why I don't differentiate them among the voxels in anova.m
%   dfdenom: vector of denominator
%
%Key Terms:
%
%More Info :
%
%

    
function [err, fstat, intensity_new, dfterm_new, dfdenom, tnames_new, LC] = SumsOfSquares(y, NF, FL, ntot, nterms, Qd, s, sindices, dfbothSS, modw, modwo, tnames, dfterm, dfe, dsgn, N_Brik, Contr)
%
%   [err,] = ss.m ()
%
%Purpose:
%
%
%
%Input Parameters:
%
%	 y: values from all factor combinations at one voxel in vector format
%   ntot: total number of files = length of vector y
%   tername: term names such as
%   termlist:
%   dmat: design matrix in the converted regression model
%   cmat: constraints matrix
%
%Output Parameters:
%   err : 0 No Problem
%       : 1  Problems
%   fstat: a vector of F values for those terms at a voxel
%   intensity_new: intensity for those terms at a voxel, which are defined as the sqare root of MS terms
%   dfterm: vector of degree of freedom for those terms (numerators) at each voxel (but the same for all voxels).
%           This is why I don't differentiate them among the voxels in anova.m
%   dfdenom: vector of denominator
%
%Key Terms:
%
%More Info :
%
%
%
%
%     Author : Gang Chen
%     Date : Tue Mar 23 14:05:05 EST 2004
%     SSCC/NIMH/ National Institutes of Health, Bethesda MD 20892


%Define the function name for easy referencing
FuncName = 'ss.m';

%Debug Flag
DBG = 1;

%initailize return variables
err = 1;

dfboth = dfbothSS;
y0 = y;  % y gets mutated down below. Keep the original y so that the contrasts can be done later at the end