learningMatlab

Aim

In this unit we want to work through an example of linear regression, in particular the estimation part.

Linear regression in action

First, I will walk/talk you through an example of how to load in some data, get a timecourse from a single voxel at a time, the designMatrix and then show the linear regression bit in action.

go to subfolder and you can also have a look at the PDF file I produced from the analysis script using the publish() feature in Matlab.

Turning this into a function

If we have time, we can also think about how we can take the logic of the code I wrote in the script into a function that takes as inputs

Specification

The function linRegress() should be of the following form:

Ultimately, running the following should work

cd('facesVhouses');
b = linRegress( 'filtered_func_data.nii', 'designMatrix.txt', [18, 14, 4])
cd('..'); % come back up one folder

Notes

To orient you with some of the calculations, consider the following plot:

Image illustrating data + fit