Resting-State fMRI Data Analysis Toolkit V1.8

Resting-State fMRI Data Analysis Toolkit (REST) is a convenient toolkit to calculate Functional Connectivity (FC), Regional Homogeneity (ReHo), Amplitude of Low-Frequency Fluctuation (ALFF), Fractional ALFF (fALFF), Gragner causality, degree centrality, voxel-mirrored homotopic connectivity (VMHC) and perform statistical analysis. You also can use REST to view your data, perform Monte Carlo simulation similar to AlphaSim in AFNI, perform Gaussian random field theory multiple comparison correction like easythresh in FSL, calculate your images, regress out covariates, extract ROI time courses, reslice images, and sort DICOM files. Download a MULTIMEDIA COURSE would be helpful for knowing more about how to use this software. Add REST's directory to MATLAB's path and enter "REST" in the command window of MATLAB to enjoy it.

Citation of REST is: 
Xiao-Wei Song, Zhang-Ye Dong, Xiang-Yu Long, Su-Fang Li, Xi-Nian Zuo, Chao-Zhe Zhu, Yong He, Chao-Gan Yan, Yu-Feng Zang. (2011) REST: A Toolkit for Resting-State Functional Magnetic Resonance Imaging Data Processing. PLoS ONE 6(9): e25031. doi:10.1371/journal.pone.0025031

The latest release is


Multimedia Course: Data Processing of Resting-State fMRI

New features of REST V1.8 release 130615:
1. Fixed a bug in temporal correlation of two groups of images in Image Calculator. (Thanks for the report of ZHANG Han)

2. The midline of VMHC results were set to zero. (YAN Chao-Gan)

New features of REST V1.8 release 130303:
When calling Mingrui Xia's BrainNet Viewer (, the default surface template is changed to the smoothed version (BrainMesh_ICBM152_smoothed.nv). The previous default template (BrainMesh_ICBM152.nv) hide more information in the sulcus. If the users want to use BrainMesh_ICBM152.nv as default surface template, please uncomment Line 3740 in rest_sliceviewer: %SurfFileName=[BrainNetViewerPath,filesep,'Data',filesep,'SurfTemplate',filesep,'BrainMesh_ICBM152.nv'];
(After discussion with Mingrui Xia).

New features of REST V1.8 release 130214:
1.    This release fixed some minor bugs, will not affect any data analysis.
2.    Fixed a bug when using .nii(.gz) files in REST Image Calculator. (WANG Xin-Di)
3.    Fixed a bug in using .nii(.gz) files in GCA analyses. (ZANG Zhen-Xiang)
4.    Fixed the imresize_old bug of REST Slice Viewer with Matlab 2012b. (YAN Chao-Gan)

New features of REST V1.8 release 121225:
1.    Support parallel computing! If you installed the MATLAB parallel computing toolbox, REST can distribute the subjects into different CPU cores. (WANG Xin-Di and YAN Chao-Gan).
2.    Algorithm change: (1) Filtering: a separate function for matrix filtering was written. The low cutoff frequency index calculation changed from round (in REST V1.7) to "ceil". E.g., if low cut off corresponded to index 5.1, now it will start from 6 other than 5. This change also applies to ALFF and fALFF calculation. The filtered data changes slightly, about 0.0001. (2) The ALFF generated by the new version is sqrt(2/N) times of the original version. (new version used: 2*abs(fft(x))/N; original version used:  sqrt(2*abs(fft(x))^2/N)). This change will not affect group analysis (as each individual scaled the same number), and will not affect mALFF and fALFF calculation as this factor will be normalized. (3) In the calculation of ReHo, the rank will keep as double and no longer converted into uint16, thus created slight difference with REST V1.7. (YAN Chao-Gan)
3.    REST Slice Viewer support 4D file display and the maximum and minimum value could be set. (WANG Xin-Di)
4.    Gaussian random field (GRF) theory multiple comparison correction (like easythresh in FSL) was supported. The smoothness could be evaluated for GRF correction or AlphaSim correction. (GUI by WANG Xin-Di, algorithm by YAN Chao-Gan)
5.    Modules of voxel-mirrored homotopic connectivity (VMHC) (Zuo et al., 2010), Degree Centrality (Buckner et al., 2009) were added. (GUI by WANG Xin-Di, algorithm by YAN Chao-Gan)
6.    REST GCA: could handle multiple ROIs (other than 2) in ROI-wise GCA now. Fixed a bug of discordance between the outputs and the description in REST-GCA readme in the pre-release of REST V1.8. (ZANG Zhen-Xiang)
7.    rest_readfile.m and rest_writefile: The default format changed to .nii from .img. (WANG Xin-Di)
8.    rest_to4d.m: now support one 4d file other than a directory, also support a cell of image filenames. (YAN Chao-Gan)
9.    rest_regress_ss.m: add the output of T value. (YAN Chao-Gan)
10.    rest_Write4DNIfTI.m: This function was added for write 4D nifti files based on SPM’s nifti function. (YAN Chao-Gan)
11.    rest_writefile.m: No longer need to change to RPI before writing. (YAN Chao-Gan)

New features of REST V1.7 release 120101:
1. REST now support .nii and .nii.gz 3D or 4D files. (DONG Zhang-Ye and YAN Chao-Gan)
2. New module of Normality Test added at REST->Utilities->REST Normality Test. Please see an application in Zang, Z.X., Yan, C.G., Dong, Z.Y., Huang, J., Zang, Y.F., 2012. Granger causality analysis implementation on MATLAB: A graphic user interface toolkit for fMRI data processing. Journal of Neuroscience Methods 203, 418-426. (ZANG Zhen-Xiang)
3. Surface Map View Mode work with BrainNet Viewer (by Mingrui Xia, REST Slice Viewer->Misc->Surface View with BrainNet Viewer. Command line version: rest_CallBrainNetViewer.m or named to BrainNet_MapVolume.m in BrainNet Viewer. (YAN Chao-Gan)
4. The GUI view in Linux or Mac OS has been optimized. (YAN Chao-Gan)
5. Fixed a bug while frequency start with 0 or up to sampleFreq/2 in alff.m. (YAN Chao-Gan)
6. The coordinates conversion from Talairach space to MNI space has changed from tal2mni.m to tal2icbm_spm.m. The function is developed and validated by Jack Lancaster (Lancaster et al., 2007). The same for icbm_spm2tal.m. (YAN Chao-Gan)

New features of REST V1.6 release 110505:
1. REST-GCA: provides a method that could transform the residual-based F into normally distributed Z score. For more details, please see (ZANG Zhen-Xiang)
2. REST Image Calculator: Fixed an error when processing images of i10, i11.... (DONG Zhang-Ye)
3. REST Slice Viewer: Fixed a bug in dispalying "only -" and a bug in dispaying unerlay with 2x2x2 voxel size. (DONG Zhang-Ye)
4. For defining ROIs, supporting keep "shift" key and select multiple mask files. From "Misc"->"Add multiple user-defined mask files". (DONG Zhang-Ye)
5. Fox Extracting ROI signals, also support Multiple label values in a single mask file. (DONG Zhang-Ye)
6. Fixed an error in the future MATLAB version in "[pathstr, name, ext, versn] = fileparts...". (YAN Chao-Gan)

New features of REST V1.5 release 101101:
1. Fixed a bug in rest_RegressOutCovariates_gui.m while processing multiple subjects with different covaribles in batch mode. (YAN Chao-Gan)

New features of REST V1.5 release 101025:
1. Module of Regional Homogeneity based on Coherence (Cohe-ReHo) has been added by LIU Dong-Qiang and DONG Zhang-Ye. For methodology, please see: Liu D, Yan C, Ren J, Yao L, Kiviniemi VJ and Zang Y (2010) Using coherence to measure regional homogeneity of resting-state fMRI signal. Front. Syst. Neurosci. 4:24. doi: 10.3389/fnsys.2010.00024.
2. In previous release of REST, removing covariates effects will also regress out linear trend. Now regressing out linear trend has been canceled in this step. Users can still regress out polynomial effects by using rest_regressOutCovariates.m in command line. (YAN Chao-Gan)
3. For rest_sliceviewer, fixed a bug of in displaying with MATLAB 2010 and support mouse wheel operation. (DONG Zhang-Ye and YAN Chao-Gan)
4. Fixed a bug in converting .nii files into NIfTI pairs (.img/.hdr). (YAN Chao-Gan)
5. Added new function of "corr(i1,i2,'spatial')" in REST Image Calculator. (DONG Zhang-Ye)
6. Now can open a yoked structural image in displaying power spectrum. (DONG Zhang-Ye)
7. Now can also pick up .nii files in GUI of reslice image. (YAN Chao-Gan)

New features of REST V1.4 release 100426:
1. Fixed a reading and writing bug of compatibility with SPM8. (YAN Chao-Gan)

New features of REST V1.4 release 100420:
1. In previous release of REST, there is a simple procedure for removing linear trend in bandpass filter (as fourier_filter.c in AFNI) regardless if detrend calculation has been performed before bandpass filter or not. Now this simple procedure for removing linear trend in bandpass filter has been canceled. (YAN Chao-Gan)
2. In previous release of REST, bandpass filter (or ALFF and fALFF) determined the frequency band a little smaller than the real wanted frequency band. For example, if the wanted band is 0.01-0.08, TR=2S, Time points=240, then the real wanted frequency band is 0.0104-0.07917, but the previous release of REST will determined to 0.0083-0.07708. This bug has been fixed in REST V1.4 release 100420. These two modifications will make the results obtained by REST V1.4 slightly different from those obtained by previous version of REST, please be careful. (YAN Chao-Gan)
3. REST Statistical Analysis: Statistical analysis module has been added -- One-Sample T-Test, Two-Sample T-Test, Paired T-Test, ANCOVA, and Correlation Analysis. The operations are much easier than the operations in SPM. Especially, the covariate images can be added into statistical analysis (such as adding GM volume images as covariates in statistical analysis).  (YAN Chao-Gan)
4. REST Slice Viewer: Fixed a bug in displaying overlay with different bounding box from those of underlay. For example, if you use ch2.nii as underlay, but the bounding box of overlay is not [-90 -126 -72;90 90 108] (e.g. if you use SPM’s default: [-78 -112 -50; 78 76 85]), then REST Slice Viewer will display in a wrong way. Please re-display your image with REST V1.4 if your data with a bounding box different from [-90 -126 -72;90 90 108]. (DONG Zhang-Ye)
5. REST-GCA: The Beta 1.0 release 100201 of REST-GCA supports only the signed-path coefficient maps at a fixed order=1 condition. In order to implement a more general GCA program, we updated REST-GCA. The updated version integrates two algorithms: the coefficient-based GCA and the residual-based GCA. The updated version supports any order. Please refer to for more details. (ZANG Zhen-Xiang)

New features of REST V1.3 release 100201:
1. Modules added:
  (1) REST GCA 1.0 Beta: perform Granger Causality Analysis. Contributed by ZANG Zhen-Xiang, please see more details by clicking here.
  (2) False Discovery Rate (FDR) Correction: under REST Slice Viewer / Misc Menu. (DONG Zhang-Ye)
2. Functions revised: 
  (1) Make the outputname as 00001.img other than 1.img in REST Image Calculator. (YAN Chao-Gan)
3. Bugs Fixed: 
  (1) Fixed a bug in ROI-wise functional connectivity calculation. (YAN Chao-Gan)

New features of REST V1.3 release 091215 (This release is updated by YAN Chao-Gan and DONG Zhang-Ye):
1. Modules added:
  (1) REST DICOM Sorter: sort and anonymize (optional) DICOM files.
2. Functions revised:
  (1) Adding more explanation of the correspondence between  x coordinates and Left/Right hemisphere when setting sphere ROI.
3. Bugs Fixed:
  (1) Fixed a bug in REST AlphaSim when rmm=6.
  (2) Fixed a bug in REST Image Calculator when creating output directory.
  (3) Fixed a bug that can not close the Utilities when quit REST.
  (4) Fixed a bug of displaying fALFF GUI in some Matlab versions (Missed a F, as Mr. SONG Xiao-Wei reported).

New features of REST V1.3 release 091201 (This release is updated by YAN Chao-Gan, DONG Zhang-Ye and ZHU Wei-Xuan):
1. Modules added:
  (1) REST AlphaSim: perform Monte Carlo simulation similar to AlphaSim in AFNI.
  (2) REST Image Calculator: calculate images, especially for group images.
  (3) Regress Out Covariates: regress nuisance covariates out.
  (4) Extract ROI Time Course: extract ROI time courses for multiple subjects.
  (5) Reslice Image: resclice images to a new vox size and new target space.
  (6) NIfTI nii to NIfTI pairs: convert NIfTI .nii (3D or 4D) files to NIfTI pairs (.hdr/.img) since REST only can process 3D .hdr/.img files.
2. Functions revised:
  (1) REST Slice Viewer: added P<->T, P<->F, P<->Z, P<->R conversion when threshoulding images; reading degree of freedom information from SPM statistical images; only+ and only-; save all clusters; cluster report functions; more AlphaSim thresholds (rmm=4, 5 and 6) for BrainMask_05_61x73x61.img; and make the Cluster Connectivity Criterion could be chosen among 6 voxels (surface), 18 voxels (edge) or 26 voxels (corner) according to rmm value.
  (2) ReHo: It should be noted that the previous release of REST does not calculate the ReHo value of the voxels near the border of the brain mask, i.e., any voxel of the 27 voxels in the cluster is outside the brain mask. The new release (here the closed test version) will calculate the ReHo value of the voxels near the border of the brain mask, users should be cautious when discussing the results near the border.
  (3) Functional Connectivity: Now it can process multiple subjects with different seed time courses (.txt) in batch mode. Give the seed time course configuration file as:
  (4) REST: Checking and fixing the error of reading and writing NIfTI images when REST starts
  (5) rest_to4d: If data has too huge or too many volumes, then it will be loaded into memory in 'single' format.
  (6) Templates: Added 3x3x3 AAL template and Brodmann template.
3. Bugs Fixed:
  (1) Fixed the bugs of color, montage and resize in REST Slice Viewer.
  (2) Fixed the bug of writing ANALYZE images.
  (3) Fixed the bug of writing data caused by finite in MATLAB 2009.
  (4) LastSphereMask would be stored under temp dir other than {REST_DIR} in case the users do not have write permission to {REST_DIR}.


New features of REST V1.3 release 090525 (YAN Chao-Gan):

1. Fixed the bug of reading and writing error under the linux, unix or mac operation system.

New features of REST V1.3 release 090422 (YAN Chao-Gan):

1. The ReHo algorithm has been re-written to speed up the calculation of ReHo. The calculation time of one subject will reduced from about ten minutes to three minutes usually.
2. Fixed the bug of computing ReHo with 7 voxels or 19 voxels in a cluster.


New features of REST V1.3 release 090401: 

1. REST now can compute fractional ALFF. (CHENG Wen-Lian)

2. Data in processing will not be converted to the format 'int16', and result data will be saved in the format 'single'. (YAN Chao-Gan)
3. Added "Correction Thresholds by AlphaSim" (under pull-down menu "Misc"). (YAN Chao-Gan)
4. Fixed the bug of 'Set Overlay's Color bar' in Matlab R2007a or latter version which caused by the revision of imresize funtion in Matlab R2007a. (YAN Chao-Gan)

Thank Dr. CHENG Wen-Lian for some helpful works.


New features of REST V1.2 release 090101 (YAN Chao-Gan):

1. Now REST can support image saving function within rest_sliceviewer ("Save Image As" under pull-down menu "Misc").
2. The display mode of transverse multislices was changed as similar to AFNI in rest_sliceviewer.
3. Fixed the bug of cluster size threshold in rest_sliceviewer.
4. The default brain mask in REST was changed to new NIFTI mask which was the SPM5 apriori mask (brainmask.nii) thresholded at 50%. There were still two masks supported under the path \mask: white matter mask - SPM5 apriori mask (white.nii) thresholded at 90% and cerebrospinal fluid mask - SPM5 apriori mask (csf.nii) thresholded at 70%.


New features of REST V1.2:

1. REST V1.2 supports NIFTI (.hdr/.img) format now. Matlab 7.1 or above is recommended. (CHEN Gui-Wen and YAN Chao-Gan)

2. REST V1.2 can process multiple subjects with different covaribles in batch mode. Give the Covariables file as:
Covariables_List: (YAN Chao-Gan)

REST V1.0 and V1.1 ( were created by SONG Xiao-Wei in 2007.

Setup instructions:
1. Download most recent REST2007V1.3_{date}.zip (such as according to the date and extract it to a directory.
2. Add this directory to MATLAB's path.
3. Enter "rest" in the command window of MATLAB.
4. Enjoy the simple way to process resting-state fMRI data.


Predefined Types:

Dear Dr Zhang

there is an issue with choosing bivariate coefficients for ROI mode in GCA -  the error message suggests that 'comptn' is incorrect

also - can you explain how the multivariate works when there are only 2 ROIs

i am trying to make sense of the output file in multivariate ROI based GCA (for 2 ROIs)

what do the columns and rows specify?

thank you


Thanks a lot for your testing!

Could you paste all the error information here? Also, the multi ROI approach is only for coefficient based.

Zhen-Xiang, could you put your read me file online?



120912: Fixed a Bug in FC analysis (multiple ROI definition). And REST Reslice Image GUI support .nii(.gz) now.
              Thanks for the bug report from Richard Bethlehem!

Dear Chao-Gan

v: 1.8PRE

IN bivariate coefficients based GCA analyses, I am having problems with y2x maps.
I have now seeded two voxels and both must ave some significant y2x influences, but I repeatedly get unexpectedly no signals for y2x maps on one sample t tests. I find this puzzling as x2y maps initially from roi A suggested that roi B is influenced by roi A, but when I use roi B in the GCA, i dont find roi A showing even a weak signal.

Any advice will be useful,

1. Fixed a major bug in REST VMHC GUI: an error in Fisher's r-to-z transformation in rest_VMHC_gui.m. Please recalculate the z scroes for VMHC if you used REST VMHC GUI to calculate VMHC. However, if you used DPARSF's automatic pipeline script, the results are correct. Thanks for Wei Liao's report.

2. Fixed a bug in ROI-wise FC in fc.m: cannot recognize .nii ROI files. Thanks for Richard Bethlehem's report.

3. Fixed a bug in rest_GRFCorrection_gui.m: cannot transfer the file name to rest_GRF_Threshold.m. Thanks for Li Wang's report.


如果需要预处理,将功能像配准到对称模板,可以采用DPARSFA pipeline。