First, we read from the nifti format, and the output a structure called brain4D
with the following structure:
brain4D = srcbext: '' analyzehdr: [] bhdr: [] vol: [4-D double] niftihdr: [1x1 struct] fspec: [1x64 char] pwd: [1x88 char] flip_angle: 0 tr: 2500 te: 0 ti: 0 vox2ras0: [4x4 double] volsize: [64 40 64] height: 64 width: 40 depth: 64 nframes: 1452 vox2ras: [4x4 double] nvoxels: 163840 xsize: 3.5000 ysize: 3.7500 zsize: 3.7500 x_r: 1 x_a: 0 x_s: 0 y_r: 0 y_a: 1 y_s: 0 z_r: 0 z_a: 0 z_s: 1 c_r: 70 c_a: 120 c_s: 120 vox2ras1: [4x4 double] Mdc: [3x3 double] volres: [3.5000 3.7500 3.7500] tkrvox2ras: [4x4 double] K>>
and the output from the function convertDataVTFormat
is a structure out containing the following information:
out = VT: [163840x1452 double] voxelID: [163840x1 double] sizeX: 64 sizeY: 40 sizeZ: 64 sizeT: 1452 coorX: [163840x1 double] coorY: [163840x1 double] coorZ: [163840x1 double] >>
What we want is the brain signal in voxel-time-series format (i.e., VT format), which can be found in out.VT
.
out.VT
is a 2D matrix M by T, where There are 2 steps: 1) get the design matrix and 2) regress for beta coefficients
1. Get the design matrix
Run the code import_experiment_label.m to get the category name (category_name
) and run number (run
) for each time stamp, saved in experiment_design.mat
. The experiment should look like the figure below:
We make a label number associating with a category name as follows:
category_name_list = {'rest','face','house','cat','bottle','scissors','shoe','chair','scrambledpix'}; assoc_label_list = [0,1,2,3,4,5,6,7,8];
2. Regress for the beta coefficients
The big picture is that we will calculate the beta coefficients b from the linear regression equation y = Xb+e, where
First, we need to make
Next, we will extract the beta coefficients from every voxel and experiment