24
Introduction to MATLAB for Neuroimaging KRISANNE LITINAS UM FMRI LABORATORY

Introduction to MATLAB for Neuroimaging

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Introduction to MATLAB for Neuroimaging

Introduction to MATLAB for NeuroimagingKRISANNE LITINASUM FMRI LABORATORY

Page 2: Introduction to MATLAB for Neuroimaging

Module 3:fMRI Data and MATLABKRISANNE LITINASUM FMRI LABORATORY

Page 3: Introduction to MATLAB for Neuroimaging

Today’s Concepts

Data storage 3D and 4D matrices Index vs subscript Orthogonal views Correlation and functional connectivity

Page 4: Introduction to MATLAB for Neuroimaging

Brain Imaging Data: 3D Movie

Page 5: Introduction to MATLAB for Neuroimaging

Single slice

Page 6: Introduction to MATLAB for Neuroimaging

Single slice

Page 7: Introduction to MATLAB for Neuroimaging

Single slice: 2D matrix

1

2

3

4

5

6

7

8

9

M

Page 8: Introduction to MATLAB for Neuroimaging

Single slice: 2D matrix

Linear Index Subscripts (row, col)

Page 9: Introduction to MATLAB for Neuroimaging

Single slice: 2D matrix

Linear Index Subscripts (row, col)

M(8) = M(2,3)

Page 10: Introduction to MATLAB for Neuroimaging

Multiple slices: from 2D to 3D

Linear Index Subscripts (row, col, slice)

M(7) = M(1,2,2)

Page 11: Introduction to MATLAB for Neuroimaging

Multiple slices: from 2D to 3D

…. Same thing to make a 4D matrix

Page 12: Introduction to MATLAB for Neuroimaging

Whole brain as a 3D matrix

XX

Page 13: Introduction to MATLAB for Neuroimaging

Whole brain as a 3D matrix

Y

Y

Page 14: Introduction to MATLAB for Neuroimaging

Whole brain as a 3D matrix

Z

Z

Page 15: Introduction to MATLAB for Neuroimaging

Brain as a 4D matrix (time series)

𝒕𝒕

𝒙𝒙

𝒚𝒚𝒛𝒛

𝑻𝑻𝑻𝑻𝟏𝟏 𝑻𝑻𝑻𝑻𝟐𝟐 𝑻𝑻𝑻𝑻𝟑𝟑

𝑀𝑀(𝑥𝑥,𝑦𝑦, 𝑧𝑧, 𝑡𝑡)

𝑀𝑀(𝑖𝑖𝑖𝑖𝑖𝑖)Index:

Subscript:

Page 16: Introduction to MATLAB for Neuroimaging

A 3D data set as a vector

𝑻𝑻𝑻𝑻𝟏𝟏

Page 17: Introduction to MATLAB for Neuroimaging

A 4D data set as a 2D matrix (!)

Page 18: Introduction to MATLAB for Neuroimaging

Image Storage

All the pixel values are stored sequentially Headers: contains information needed to display an image AVW and NIFTI formats

Page 19: Introduction to MATLAB for Neuroimaging

Linear Regression Review

We have a bunch of measurements of 𝑥𝑥 and 𝑦𝑦 Model the relationship as linear:

Solve for 𝑚𝑚 and 𝑏𝑏 If the model is true, 𝑥𝑥 and 𝑦𝑦 are correlated

𝑦𝑦 = 𝑚𝑚𝑥𝑥 + 𝑏𝑏 + 𝜀𝜀

Page 20: Introduction to MATLAB for Neuroimaging

Expand to Matrix Form

Now with many variables:

𝑦𝑦 = 𝑚𝑚𝑥𝑥 + 𝑏𝑏 + 𝑒𝑒

Y= 𝑋𝑋𝛽𝛽 + 𝜀𝜀𝑌𝑌1𝑌𝑌2⋮𝑌𝑌𝑛𝑛

=

1 𝑋𝑋11 ⋯ 𝑋𝑋1𝑝𝑝1⋮1

𝑋𝑋21⋮𝑋𝑋𝑛𝑛1

𝑋𝑋2𝑝𝑝⋮

𝑋𝑋𝑛𝑛𝑝𝑝

𝛽𝛽0𝛽𝛽1⋮𝛽𝛽𝑝𝑝

+𝜀𝜀0𝜀𝜀1⋮𝜀𝜀𝑛𝑛

Design Matrix Observed Data

Model Params.

Error

time

Page 21: Introduction to MATLAB for Neuroimaging

Linear Regression Review

Solve for terms, do fancy math with matrices

𝑌𝑌 = 𝑋𝑋𝛽𝛽 + 𝜀𝜀

𝜀𝜀𝑒𝑒𝑒𝑒𝑒𝑒 = 𝑌𝑌 − 𝑋𝑋 ∗ 𝛽𝛽𝑒𝑒𝑒𝑒𝑒𝑒

𝑇𝑇𝑒𝑒𝑠𝑠𝑠𝑠𝑠𝑠𝑒𝑒(𝑛𝑛) =𝛽𝛽𝑒𝑒𝑒𝑒𝑒𝑒

𝑠𝑠𝑡𝑡𝑖𝑖𝑒𝑒𝑠𝑠(𝜀𝜀𝑒𝑒𝑒𝑒𝑒𝑒 𝑛𝑛 )

𝛽𝛽𝑒𝑒𝑒𝑒𝑒𝑒 = (𝑋𝑋)−1∗ 𝑌𝑌

Page 22: Introduction to MATLAB for Neuroimaging

Linear Regression Applied: Functional Connectivity

Pixel of interest for study Want to find other pixels in synch… possible connections?

Y= 𝑋𝑋𝛽𝛽 + 𝜀𝜀𝑌𝑌1𝑌𝑌2⋮𝑌𝑌𝑛𝑛

=

1 𝑋𝑋11 ⋯ 𝑋𝑋1𝑝𝑝1⋮1

𝑋𝑋21⋮𝑋𝑋𝑛𝑛1

𝑋𝑋2𝑝𝑝⋮

𝑋𝑋𝑛𝑛𝑝𝑝

𝛽𝛽0𝛽𝛽1⋮𝛽𝛽𝑝𝑝

+𝜀𝜀0𝜀𝜀1⋮𝜀𝜀𝑛𝑛

Design Matrix Observed Data

Error

time

Page 23: Introduction to MATLAB for Neuroimaging

Linear Regression Applied: Functional Connectivity

Pixel of interest for study Want to find other pixels in synch… possible connections? The model for all pixels is the time course of the “seed pixel”.

𝑌𝑌1𝑌𝑌2⋮𝑌𝑌𝑛𝑛

=

1 𝑋𝑋111⋮1

𝑋𝑋21⋮𝑋𝑋𝑛𝑛1

𝛽𝛽0𝛽𝛽1

+𝜀𝜀0𝜀𝜀1⋮𝜀𝜀𝑛𝑛

Observed Data

Model Params.

Error

time

Seed Pixel

Page 24: Introduction to MATLAB for Neuroimaging

The Lab Exercise

Read in NIFTI and Analyze format Understand data ordering Navigate and display the time series Do a “connectivity analysis”

Use regression

Use all data as a single matrix