Linear Algebra, Matrices (and why they matter to (f)MRI!) Methods for Dummies FIL October 2008 Nick Henriquez & Nick Wright Theory & Application Theory.

Slides:



Advertisements
Similar presentations
Matrix Algebra (and why it’s important!)
Advertisements

Matrix Algebra Matrix algebra is a means of expressing large numbers of calculations made upon ordered sets of numbers. Often referred to as Linear Algebra.
Matrix Algebra Matrix algebra is a means of expressing large numbers of calculations made upon ordered sets of numbers. Often referred to as Linear Algebra.
© 2005 Baylor University Slide 1 Fundamentals of Engineering Analysis EGR 1302 Unit 1, Lecture B Approximate Running Time - 24 minutes Distance Learning.
3_3 An Useful Overview of Matrix Algebra
MF-852 Financial Econometrics
Review of Matrix Algebra
GG313 Lecture 12 Matrix Operations Sept 29, 2005.
Ch 7.2: Review of Matrices For theoretical and computation reasons, we review results of matrix theory in this section and the next. A matrix A is an m.
1 Neural Nets Applications Vectors and Matrices. 2/27 Outline 1. Definition of Vectors 2. Operations on Vectors 3. Linear Dependence of Vectors 4. Definition.
MOHAMMAD IMRAN DEPARTMENT OF APPLIED SCIENCES JAHANGIRABAD EDUCATIONAL GROUP OF INSTITUTES.
Part 3 Chapter 8 Linear Algebraic Equations and Matrices PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The.
Methods for Dummies FIL January Jon Machtynger & Jen Marchant
Pam Perlich Urban Planning 5/6020
Linear regression models in matrix terms. The regression function in matrix terms.
Lecture 7: Matrix-Vector Product; Matrix of a Linear Transformation; Matrix-Matrix Product Sections 2.1, 2.2.1,
Intro to Matrices Don’t be scared….
Arithmetic Operations on Matrices. 1. Definition of Matrix 2. Column, Row and Square Matrix 3. Addition and Subtraction of Matrices 4. Multiplying Row.
Linear Algebra and Matrices Methods for Dummies 20 th October, 2010 Melaine Boly Christian Lambert.
A Fast Introduction inverse matrix1 What is a matrix (One Matrix many matrices) Why do they exist Matrix Terminology Elements Rows Columns Square.
Linear Algebra and Matrices
Copyright © Cengage Learning. All rights reserved. 7.6 The Inverse of a Square Matrix.
3.8 Matrices.
Modified Gary Larson Far Side cartoon
1 Chapter 3 Matrix Algebra with MATLAB Basic matrix definitions and operations were covered in Chapter 2. We will now consider how these operations are.
Matrix Algebra HGEN619 class Heuristic You already know a lot of it Economical and aesthetic Great for statistics.
1 Chapter 2 Matrices Matrices provide an orderly way of arranging values or functions to enhance the analysis of systems in a systematic manner. Their.
Chapter 7 Matrix Mathematics Matrix Operations Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Linear Algebra & Matrices MfD 2004 María Asunción Fernández Seara January 21 st, 2004 “The beginnings of matrices and determinants.
Linear Algebra and Matrices Methods for Dummies FIL November 2011 Narges Bazargani and Sarah Jensen Linear Algebra and Matrices Methods for Dummies FIL.
Chapter 10 Review: Matrix Algebra
Compiled By Raj G. Tiwari
ECON 1150 Matrix Operations Special Matrices
Matlab tutorial course Lesson 2: Arrays and data types
BIOL 582 Lecture Set 19 Matrices, Matrix calculations, Linear models using linear algebra.
Matrices And Linear Systems
Review of Matrices Or A Fast Introduction.
A rectangular array of numbers (we will concentrate on real numbers). A nxm matrix has ‘n’ rows and ‘m’ columns What is a matrix? First column First row.
Statistics and Linear Algebra (the real thing). Vector A vector is a rectangular arrangement of number in several rows and one column. A vector is denoted.
Fin500J Mathematical Foundations in Finance Topic 1: Matrix Algebra Philip H. Dybvig Reference: Mathematics for Economists, Carl Simon and Lawrence Blume,
Unit 6 : Matrices.
Unit 3: Matrices.
Matrix Multiplication The inner dimensions must be the same (or the number of columns in the first matrix is equal to the number of rows in the second.
Matrix Algebra and Regression a matrix is a rectangular array of elements m=#rows, n=#columns  m x n a single value is called a ‘scalar’ a single row.
Multivariate Statistics Matrix Algebra I W. M. van der Veld University of Amsterdam.
Linear algebra: matrix Eigen-value Problems Eng. Hassan S. Migdadi Part 1.
P1 RJM 06/08/02EG1C2 Engineering Maths: Matrix Algebra 1 EG1C2 Engineering Maths : Matrix Algebra Dr Richard Mitchell, Department of Cybernetics AimDescribe.
Examples of linear transformation matrices Some special cases of linear transformations of two-dimensional space R 2 are illuminating:dimensional Dimoffree.svgDimoffree.svg‎
Fundamentals of Engineering Analysis
ES 240: Scientific and Engineering Computation. Chapter 8 Chapter 8: Linear Algebraic Equations and Matrices Uchechukwu Ofoegbu Temple University.
Matrices and Matrix Operations. Matrices An m×n matrix A is a rectangular array of mn real numbers arranged in m horizontal rows and n vertical columns.
MATRIX A set of numbers arranged in rows and columns enclosed in round or square brackets is called a matrix. The order of a matrix gives the number of.
Matrix Algebra Methods for Dummies FIL November Mikkel Wallentin
Linear System of Simultaneous Equations Warm UP First precinct: 6 arrests last week equally divided between felonies and misdemeanors. Second precinct:
REGRESSION (CONTINUED) Matrices & Matrix Algebra; Multivariate Regression LECTURE 5 Supplementary Readings: Wilks, chapters 6; Bevington, P.R., Robinson,
Matrices. Matrix - a rectangular array of variables or constants in horizontal rows and vertical columns enclosed in brackets. Element - each value in.
Matrices. Variety of engineering problems lead to the need to solve systems of linear equations matrixcolumn vectors.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
College Algebra Chapter 6 Matrices and Determinants and Applications
MTH108 Business Math I Lecture 20.
Introduction What is a matrix (One Matrix many matrices)
Linear Algebraic Equations and Matrices
12-1 Organizing Data Using Matrices
Chapter 7 Matrix Mathematics
Linear Algebraic Equations and Matrices
MATRICES MATRIX OPERATIONS.
Lecture 11 Matrices and Linear Algebra with MATLAB
Dr Huw Owens Room B44 Sackville Street Building Telephone Number 65891
Inverse of a Matrix Solving simultaneous equations.
Linear Algebra and Matrices
Presentation transcript:

Linear Algebra, Matrices (and why they matter to (f)MRI!) Methods for Dummies FIL October 2008 Nick Henriquez & Nick Wright Theory & Application Theory & Application

Sources and further information   Previous FIL slides! YES we copied some....   SPM course   Web Guides – – – – (Formal Modelling in Cognitive Science course) – –

fMRI and Linear Algebra (fMRI) measures signal changes in the brain that are due to changing neural activity. brainneural Increases in neural activity cause changes in the MR signal via T2* changes; this mechanism is referred to as the BOLD (blood-oxygen-level dependent) effect.blood-oxygen-level dependent To estimate the MAGNITUDE of signal changes we need to measure MR INTENSITY levels for each “volumetric pixel”=VOXEL at various TIME POINTS. In SPM each VOXEL is observed/considered independently over time Any relationship between EXPERIMENT and VOXEL CHANGE is established using standard statistics Calculation and notation require Linear Algebra and MATRICES

Defining scalars, vectors and matrices   Scalar: Variable described by a single number – e.g. Image intensity (pixel value)  Vector: Variable described by magnitude and direction – e.g. pixel value+(relative) location  Matrix: Rectangular array of vectors defined by number of rows and columns – e.g. Intensities of several voxels or same voxel at different times Square (3 x 3)Rectangular (3 x 2) d r c : r th row, c th column 3 2 (Roman Catholic) V E V N Volumetric pixel (VOXEL) intensity is expressed as a VECTOR. The size (=> MAGNITUDE) is determined by its direction. V= V N V E

Matrices in Matlab   Vector formation: [1 2 3]   Matrix formation: X = [1 2 3; 4 5 6; 7 8 9] = Subscripting – each element of a matrix can be addressed with a pair of numbers; row first, column second (Roman Catholic) e.g. X(2,3) = 6 X(3, :) = X( [2 3], 2) = ‘;’ is used to signal end of a row ‘:’ is used to signify all rows or columns “Special” matrix commands: zeros(3,1) = ones(2) = magic(3) more to come…

Addition (matrix of same size) –Commutative: A+B=B+A –Associative: (A+B)+C=A+(B+C) Subtraction (consider as the addition of a negative matrix) Matrix addition

Matrix multiplication a 11 a 12 a 13 b 11 b 12 a 21 a 22 a 23 X b 21 b 22 a 31 a 32 a 33 b 31 b 32 a 41 a 42 a 43 Scalar multiplication: Multiplication of vectors/matrices: b 11 b 12 a 11 a 12 a 13 b 21 b 22 x a 21 a 22 a 23 b 31 b 32 a 31 a 32 a 33 a 41 a 42 a 43 Matrix multiplication rule: “When A is a mxn matrix & B is a kxl matrix, AB is only viable if n=k. The result will be an mxl matrix” nl m k

Sum over product of respective rows and columns For larger matrices, following method might be helpful: Multiplication method m l m l X= = = Define output matrix Sum over c rc Matlab does all this for you! Simply type: C = A * B N.B. If you want to do element-wise multiplication, use: A.* B rc

Defining the identity matrix   Is there a matrix which plays a similar role as the number 1 in number multiplication? Consider the nxn matrix: A square nxn matrix A has one A I n = I n A = A An nxm matrix A has two!! I n A = A & A I m = A X010= Worked example A In = A for a 3x3 matrix: In Matlab: eye(r, c) produces an r x c identity matrix

Inverse matrices   Definition. A matrix A is nonsingular or invertible if there exists a matrix B such that: worked example:  Common notation for the inverse of a matrix A is A -1  If A is an invertible matrix, then (A T ) -1 = (A -1 ) T  The inverse matrix A -1 is unique when it exists.  If A is invertible, A -1 is also invertible  A is the inverse matrix of A -1.11X = = In Matlab: A -1 = inv(A) Matrix division: A/B = AB -1

Determinants In Matlab: det(A) = det(A)  A matrix A has an inverse matrix A -1 if and only if det(A)≠0 (see next slide) The determinant of a 2×2 matrix is the product of the elements on the main diagonal minus the product of the elements off the main diagonal.

Calculation of inversion using determinants ax 1 = 1-cx 2 => x 1 = (1-cx 2 ) Etc. thus Note: det(A)≠0 Or you can just type inv(A) ! bx 1 +dx 2 =0 => b(1-cx 2 )/a = -dx 2

Transposition column → row row → column M rc = M cr In Matlab: A T = A’ T

Outer product = matrix Inner product = scalar Two vectors: Outer and inner products of vectors (1xn)(nx1)  (1X1) (nx1)(1xn)  (nXn)

Applications

Recap!   Why matrices? Lots of data and calculation   Why algebra? Allows you to find unknowns.   To do matrix algebra you need to use the matrix manipulations you’ve just learnt, e.g. – –Addition and subtraction – –Multiplicatione.g. Inner / outer – –“Division”e.g. Inverse – –“Powers”e.g. Transpose

Scalar and vector algebra   Algebra with scalars (“Normal school algebra”): e.g. y = x  – –Solve for  :  = y / xor  = y x -1   But our experiments get more data, which we want to represent vectors or matrices. We still want to do algebra with matrices. e.g. Y = X  – –Solve for  :  = X -1 Y   Examples of using matrix algebra to solve equations: – –Simultaneous equations with 2 unknowns and 2 equations – –Many equations and unknowns – real world GLM and fMRI

Example: Using matrices to solve simultaneous equations   A pair of simultaneous equations:   In matrix form   We want to rearrange to find the unknowns 0.4p + 0.2q = 4 0.6p + 0.8q = 11

  Need to find the inverse of A   Multiply both sides by A -1 of our first matrix by A -1   Get the answer! A = A -1 = = A -1 A = A -1 = = So… p = 5 and q = 10

Analysing data from one voxel   Getting the data as a vector of intensities Intensity at time 1 Intensity at time 2 Intensity at time 3 Time

  +  =  + YX data vector (Voxel) design matrix parameters error vector × = One voxel: The GLM Our aim: Solve equation for β – tells us how much BOLD signal is explained by X

Some matrix algebra   Initially can think of this as a system of simultaneous equations.   But, there are more equations (y = x  ) than unknowns (  )   So … clever maths e.g. Y = X  X T Y = X T X  (X T X) -1 X T Y =   = (XT X)-1 XT Y ^

  +  =  + YX data vector (Voxel) design matrix parameters error vector × = One voxel: The GLM Our aim: Solve equation for β – tells us how much BOLD signal is explained by X

Take home messages 1. 1.Matrices are at the core of SPM – it is how the data and design “matrix” are built and manipulated You need to be able to manipulate matrices to do matrix algebra and find unknowns – the basic results for the experiment! 3. 3.Simple example: use matrix algebra to solve 2 simultaneous equations with 2 unknowns Use matrix algebra to solve bigger problems, e.g. the GLM.

Thanks Justin. The End…