learningMatlab

Aim

The learning objectives for this unit are:

Loading data from nifti files

data = niftiread('/Volumes/practicals/ds1/2019-msc-matlab/example.nii');

Look at the documentation for niftiread!

A function for returning a single voxel timecourse

Write a function returnTimecourse() that returns a 1D timecourse from a 4D dataset (3d space, 1d time).

Users should be able to use the function like this

c = [24,25,10]; for example
tc = returnTimecourse(data, c);
plot(tc)

A function for calculating the HRF

The function makeHrf() creates the y-values for an HRF. The time runs from 0 to 30s (in steps of the TR you specify). So for TR=1.5 it would be [0, 1.5 3, 4.5, ... 30]

t = 0:1.5:30; %
h = makeHrf(1.5); % creates an hrf for 30s
plot(t, h ,'ro-')

Bonus: where to find the equations that describe HRF as a function to time? Are there several available? Could you add a flag to your code that could allow you to switch between different versions?

Also…

Toward the end of this unit, we need to construct a function makeDesignMatrix() that will help us do linear regression in due course. The idea here is to specify the on/off timing (say, for a visual stimulus in an fMRI experiment)

Checking results

Look at help makeDesignMatrix to get some ideas on how to plot. With some additional adjusting you can end up with something like this:

Image of Design matrix

Notes