Diff for "TestPage" - MRC CBU Imaging Wiki
location: Diff for "TestPage"
Differences between revisions 8 and 9
Revision 8 as of 2006-08-11 14:14:16
Size: 4984
Editor: devel03
Comment:
Revision 9 as of 2006-08-11 14:50:17
Size: 49
Editor: devel03
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Which, because cv(j) is always 1, is exactly the same as:

Y(j) = beta * x(j) + c + E(j)

i.e. our original model.

Now we can rephrase our model in terms of matrices:

'''Y''' = '''X''' * '''B''' + '''E'''

(note that '''Y''', '''X''', '''B''' and '''E''', the matrices, are now in '''bold''')

Where '''Y''' is the data matrix:

||<tablewidth="60px"^ bgcolor="#FFFFFF" height="18px">57.84||
||<^ bgcolor="#FFFFFF" height="18px">57.58||
||<^ bgcolor="#FFFFFF" height="18px">57.14||
||<^ bgcolor="#FFFFFF" height="18px">55.15||
||<^ bgcolor="#FFFFFF" height="18px">55.90||
||<^ bgcolor="#FFFFFF" height="18px">55.67||
||<^ bgcolor="#FFFFFF" height="18px">58.14||
||<^ bgcolor="#FFFFFF" height="18px">55.82||
||<^ bgcolor="#FFFFFF" height="18px">55.10||
||<^ bgcolor="#FFFFFF" height="18px">58.65||
||<^ bgcolor="#FFFFFF" height="18px">56.89||
||<^ bgcolor="#FFFFFF" height="18px">55.69||
'''X''' is the design matrix:

||<tablewidth="134px"^ 46% bgcolor="#FFFFFF" height="18px">5||<^ 55% bgcolor="#FFFFFF" height="18px">1||
||<^ 46% bgcolor="#FFFFFF" height="18px">4||<^ 55% bgcolor="#FFFFFF" height="18px">1||
||<^ 46% bgcolor="#FFFFFF" height="18px">4||<^ 55% bgcolor="#FFFFFF" height="18px">1||
||<^ 46% bgcolor="#FFFFFF" height="18px">2||<^ 55% bgcolor="#FFFFFF" height="18px">1||
||<^ 46% bgcolor="#FFFFFF" height="18px">3||<^ 55% bgcolor="#FFFFFF" height="18px">1||
||<^ 46% bgcolor="#FFFFFF" height="18px">1||<^ 55% bgcolor="#FFFFFF" height="18px">1||
||<^ 46% bgcolor="#FFFFFF" height="18px">6||<^ 55% bgcolor="#FFFFFF" height="18px">1||
||<^ 46% bgcolor="#FFFFFF" height="18px">3||<^ 55% bgcolor="#FFFFFF" height="18px">1||
||<^ 46% bgcolor="#FFFFFF" height="18px">1||<^ 55% bgcolor="#FFFFFF" height="18px">1||
||<^ 46% bgcolor="#FFFFFF" height="18px">6||<^ 55% bgcolor="#FFFFFF" height="18px">1||
||<^ 46% bgcolor="#FFFFFF" height="18px">5||<^ 55% bgcolor="#FFFFFF" height="18px">1||
||<^ 46% bgcolor="#FFFFFF" height="18px">2||<^ 55% bgcolor="#FFFFFF" height="18px">1||
'''B''' is the parameter matrix:

||<tablewidth="60px"^ bgcolor="#FFFFFF" height="18px">Beta||
||<^ bgcolor="#FFFFFF" height="18px">C||
And '''E''' is the error matrix, with one column and 12 rows:

||<tablewidth="210px"107% bgcolor="#FFFFFF">remaining error for scan 1 ||
||<107% bgcolor="#FFFFFF">remaining error for scan 2 ||
||<107% bgcolor="#FFFFFF">... ||
||<107% bgcolor="#FFFFFF">remaining error for scan 12 ||
This design matrix is precisely the design matrix used by SPM. As you can see from the analysis printouts, SPM displays this design matrix to you graphically, scaling each column so that the most negative number in the column will be nearest to black, and the most positive will be nearest to white. For example, the first column in the design matrix above varies from one to six. In the SPM display for this design matrix, for the first column, ones will be shown as black, sixes as white, and the rest as intermediate greys. The design matrix above will therefore look like the figure below. As you would expect, in the first column of the picture, the sixth and ninth rows in the picture are black, corresponding to the ones in the design matrix, and rows seven and ten are white corresponding to the sixes in the design matrix.

[[ImageLink(http://imaging.mrc-cbu.cam.ac.uk/images/st_dm1.gif,http://imaging.mrc-cbu.cam.ac.uk/pdfs/st_figures.pdf,alt=Click here to view figures in pdf format)]]

Because of the way matrix multiplication works, our matrix model ('''Y'''='''X'''*'''B'''+'''E''') is mathematically the same as our previous version of the formula, i.e.:

Y(j) = beta * x(j) + c + E(j)

Thus the top row of '''Y''' (Y(1)) is:

x(1)* beta + cv(1) * c + E(1) ( = 5 * beta + c + error-for-scan-1),

the second row of '''Y''' is:

x(2)* beta + cv(2) * c + E(2) ( = 4 * beta + C + error-for-scan-2),

and so on.

The matrix formulation makes it very easy to find our least square fit for the line. It can be performed in one line of matlab code:

{{{
B = inv(X)*Y
}}}

where

{{{
inv(X)
}}}

is the inverse of the design matrix. Please see Andrew Holmes' chapter in the SPM course notes for the derivation of the maths. We now have a matrix'''B'''that contains the least squares estimates of our parameters:

||<tablewidth="60px"^ bgcolor="#FFFFFF" height="18px">0.64||
||<^ bgcolor="#FFFFFF" height="18px">54.39||

where the first element of '''B''', 0.64, is the slope of the line, beta, and the second element of '''B''', 54.39, is the y intercept, c.

Below is a plot of the data with the least squares fitting line:

[[ImageLink(http://imaging.mrc-cbu.cam.ac.uk/images/st_bestplot.gif,http://imaging.mrc-cbu.cam.ac.uk/pdfs/st_figures.pdf,alt=Click here to view figures in pdf format)]]

We can work out the remaining errors E by:

'''E''' = '''Y''' - '''X''' * '''B'''

which is the same as saying

E(1) = Y(1) - beta * x(1) + c,

E(2) = Y(2) - beta * x(2) + c, etc.
[[latex(\usepackage{dsfont} % $$\mathds{C}$$)]]

CbuImaging: TestPage (last edited 2013-03-07 21:24:04 by localhost)