Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Matlab for Neuroimaging

Similar presentations


Presentation on theme: "Introduction to Matlab for Neuroimaging"— Presentation transcript:

1 Introduction to Matlab for Neuroimaging
Luis Hernandez-Garcia Hernandez-Garcia, UM FMRI course

2 Goals Become familiar with Matlab Learn a few programming skills
Learn how to make simple simulations of BOLD signals. Understand how FMRI data are stored and manipulated. See the “guts” of the General Linear Model Hernandez-Garcia, UM FMRI course

3 Why? Need to manipulate data at lower level
Need easy, fast way to carry out lots of computations Matlab is quick and easy: Doesn’t require compilation, Direct access to variables during execution. Great debugging tools. Matlab has lots of built-in math functions. SPM is built on matlab -> easier to get under the hood and interact with SPM Hernandez-Garcia, UM FMRI course

4 About programming People in this class range the whole gamut of expertise Computers are not smart Frustration The learning curve Worth the effort Hernandez-Garcia, UM FMRI course

5 Module 1: Get acquainted with Matlab
Hernandez-Garcia, UM FMRI course

6 So … Here’s Matlab! Hernandez-Garcia, UM FMRI course

7 Today’s Concepts The Path Variables and operations Scripts Functions
Loops Conditional statements (IF … then ..) Hernandez-Garcia, UM FMRI course

8 The Lab Exercise Follow instructions in
C:\fmri_lab\FMRICourse\LabAssignments\Lab1_Matlab\Matlab_T utorial_1.doc Copy and Paste between doc and Matlab. Make edits as instructed. Think about what you are seeing and ASK LOTS OF QUESTIONS. Read as much documentation along the way as you can. Sign the sheet as you leave What if I already know how to Matlab ? Hernandez-Garcia, UM FMRI course

9 Module 2: Single Pixel analysis in Matlab (General Linear Model)
Hernandez-Garcia, UM FMRI course

10 Super Quick Review of Linear regression
Our data are a bunch of measurements of the variables x and y A linear model of these data: y = mx + b + noise (we can solve for m and b) If this model fits, then x and y are correlated. Hernandez-Garcia, UM FMRI course

11 y x Hernandez-Garcia, UM FMRI course

12 Super Quick Review of Linear regression
If m is “significant”, then we infer that the model is true. Significant means that m is big enough compared to the noise. “noise” is the residual signal after we remove the fitted signal. Hernandez-Garcia, UM FMRI course

13 Super Quick Review of Linear regression
Our data are a bunch of measurements of the variables x1 , x2 , x3 … and y A bigger linear model of these data: y = m1x1 + m2x2 + m3x3 +… + noise Hernandez-Garcia, UM FMRI course

14 Super Quick Review of Linear regression
In fMRI, y is a time course x1, x2, ..etc are also time courses Hernandez-Garcia, UM FMRI course

15 Super Quick Review of Linear regression
In the usual GLM analysis of FMRI data, all the x1, x2, … are not usually measured. Instead , we make an ideal model and hope it’s good enough. Hernandez-Garcia, UM FMRI course

16 Super Quick Review of Linear regression
Say it with matrices Y = X*M + e Mest = (X)-1*Y eest = Y – X*Mest Tscore(1) = Mest(1) /std. dev(eest(1)) Hernandez-Garcia, UM FMRI course

17 Today’s exercise Generate and explore temporal noise for FMRI data (e)
Create a linear model for a BOLD time series using Matlab (X) Create a Realistic (but fake) BOLD signal (Y) Use regression to test whether the model fits the signal Hernandez-Garcia, UM FMRI course

18 Note for today Don’t use the GUI for setting the path. Instead do it from the command line addpath C:\fmri_Course\FMRI_lab\Lab2_Matlab\Mlib addpath C:\SPM12 If you don’t want to have to do this each time you start matlab, put these commands in startup.m

19 Module 3: FMRI data and Matlab
Hernandez-Garcia, UM FMRI course

20 Today’s Concepts Data storage 3D and 4D matrices Index v. subscript
Orthogonal views Correlation and functional connectivity. Hernandez-Garcia, UM FMRI course

21 Brain Imaging Data is a 3D movie
Hernandez-Garcia, UM FMRI course

22 A single slice: 2D matrix
Hernandez-Garcia, UM FMRI course

23 Multiple slices: from 2D to 3D
…. Same thing to make a 4D matrix Hernandez-Garcia, UM FMRI course

24 A 4D data set as a 2D matrix! Hernandez-Garcia, UM FMRI course

25 Image storage All the pixel values are stored sequentially.
Headers: What information is needed to display an image? Data “proper” AVW and NIFTI formats Hernandez-Garcia, UM FMRI course

26 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 the data as a single matrix Hernandez-Garcia, UM FMRI course

27 Super Quick Review of Linear regression
Our data are a bunch of measurements of the variables x and y A linear model of these data: y = mx + b + noise (we will solve for m and b) If this model is true, then x and y are correlated. Hernandez-Garcia, UM FMRI course

28 Super Quick Review of Linear regression
If m is “significant”, then we infer that the model is true. Significant means that m is big enough compared to the noise. Hernandez-Garcia, UM FMRI course

29 Super Quick Review of Linear regression
Say it with matrices Y = X*b + e best = (X)-1*Y eest = Y – X*best Tscore(1) = best(1) /eest(1) Hernandez-Garcia, UM FMRI course

30 Super Quick Review of Linear regression
In Connectivity analysis: The MODEL for all pixels is the time course of the “seed pixel”. Hernandez-Garcia, UM FMRI course

31 Notes for today’s tutorial
When setting the path: do not use the GUI. Instead put this in the command line addpath C:\fmri_lab\FMRICourse\Lab3_Matlab\Mlib addpath C:\SMP8 Hernandez-Garcia, UM FMRI course


Download ppt "Introduction to Matlab for Neuroimaging"

Similar presentations


Ads by Google