introduction to matlab for neuroimaging

24
Introduction to MATLAB for Neuroimaging KRISANNE LITINAS UM FMRI LABORATORY

Upload: others

Post on 10-Nov-2021

6 views

Category:

Documents


0 download

TRANSCRIPT

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