introduction to matlab for neuroimaging · introduction to matlab for neuroimaging krisanne litinas...
TRANSCRIPT
![Page 1: Introduction to MATLAB for Neuroimaging · Introduction to MATLAB for Neuroimaging KRISANNE LITINAS UM FMRI LABORATORY. Module 1: Recap MATLAB Interface](https://reader035.vdocuments.us/reader035/viewer/2022062311/5ed33e1b0435ca6f1051ea0a/html5/thumbnails/1.jpg)
Introduction to MATLAB for NeuroimagingKRISANNE LITINASUM FMRI LABORATORY
![Page 2: Introduction to MATLAB for Neuroimaging · Introduction to MATLAB for Neuroimaging KRISANNE LITINAS UM FMRI LABORATORY. Module 1: Recap MATLAB Interface](https://reader035.vdocuments.us/reader035/viewer/2022062311/5ed33e1b0435ca6f1051ea0a/html5/thumbnails/2.jpg)
Module 1: Recap
MATLAB Interface Path concept Variables and operators Scripts Functions Loops Conditional statements
![Page 3: Introduction to MATLAB for Neuroimaging · Introduction to MATLAB for Neuroimaging KRISANNE LITINAS UM FMRI LABORATORY. Module 1: Recap MATLAB Interface](https://reader035.vdocuments.us/reader035/viewer/2022062311/5ed33e1b0435ca6f1051ea0a/html5/thumbnails/3.jpg)
Module 2:Single Pixel Analysis in MATLAB (General Linear Model)KRISANNE LITINASUM FMRI LABORATORY
![Page 4: Introduction to MATLAB for Neuroimaging · Introduction to MATLAB for Neuroimaging KRISANNE LITINAS UM FMRI LABORATORY. Module 1: Recap MATLAB Interface](https://reader035.vdocuments.us/reader035/viewer/2022062311/5ed33e1b0435ca6f1051ea0a/html5/thumbnails/4.jpg)
Concept of a Model: Example
Say we have two variables, x and y. Goal: find out the relationship between x and y Method: come up with estimation and model the data accordingly
![Page 5: Introduction to MATLAB for Neuroimaging · Introduction to MATLAB for Neuroimaging KRISANNE LITINAS UM FMRI LABORATORY. Module 1: Recap MATLAB Interface](https://reader035.vdocuments.us/reader035/viewer/2022062311/5ed33e1b0435ca6f1051ea0a/html5/thumbnails/5.jpg)
Simple Example
y
x
𝑦𝑦: Measurement (DV)
𝑥𝑥: The thing you are measuring against (IV)
![Page 6: Introduction to MATLAB for Neuroimaging · Introduction to MATLAB for Neuroimaging KRISANNE LITINAS UM FMRI LABORATORY. Module 1: Recap MATLAB Interface](https://reader035.vdocuments.us/reader035/viewer/2022062311/5ed33e1b0435ca6f1051ea0a/html5/thumbnails/6.jpg)
Simple Example
y
x
𝑦𝑦: Measurement (DV)
𝑥𝑥: The thing you are measuring against (IV)
Need to model it somehow…
![Page 7: Introduction to MATLAB for Neuroimaging · Introduction to MATLAB for Neuroimaging KRISANNE LITINAS UM FMRI LABORATORY. Module 1: Recap MATLAB Interface](https://reader035.vdocuments.us/reader035/viewer/2022062311/5ed33e1b0435ca6f1051ea0a/html5/thumbnails/7.jpg)
Simple Example: Linear Regression
y
x
𝑦𝑦: Measurement (DV)
𝑥𝑥: The thing you are measuring against (IV)
𝑦𝑦 = 𝑚𝑚𝑥𝑥 + 𝑏𝑏 + 𝑒𝑒
Estimate of the data: a linear relationship
![Page 8: Introduction to MATLAB for Neuroimaging · Introduction to MATLAB for Neuroimaging KRISANNE LITINAS UM FMRI LABORATORY. Module 1: Recap MATLAB Interface](https://reader035.vdocuments.us/reader035/viewer/2022062311/5ed33e1b0435ca6f1051ea0a/html5/thumbnails/8.jpg)
Simple Example: Linear Regression
y
x
𝑦𝑦: Measurement (DV)
𝑥𝑥: The thing you are measuring against (IV)
𝑏𝑏: Intercept (constant)
𝑦𝑦 = 𝑚𝑚𝑥𝑥 + 𝑏𝑏 + 𝑒𝑒
Estimate of the data: a linear relationship
b
![Page 9: Introduction to MATLAB for Neuroimaging · Introduction to MATLAB for Neuroimaging KRISANNE LITINAS UM FMRI LABORATORY. Module 1: Recap MATLAB Interface](https://reader035.vdocuments.us/reader035/viewer/2022062311/5ed33e1b0435ca6f1051ea0a/html5/thumbnails/9.jpg)
Simple Example: Linear Regression
y
x
𝑦𝑦: Measurement (DV)
𝑥𝑥: The thing you are measuring against (IV)
𝑏𝑏: Intercept (constant)
𝑒𝑒: Error term (residual noise after the fitting)
𝑦𝑦 = 𝑚𝑚𝑥𝑥 + 𝑏𝑏 + 𝑒𝑒
Estimate of the data: a linear relationship
b
𝒆𝒆𝒊𝒊
![Page 10: Introduction to MATLAB for Neuroimaging · Introduction to MATLAB for Neuroimaging KRISANNE LITINAS UM FMRI LABORATORY. Module 1: Recap MATLAB Interface](https://reader035.vdocuments.us/reader035/viewer/2022062311/5ed33e1b0435ca6f1051ea0a/html5/thumbnails/10.jpg)
Simple Example: Linear Regression
y
x
𝑦𝑦: Measurement (DV)
𝑥𝑥: The thing you are measuring against (IV)
𝑏𝑏: Intercept (constant)
𝑒𝑒: Error term (residual noise after the fitting)
𝑚𝑚: Slope of the fitted line
𝑦𝑦 = 𝑚𝑚𝑥𝑥 + 𝑏𝑏 + 𝑒𝑒
Estimate of the data: a linear relationship
b
𝒎𝒎 =∆𝒚𝒚∆𝒙𝒙
![Page 11: Introduction to MATLAB for Neuroimaging · Introduction to MATLAB for Neuroimaging KRISANNE LITINAS UM FMRI LABORATORY. Module 1: Recap MATLAB Interface](https://reader035.vdocuments.us/reader035/viewer/2022062311/5ed33e1b0435ca6f1051ea0a/html5/thumbnails/11.jpg)
y
x
Simple Example: Linear Regression
o We can solve for m and b
o If this model fits, we say that x and y are correlated
𝑦𝑦 = 𝑚𝑚𝑥𝑥 + 𝑏𝑏 + 𝑒𝑒
Estimate of the data: a linear relationship
b
𝒎𝒎
![Page 12: Introduction to MATLAB for Neuroimaging · Introduction to MATLAB for Neuroimaging KRISANNE LITINAS UM FMRI LABORATORY. Module 1: Recap MATLAB Interface](https://reader035.vdocuments.us/reader035/viewer/2022062311/5ed33e1b0435ca6f1051ea0a/html5/thumbnails/12.jpg)
Simple Example: Linear Regression
If 𝑚𝑚 is “significant”, then we refer to that model as true.
”Significant”: 𝑚𝑚 is big enough compared to the noise (e)
![Page 13: Introduction to MATLAB for Neuroimaging · Introduction to MATLAB for Neuroimaging KRISANNE LITINAS UM FMRI LABORATORY. Module 1: Recap MATLAB Interface](https://reader035.vdocuments.us/reader035/viewer/2022062311/5ed33e1b0435ca6f1051ea0a/html5/thumbnails/13.jpg)
Bigger Example: Linear Regression
Data composed of: DV: 𝑦𝑦
Multiple IVs: 𝑥𝑥1, 𝑥𝑥2, 𝑥𝑥3 …
A bigger linear model of these data (>1 independent variables):
𝑦𝑦 = 𝑚𝑚1𝑥𝑥1 + 𝑚𝑚2𝑥𝑥2 + 𝑚𝑚3𝑥𝑥3 + ⋯+ 𝑏𝑏 + 𝑒𝑒
![Page 14: Introduction to MATLAB for Neuroimaging · Introduction to MATLAB for Neuroimaging KRISANNE LITINAS UM FMRI LABORATORY. Module 1: Recap MATLAB Interface](https://reader035.vdocuments.us/reader035/viewer/2022062311/5ed33e1b0435ca6f1051ea0a/html5/thumbnails/14.jpg)
Linear Regression in fMRI
𝑦𝑦, 𝑥𝑥1, 𝑥𝑥2, 𝑥𝑥3,… etc. are all time courses In the usual GLM analysis of fMRI data, all the 𝑥𝑥1, 𝑥𝑥2, 𝑥𝑥3,… terms are
usually not measured Instead, we make an ideal model and hope for the best ¯\_(ツ)_/¯
𝑦𝑦 = 𝑚𝑚1𝑥𝑥1 + 𝑚𝑚2𝑥𝑥2 + 𝑚𝑚3𝑥𝑥3 + ⋯+ 𝑏𝑏 + 𝑒𝑒
![Page 15: Introduction to MATLAB for Neuroimaging · Introduction to MATLAB for Neuroimaging KRISANNE LITINAS UM FMRI LABORATORY. Module 1: Recap MATLAB Interface](https://reader035.vdocuments.us/reader035/viewer/2022062311/5ed33e1b0435ca6f1051ea0a/html5/thumbnails/15.jpg)
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 16: Introduction to MATLAB for Neuroimaging · Introduction to MATLAB for Neuroimaging KRISANNE LITINAS UM FMRI LABORATORY. Module 1: Recap MATLAB Interface](https://reader035.vdocuments.us/reader035/viewer/2022062311/5ed33e1b0435ca6f1051ea0a/html5/thumbnails/16.jpg)
Expand to Matrix Form
Solve for terms, do fancy math with matrices
𝑌𝑌 = 𝑋𝑋𝛽𝛽 + 𝜀𝜀
𝜀𝜀𝑒𝑒𝑒𝑒𝑒𝑒 = 𝑌𝑌 − 𝑋𝑋 ∗ 𝛽𝛽𝑒𝑒𝑒𝑒𝑒𝑒
𝑇𝑇𝑒𝑒𝑠𝑠𝑠𝑠𝑠𝑠𝑒𝑒(𝑛𝑛) =𝛽𝛽𝑒𝑒𝑒𝑒𝑒𝑒
𝑠𝑠𝑠𝑠𝑠𝑠𝑒𝑒𝑠𝑠(𝜀𝜀𝑒𝑒𝑒𝑒𝑒𝑒 𝑛𝑛 )
𝛽𝛽𝑒𝑒𝑒𝑒𝑒𝑒 = (𝑋𝑋)−1∗ 𝑌𝑌
![Page 17: Introduction to MATLAB for Neuroimaging · Introduction to MATLAB for Neuroimaging KRISANNE LITINAS UM FMRI LABORATORY. Module 1: Recap MATLAB Interface](https://reader035.vdocuments.us/reader035/viewer/2022062311/5ed33e1b0435ca6f1051ea0a/html5/thumbnails/17.jpg)
Today’s Exercise
Generate and explore temporal noise for fMRI data (𝜀𝜀) Create a linear model for a BOLD time series using MATLAB (𝑋𝑋) Create a realistic (but fake) BOLD signal (𝑌𝑌) Use regression to test whether the model fits the signal