1. Data input and output in Matlab - Lin-Brain-Lab/machine_learning Wiki

Procedures to read fMRI data in Matlab

Example data are at:

  1. Perspective-taking fMRI: /space_lin2/fhlin/perspective

  2. Human connectome project: /space_lin1/hcp

1. Read in-house fMRI data

Here are examples to read perspective-taking fMRI data in Matlab.

1.1 NII format

This one reads the 4D brain volume in run 007 data for subject subj_02. The data are motion corrected, slice-timing corrected, and spatially smoothed in the native space.

img=load_untouch_nii('/space_lin2/fhlin/perspective/subj_02/epi_data/unpack/bold/007/sfmcstc.nii');    

This one reads the 4D brain volume in run 007 data for subject subj_02. The data are motion corrected, spatially smoothed, and normalized to the MNI space in 2-mm resolution.

img=load_untouch_nii('/space_lin2/fhlin/perspective/subj_02/epi_data/unpack/bold/007/sfmcs-tal.2mm.nii');

1.2 STC format

We have scripts in fhlin_toolbox to read/write STC files in Matlab. In brief, A STC file is a two-dimensional matrix, where columns and rows typically represent time indices and spatial locations, respectively.

%read stc_file into a variable named stc. v denotes the vector for spatial indices. t0 is the onset time. t1 is the sampling period in milliseconds.

[stc,v,t0,t1]=inverse_read_stc(stc_file);

%write a 2D matrix called 'stc' in to the file named file_to_be_saved. 
inverse_write_stc(stc,v,t0,t1,file_to_be_saved);

2. Read Human Connectome Project data

Extensively processed HCP data from 1113 subjects were downloaded and processed. Here are methods to read them.

2.1 STC format

We have transformed the spatially normalized fMRI data to the cortical surface using FreeSurfer. The resulting STC files can be read by this script file, where the variable STC denotes the spatiotemporal signals of one subject.

The subjects to be read are included in the list file.