The learning objectives for this unit are:
nifti
filesfunction
s in matlabfunction
s that have 1 or more input arguments, and 1 or more output argumentsnifti
filesdata = niftiread('/Volumes/practicals/ds1/2019-msc-matlab/example.nii');
Look at the documentation for niftiread
!
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)
TR
is to create a vector of time in seconds (rather than units of volumes
)?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?
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)
blockOne, n
TR, hrf
d
(1-column design matrix taking into account the HRF)dRaw
(same as d, but without HRF).Look at help makeDesignMatrix
to get some ideas on how to plot. With some additional adjusting you can end up with something like this:
the file makeDesignMatrix.p
is the pcode/compiled version that runs (but for which you cannot see the code). The .m
file here is just to provide the help text - you need to add the code to implement the function yourself!
dRaw
contains n
repeats of blockOne
in succession,d
is the same as dRaw
, but convolved with a haemodynamic response function.d
should be returned such that mean(d) = 0