Introduction to Matlab for Neuroimaging

Slides:



Advertisements
Similar presentations
MATLAB – A Computational Methods By Rohit Khokher Department of Computer Science, Sharda University, Greater Noida, India MATLAB – A Computational Methods.
Advertisements

SPM 2002 C1C2C3 X =  C1 C2 Xb L C1 L C2  C1 C2 Xb L C1  L C2 Y Xb e Space of X C1 C2 Xb Space X C1 C2 C1  C3 P C1C2  Xb Xb Space of X C1 C2 C1 
Introduction to Matlab. I use Matlab for: Data analysis Data plotting Image Analysis Also – Simulations (solving odes/pdes/finite element methods) – Minimisations,
Lecture 6 Sept 15, 09 Goals: two-dimensional arrays matrix operations circuit analysis using Matlab image processing – simple examples.
SM3121 Software Technology Mark Green School of Creative Media.
Lorelei Howard and Nick Wright MfD 2008
Linear Algebra, Matrices (and why they matter to (f)MRI!) Methods for Dummies FIL October 2008 Nick Henriquez & Nick Wright Theory & Application Theory.
Copyright © Allyn & Bacon 2008 POWER PRACTICE Chapter 6 Academic Software START This multimedia product and its contents are protected under copyright.
Introduction to MATLAB adapted from Dr. Rolf Lakaemper.
Introduction to MATLAB Session 1 Prepared By: Dina El Kholy Ahmed Dalal Statistics Course – Biomedical Department -year 3.
1 A Simple but Realistic Assembly Language for a Course in Computer Organization Eric Larson Moon Ok Kim Seattle University October 25, 2008.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 6 Value- Returning Functions and Modules.
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Chapters 2 & 3 MATLAB Skills This tutorial revisits Examples 3.1 to 3.4 to show how MATLAB can be used to solve the same problems 1.Scatter Plots 2.Other.
CS 127 Introduction to Computer Science. What is a computer?  “A machine that stores and manipulates information under the control of a changeable program”
CIS 601 Fall 2003 Introduction to MATLAB Longin Jan Latecki Based on the lectures of Rolf Lakaemper and David Young.
Alexandria University Faculty of Science Computer Science Department Introduction to Programming C++
Finishing up Chapter 5. Will this code enter the if statement? G=[30,55,10] if G
CIS 595 MATLAB First Impressions. MATLAB This introduction will give Some basic ideas Main advantages and drawbacks compared to other languages.
Introduction to Computing Systems and Programming Programming.
Dynamic Causal Modeling (DCM) A Practical Perspective Ollie Hulme Barrie Roulston Zeki lab.
SPM short course – Mai 2008 Linear Models and Contrasts Jean-Baptiste Poline Neurospin, I2BM, CEA Saclay, France.
Getting started with Matlab: Outline
Introduction to Matlab
Matlab.
Examples, examples: Outline
Learning to Program D is for Digital.
Lesson #6 Modular Programming and Functions.
Lesson #6 Modular Programming and Functions.
Matlab Training Session 4: Control, Flow and Functions
Lecture: MATLAB Chapter 1 Introduction
Foundations of Programming: Arrays
Basics of Group Analysis
Lecture 2 Introduction to Programming
A Closer Look at Instruction Set Architectures
(Mohammed Sami) Ashhab
Prepared by Kimberly Sayre and Jinbo Bi
Unit# 8: Introduction to Computer Programming
CS190/295 Programming in Python for Life Sciences: Lecture 1
Cracking the Coding Interview
Lesson #6 Modular Programming and Functions.
Covariance and Correlation
Introduction to MATLAB
StatLab Matlab Workshop
Wellcome Trust Centre for Neuroimaging University College London
Engineering 1020 Introduction to Programming
Lesson 4: Controlling Memory with Variables
Use of Mathematics using Technology (Maltlab)
Weighted Least Squares Fit
StatLab Workshop: Intro to Matlab for Data Analysis and Statistical Modeling 11/29/2018.
Introduction to Java, and DrJava part 1
Lesson 1: Fundamentals of Programming
Faculty of Computer Science & Information System
Communication and Coding Theory Lab(CS491)
CSE 307 Basics of Image Processing
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
Lesson #6 Modular Programming and Functions.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Hank Childs, University of Oregon
CMSC201 Computer Science I for Majors Final Exam Information
How to write good code Part 2
Tonga Institute of Higher Education IT 141: Information Systems
Experiment No. (1) - an introduction to MATLAB
Simulation And Modeling
Tonga Institute of Higher Education IT 141: Information Systems
you get to solve puzzles!
Week 7: Computer Tools for Problem Solving and Critical Thinking
Introduction To MATLAB
Chapter 6 Programming.
Presentation transcript:

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

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

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

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

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

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

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

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

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

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

y x Hernandez-Garcia, UM FMRI course

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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