Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


SumsOfSquares.m File Reference

Go to the source code of this file.


Functions

 SS (Error)
get its residual SS and d f ssw (1:nterms)
end if dfboth (k0)~
 ssw (k)
 sswo (k)
 ssterm (dfterm==0)=0
 C (A)
 BC (A) ssterm(3)
 SSC (A)
 SSBC (A)
 CD (ABC)
 ssterm (4)
 SSD (A)
 DF (D(A))
 SSBD (A)
 DF (BD(A))
 SSCD (A)
 DF (CD(A))
 SSBCD (A)
 DF (BCD(A))
 DF (D(AB))
 DF (CD(AB))
id terms: (A)
 DE (ABC)
 ABDE (ACDE)
only terms ssterm (5)
 SSE (A)
 DF (E(A))
 SSBE (A)
 DF (BE(A))
 SSCE (A)
 DF (CE(A))
 SSDE (A)
 DF (DE(A))
 SSBCE (A)
 DF (BCE(A))
 SSBDE (A)
 DF (BDE(A))
 SSCDE (A)
 DF (CDE(A))
 SSBCDE (A)
 DF (BCDE(A))
Throw out those four which
do not exist for 
intensity (6)]
 tnames (6)]
dfe ()
 tnames (8:11)
 tnames (14)]
 tnames (8)
 tnames (10:11)]
denominator dfterm (4)
denominator dfterm (10)
 tnames (10:17)
 tnames (19)
 tnames (22:26)
 tnames (30)]
Only calculate it when denominator
is greater than 
fstat (t)
assign this so that output
argument LC would not be empty
else 
if (NF==1)
 if (tmp > 0)
LC t1 (i).t
end end end Get t values for
contrast 
tests (B)
ABC for (i=1:1:Contr.ord2.tot)
ABC LC t2 (i).t=0 = LC.t2(i).value/sqrt(tmp)
initializtion in case it is
assigned later on due to denominator
of switch Contr ord2 
cnt (i).idx1 case 1
A BXC: (dsgn==3|dsgn==4 msdenom)
MSBC else fprintf ('\nSomething is wrong in the contrast coding!\n')
 fprintf (2,'Halted:Ctrl+c to exit')
end end end if (Contr.ord2.tot > 0)
end end end dmat (:, num_col0+num_col1+1:num_col1+num_col0+num_col2) is the matrix for 2nd order contrasts if(Contr.ord3.tot > 0)
end end end LC t3 (i).t=0 = Contr.ord3.cnt(i).vec * y0
initializtion in case it is
assigned later on due to denominator
of switch Contr ord3 switch
Contr ord3 
if (Contr.ord3.cnt(i).idx3==3)
end end end end If (NF==3) if(NF
Less likely each term of this
contrast 
LC2 (i).value = LC2(i).value + Contr2.cnt(i).coef(j) * dmat(:, Contr2.cnt(i).code(j).pos)' * y0
initializtion in case it is
assigned later on due to denominator
of 
if (dsgn==3)
MSABD not exist for (dsgn==3|dsgn==4|dsgn==5) end case 3
end end end Get t values for
contrast tests within each 
factor (B)
 elseif (dsgn==3) what
end end LC t4 (i).t=0 = LC.t4(i).value/sqrt(tmp)
MSABCE end switch Contr ord4 if (Contr.ord4.cnt(i).idx4==5)

Variables

 function [err, fstat, intensity_new, dfterm_new, dfdenom, tnames_new, LC]
which are defined as the sqare
root of MS terms 
dfterm
which are defined as the sqare
root of MS terms Bethesda
MD 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 Fit the full
model and compute the residual
sum of squares 
mu = mean(y)
 y = y - mu
two passes to improve accuracy mu2 = mean(y)
 sst = sum(y.^2)
 SSTO [ssx, y] = dofit(y, Qd)
y __pad3__
ssx __pad4__
for full model we already
know the results for 
j
Look in unsorted arrays to
see if we have already fit
this model if j nterms 
k0 = k+nterms
else thismod = modw(k, :)
end Fit this model [ssx0, dfx0] = QRfit(X, y, C)
 ssx0 = dofit(y, s(j).Qdt)
Use these results for each
term that requires them 
mod0 = repmat(thismod, nterms, 1)
 k = find(all(modw == mod0, 2))
end clear mod0 Compute the
sum of squares attributed
to each term 
ssterm = ssw - sswo
make this exact
make this fstat = repmat(0, size(ssterm))
only ss term
 case
terms __pad5__
 B
 C
 AB
 AC
 BC
end switch dsgn switch dsgn
Order of the 
terms
 D
 AD
 BD
 ABD
 ACD
 BCD
and ABCD
 CD
 ABC
 E
 AE
 BE
 CE
 ABE
 ACE
 ADE
 BCE
 BDE
 CDE
 ABCE
 BCDE
end switch dsgn end switch
NF Compute the mean square
for each term 
msterm = ssterm ./ max(1, dfterm')
 mse = sse * (dfe>0) / max(1, dfe)
 intensity = sqrt(msterm)
Intensity for each term Equated
computed and expected mean 
squares
Intensity for each term Equated
computed and expected mean
then solve for variance component
estimates switch NF 
dfterm_new = dfterm
 tnames_new = tnames
 msterm_new = msterm
 intensity_new = intensity
 msdenom = repmat(mse, size(msterm))
 dfdenom = repmat(dfe, size(msterm))
terms __pad6__
terms __pad7__
Throw out those four which
do not exist for 
nesting
terms __pad8__
denominator MS
denominator dfe
denominator DF end end Close
swtich NF Compute an F statistic
for each term 
t = (msdenom>0)
 LC = 0
assign this so that output
argument LC would not be empty
else Get t values for contrast
tests within each factor(1st order)%dmat(initializtion
in case it is assigned later
on due to denominator of LC 
t1 (i).value = Contr.ord1.cnt(i).vec * y0
intensity for this st order
contrast 
tmp = msdenom(Contr.ord1.cnt(i).idx1)*Contr.ord1.cnt(i).scalar
initializtion in case it is
assigned later on due to denominator
of switch Contr ord2 switch
Contr ord2 
what = msdenom(4)
 pause
Less likely to occur
 scalar = scalar + Contr2.cnt(i).coef(j) * Contr2.cnt(i).coef(j)
 return

Function Documentation

ABDE ACDE   ) 
 

BC A   ) 
 

A BXC: dsgn  = =3|dsgn==4 msdenom  )  [virtual]
 

C A   ) 
 

CD ABC   ) 
 

initializtion in case it is assigned later on due to denominator of switch Contr ord2 cnt  ) 
 

DE ABC   ) 
 

DF BCDE(A  ) 
 

DF CDE(A  ) 
 

DF BDE(A  ) 
 

DF BCE(A  ) 
 

DF DE(A  ) 
 

DF CE(A  ) 
 

DF BE(A  ) 
 

DF E(A  ) 
 

DF CD(AB  ) 
 

DF D(AB  ) 
 

DF BCD(A  ) 
 

DF CD(A  ) 
 

DF BD(A  ) 
 

DF D(A  ) 
 

end if dfboth k0   ) 
 

6 dfe  )  [virtual]
 

denominator dfterm 10   ) 
 

denominator dfterm  ) 
 

end end end dmat ,
num_col0+num_col1+1:num_col1+num_col0 num_col2
 

elseif dsgn  = =3  ) 
 

end end end Get t values for contrast tests within each factor B   ) 
 

Referenced by adjust_endpts(), assign_afni_floats(), attach_sub_brick(), basis_write_iresp(), basis_write_sresp(), calculate_acontrasts(), calculate_adifferences(), calculate_ameans(), calculate_bcontrasts(), calculate_bdifferences(), calculate_bmeans(), check_for_valid_inputs(), DepthCueSlice(), display_coords(), mask_all_shorts_to_float(), mask_shorts_to_float(), mri_to_mri_scl(), process_as_floats(), process_subbrick(), qh_voronoi_center(), r_set_afni_s_from_dset(), rfft(), thd_mask_from_brick(), v2s_adjust_endpts(), write_3dtime(), write_bucket_data(), and write_ts_array().

MSABD not exist for dsgn  = = 3 | dsgn == 4 | dsgn == 5  ) 
 

ABC for = 1:1:Contr.ord2.tot  ) 
 

fprintf ,
'Halted:Ctrl+c to exit' 
 

MSBC else fprintf '\nSomething is wrong in the contrast coding!\n  ) 
 

Only calculate it when denominator is greater than fstat  ) 
 

MSABCE end switch Contr ord4 if Contr.ord4.cnt(i).  idx4 = = 5  ) 
 

initializtion in case it is assigned later on due to denominator of if dsgn  = = 3  ) 
 

end end end end If NF  = =3  ) 
 

initializtion in case it is assigned later on due to denominator of switch Contr ord3 switch Contr ord3 if Contr.ord3.cnt(i).  idx3 = = 3  ) 
 

end end end if Contr.ord2.  tot,
 

if tmp  ,
 

assign this so that output argument LC would not be empty else if NF  = = 1  ) 
 

Throw out those four which do not exist for intensity  ) 
 

Less likely each term of this contrast LC2  )  = LC2(i).value + Contr2.cnt(i).coef(j) * dmat(:, Contr2.cnt(i).code(j).pos)' * y0
 

SS Error   ) 
 

SSBC A   ) 
 

SSBCD A   ) 
 

SSBCDE A   ) 
 

SSBCE A   ) 
 

SSBD A   ) 
 

SSBDE A   ) 
 

SSBE A   ) 
 

SSC A   ) 
 

SSCD A   ) 
 

Initial value:

 SSCD + SSACD + SSBCD + SSABCD
            dfterm(10) = dfterm(10) + dfterm(13) + dfterm(14) + dfterm(15)

SSCDE A   ) 
 

SSCE A   ) 
 

SSD A   ) 
 

Initial value:

 SSD + SSAD + SSBD + SSABD
            dfterm(4) = dfterm(4) + dfterm(7) + dfterm(9) + dfterm(12)

SSDE A   ) 
 

SSE A   ) 
 

Referenced by calculate_sse().

only terms ssterm  ) 
 

ssterm  ) 
 

ssterm dfterm  = =0  )  [pure virtual]
 

ssw  ) 
 

get its residual SS and d f ssw 1:nterms   ) 
 

sswo  ) 
 

LC t1  ) 
 

LC t2  )  = LC.t2(i).value/sqrt(tmp) [pure virtual]
 

Referenced by add_quats(), alnrel(), basis_block_hrf4(), basis_block_hrf5(), bgrat(), bisect_(), calc_glt_matrix(), cx_scramble(), dln1px(), fft128(), fft256(), fft512(), fft64(), fft_3dec(), fft_4dec(), get_quadratic_trend(), idct_col(), idct_row(), InvertSym3(), maxtype(), median_float4(), PERMTEST_compute(), putpower(), qzvec_(), stas4(), SUMA_Find_IminImax(), SUMA_FindVoxelsInSurface(), SUMA_FindVoxelsInSurface_SLOW(), SUMA_isinbox(), SUMA_isinsphere(), SUMA_isSelfIntersect(), SUMA_StretchToFitLeCerveau(), THD_cubic_detrend(), tridib_(), tsturm_(), and UTL_SqueezeBlanks().

LC t3  )  = Contr.ord3.cnt(i).vec * y0 [pure virtual]
 

Referenced by add_quats(), basis_block_hrf5(), ComputeD0(), get_linear_trend(), get_quadratic_trend(), idct_col(), idct_row(), median_float4(), shear_xzyx(), and SUMA_GetM2M_NN().

LC t4  )  = LC.t4(i).value/sqrt(tmp) [pure virtual]
 

Referenced by basis_block_hrf4(), basis_block_hrf5(), fft_3dec(), get_quadratic_trend(), InvertSym3(), shear_xzyx(), and stinv().

id terms: A   )  [virtual]
 

end end end Get t values for contrast tests B   ) 
 

tnames 30   ) 
 

tnames 22:26   ) 
 

tnames 19   ) 
 

tnames 10:17   ) 
 

tnames 10:11   ) 
 

tnames  ) 
 

tnames 14   ) 
 

tnames 8:11   ) 
 

tnames  ) 
 


Variable Documentation

y __pad3__
 

Definition at line 59 of file SumsOfSquares.m.

ssx __pad4__
 

Definition at line 60 of file SumsOfSquares.m.

terms __pad5__
 

Definition at line 123 of file SumsOfSquares.m.

terms __pad6__
 

Definition at line 248 of file SumsOfSquares.m.

terms __pad7__
 

Definition at line 253 of file SumsOfSquares.m.

terms __pad8__
 

Definition at line 261 of file SumsOfSquares.m.

AB
 

Definition at line 557 of file SumsOfSquares.m.

ABC
 

Definition at line 281 of file SumsOfSquares.m.

denominator DF only terms in nesting case without BCD and ABCD
 

Definition at line 295 of file SumsOfSquares.m.

ABCE
 

Definition at line 559 of file SumsOfSquares.m.

ABD
 

Definition at line 558 of file SumsOfSquares.m.

ABE
 

Definition at line 558 of file SumsOfSquares.m.

AC
 

Definition at line 557 of file SumsOfSquares.m.

Throw out those four which do not exist for ACD
 

Definition at line 296 of file SumsOfSquares.m.

ACE
 

Definition at line 558 of file SumsOfSquares.m.

AD
 

Definition at line 557 of file SumsOfSquares.m.

ADE
 

Definition at line 558 of file SumsOfSquares.m.

AE
 

Definition at line 557 of file SumsOfSquares.m.

B
 

Definition at line 306 of file SumsOfSquares.m.

BC
 

Definition at line 558 of file SumsOfSquares.m.

BCD
 

Definition at line 559 of file SumsOfSquares.m.

BCDE
 

Definition at line 559 of file SumsOfSquares.m.

BCE
 

Definition at line 559 of file SumsOfSquares.m.

BD
 

Definition at line 558 of file SumsOfSquares.m.

BDE
 

Definition at line 559 of file SumsOfSquares.m.

BE
 

Definition at line 558 of file SumsOfSquares.m.

C
 

Definition at line 557 of file SumsOfSquares.m.

end case
 

Definition at line 739 of file SumsOfSquares.m.

CD
 

CDE
 

Definition at line 559 of file SumsOfSquares.m.

CE
 

Definition at line 558 of file SumsOfSquares.m.

Referenced by SUMA_GetContour(), and SUMA_Pattie_Volume().

D
 

Definition at line 557 of file SumsOfSquares.m.

Debug Flag DBG = 1
 

Definition at line 43 of file SumsOfSquares.m.

dfboth = dfbothSS
 

Definition at line 48 of file SumsOfSquares.m.

denominator MS dfdenom = repmat(dfe, size(msterm))
 

Definition at line 294 of file SumsOfSquares.m.

denominator dfe
 

Definition at line 302 of file SumsOfSquares.m.

which are defined as the sqare root of MS terms dfterm
 

Definition at line 1 of file SumsOfSquares.m.

terms dfterm_new = dfterm
 

Definition at line 313 of file SumsOfSquares.m.

E
 

Definition at line 557 of file SumsOfSquares.m.

initailize return variables err = 1
 

Definition at line 46 of file SumsOfSquares.m.

make this exact
 

Initial value:

=======================================================
% !!!The ones for dfterm are the same for all voxles: is there a way to move them out of this routine?
% Also the switches should stay in PreProc.m instead of being here!
%=========================================================

switch NF
   case 1

Definition at line 106 of file SumsOfSquares.m.

Referenced by _getopt_internal().

fstat = repmat(0, size(ssterm))
 

Definition at line 134 of file SumsOfSquares.m.

which are defined as the sqare root of MS terms Bethesda MD Define the function name for easy referencing FuncName = 'ss.m'
 

Definition at line 40 of file SumsOfSquares.m.

function[err, fstat, intensity_new, dfterm_new, dfdenom, tnames_new, LC]
 

Initial value:

 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

Definition at line 1 of file SumsOfSquares.m.

intensity = sqrt(msterm)
 

Definition at line 216 of file SumsOfSquares.m.

Throw out those four which do not exist for BCD and ABCD intensity_new = intensity
 

Definition at line 297 of file SumsOfSquares.m.

for full model we already know the results for j
 

Initial value:

length(sindices):-1:1
   % Find the next model index to fit
   k = sindices(j)

Definition at line 65 of file SumsOfSquares.m.

k = find(all(modw == mod0, 2))
 

Definition at line 95 of file SumsOfSquares.m.

else k0 = k+nterms
 

Definition at line 73 of file SumsOfSquares.m.

LC = 0
 

Definition at line 353 of file SumsOfSquares.m.

Use these results for each term that requires them mod0 = repmat(thismod, nterms, 1)
 

Definition at line 92 of file SumsOfSquares.m.

end Fit this model[ssx0, dfx0] = QRfit(X, y, C)
 

Definition at line 88 of file SumsOfSquares.m.

denominator MS
 

Definition at line 302 of file SumsOfSquares.m.

Only preserve those valid for nesting Semicolon for coloumn catenation msdenom = repmat(mse, size(msterm))
 

Definition at line 300 of file SumsOfSquares.m.

mse = sse * (dfe>0) / max(1, dfe)
 

Definition at line 215 of file SumsOfSquares.m.

Referenced by basis_write_sresp(), calc_tcoef(), CalcDistortion(), calculate_f_statistic(), calculate_results(), evaluate_irc(), regression_analysis(), report_results(), and save_voxel().

end switch dsgn end switch NF Compute the mean square for each term msterm = ssterm ./ max(1, dfterm')
 

Definition at line 214 of file SumsOfSquares.m.

denominator DF terms msterm_new = msterm
 

Definition at line 331 of file SumsOfSquares.m.

mu = mean(y)
 

Definition at line 55 of file SumsOfSquares.m.

Referenced by brcmp1(), bup(), chfit(), ComputeD0(), esum(), main(), mri_watershedize(), rand_binormal(), rand_normal(), and SUMA_Taubin_Smooth().

two passes to improve accuracy mu2 = mean(y)
 

Definition at line 54 of file SumsOfSquares.m.

Throw out those four which do not exist for nesting
 

Definition at line 296 of file SumsOfSquares.m.

Less likely occur
 

Definition at line 592 of file SumsOfSquares.m.

pause
 

Definition at line 747 of file SumsOfSquares.m.

return
 

Definition at line 761 of file SumsOfSquares.m.

scalar = scalar + Contr2.cnt(i).coef(j) * Contr2.cnt(i).coef(j)
 

Definition at line 594 of file SumsOfSquares.m.

Referenced by vpClassifyScalars(), vpVolumeNormals(), and x_rsne().

Intensity for each term Equated computed and expected mean squares
 

Definition at line 218 of file SumsOfSquares.m.

sst = sum(y.^2)
 

Definition at line 57 of file SumsOfSquares.m.

ABC ssterm = ssw - sswo
 

SSTO[ssx, y] = dofit(y, Qd)
 

Definition at line 59 of file SumsOfSquares.m.

ssx0 = dofit(y, s(j).Qdt)
 

Definition at line 89 of file SumsOfSquares.m.

denominator DF end end Close swtich NF Compute an F statistic for each term t = (msdenom>0)
 

Definition at line 347 of file SumsOfSquares.m.

LC t1 = Contr.ord1.cnt(i).vec * y0
 

Referenced by add_quats(), basis_block_hrf4(), basym(), bisect_(), calc_glt_matrix(), ComputeD0(), cx_scramble(), fft128(), fft256(), fft512(), fft64(), fft_3dec(), fft_4dec(), get_linear_trend(), get_quadratic_trend(), gratio(), idct_col(), idct_row(), Inline(), maxtype(), median_float4(), putcall(), putpower(), qzvec_(), rcomp(), shear_xzyx(), stas4(), SUMA_FindVoxelsInSurface(), SUMA_FindVoxelsInSurface_SLOW(), SUMA_isinbox(), SUMA_isinsphere(), SUMA_isSelfIntersect(), THD_cubic_detrend(), tridib_(), tsturm_(), UTL_SqueezeBlanks(), VPCompAC00G(), VPCompAC11B(), VPCompAC1NB(), VPCompAC1NS(), VPCompAC1PB(), VPCompAC31B(), VPCompAC32B(), VPCompAC3NB(), VPCompAC3NS(), VPCompAC3PB(), VPCompAR00G(), VPCompAR11B(), VPCompAR1NB(), VPCompAR1NS(), VPCompAR1PB(), VPCompAR31B(), VPCompAR32B(), VPCompAR3NB(), VPCompAR3NS(), VPCompAR3PB(), VPRenderAffine(), and vpShadeTable().

only ss term
 

Definition at line 115 of file SumsOfSquares.m.

totally terms
 

Definition at line 227 of file SumsOfSquares.m.

else thismod = modw(k, :)
 

Definition at line 83 of file SumsOfSquares.m.

intensity for this rd order contrast tmp = msdenom(Contr.ord1.cnt(i).idx1)*Contr.ord1.cnt(i).scalar
 

Definition at line 750 of file SumsOfSquares.m.

tnames_new = tnames
 

Definition at line 334 of file SumsOfSquares.m.

end what = msdenom(4)
 

Definition at line 736 of file SumsOfSquares.m.

Referenced by clf(), putmnmx(), SUMA_FormSwitchColMenuVector(), SUMA_InitRangeTable(), and wanted().

THIS CAN BE DELETED FOR MY CASE since it is not used from this point y = y - mu
 

Definition at line 56 of file SumsOfSquares.m.

y0 = y
 

Definition at line 49 of file SumsOfSquares.m.

Referenced by bratio(), brcmp1(), brcomp(), ClassifyRawVolume(), ComputeOctreeMask(), dbesy0_(), drawBox(), ExtractClassifiedVolume(), ExtractRawVolume(), mri_drawline(), plx_TXT(), pointclip(), POWER_main(), ppmd_circle(), ppmd_line(), ppmd_polyspline(), ppmd_spline3(), ShadeRawVolume(), SUMA_DrawWindowLine(), VPClassifyBlock(), vpExtract(), and VPShadeBlock().

 

Powered by Plone

This site conforms to the following standards: