1. Data input and output in Matlab - Lin-Brain-Lab/machine_learning GitHub 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.

ROI analysis This script will read STC files and provide the time series for the average as well as the standard deviation over an ROI. We use the Destrieux Atlas (?h.aparc.a2009s.annot) in FreeSurfer for ROI. This is an efficient strategy to reduce the whole cortex vertices (10242 vertices in fsaverage MNI305 template subject) to 75 regions. Variables ROI_avg and ROI_std in (roi,:,hemisphere,roi_set) stores the average and standard deviation time series in for different regions, hemispheres and ROI set. Here we have only one set of ROI.

--