Preprocessing Haxby's 6 subjects

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
    • M is the number of the voxels in the entire scan space (64*40*64 = 163840 voxels in this case); and
    • T is the whole duration of the time series (1452 time stamps).
    • out.VT looks like the figure below:
  • out.voxelID is a column vector representing the id of each voxel. Each voxel in the brain has an ID determined from the order when the brain4D is collapsed into a column vector:
      • [sizeX sizeY sizeZ sizeT] = size(brain4D); numVoxel = sizeX*sizeY*sizeZ; VT = zeros(numVoxel,sizeT); % For each time stamp t for t = 1:sizeT tmp1 = brain4D(:,:,:,t); % take a 3D slice VT(:,t) = tmp1(:); % collapse the time slice into a column vector end indexVector = [1:numVoxel]'; % make voxel ID % Get the xyz coordinate for each voxel [coorX, coorY, coorZ] = ind2sub([sizeX sizeY sizeZ],indexVector);
  • f

Extract the beta coefficients from the VT format

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

  • y is a column vector of a time series in a voxel
  • X is a design matrix whose column contains a predictor (a.k.a basis or independent variable).
    • In our implementation, the first 9 columns are the predictor of the category 0-8. The predictor might be constructed from convolving the basis design matrix with the gamma function.
    • The columns after that (i.e., 10 and 11) can denote "constant offset" and "linear drift".
  • b is a column vector whose entry b(i) is a coefficient for each predictor X(:,i)
  • e is a column vector representing residues of the LMS solution

First, we need to make

Next, we will extract the beta coefficients from every voxel and experiment