Resting-State fMRI Data Analysis Toolkit V1.6 (静息态功能磁共振数据处理工具包 V1.6)

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 and perform statistical analysis. You also can use REST to view your data, perform Monte Carlo simulation similar to AlphaSim in AFNI, 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 REST_V1.6_110505.


Multimedia Course: Data Processing of Resting-State fMRI

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.... and supporting keep "shift" key to select multiple groups or images. (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. For extracting ROI signals, also support Multiple label values in a single mask file. 6. Fixed an error in the future MATLAB version in "[pathstr, name, ext, versn] = fileparts...".
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.

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.
3. For rest_sliceviewer, fixed a bug of in displaying with MATLAB 2010 and support mouse wheel operation.
4. Fixed a bug in converting .nii files into NIfTI pairs (.img/.hdr).
5. Added new function of "corr(i1,i2,'spatial')" in REST Image Calculator.
6. Now can open a yoked structural image in displaying power spectrum.
7. Now can also pick up .nii files in GUI of reslice image.

New features of REST V1.4 release 100426:
1. Fixed a reading and writing bug of compatibility with SPM8.

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.
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.
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).  (by 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]. (by 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. (by 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
2. Functions revised:
  (1) Make the outputname as 00001.img other than 1.img in REST Image Calculator.
3. Bugs Fixed:
  (1) Fixed a bug in ROI-wise functional connectivity calculation.

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:

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:

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.

2. Data in processing will not be converted to the format 'int16', and result data will be saved in the format 'single'.
3. Added "Correction Thresholds by AlphaSim" (under pull-down menu "Misc").
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.

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


New features of REST V1.2 release 090101:

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.

2. REST V1.2 can process multiple subjects with different covaribles in batch mode. Give the Covariables file as:

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.

If you think REST is useful for your work, citing it in your paper would be greatly appreciated:
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

Before the REST description paper, the citation was:
Resting-State fMRI Data Analysis Toolkit (REST, by SONG Xiao-Wei et al.,

 Mail to Authors: SONG Xiao-Wei; YAN Chao-Gan; DONG Zhang-Ye


 Multimedia Course: Data Processing of Resting-State fMRI


I intend to carry an analysis with REST-GCA. I would like to perform a simple functional connectivity analysis of the amygdala set as a seed-region. I have my data preprocessed and organized by subject name (no sub001, 002, etc, but: alexis89, elizab77, etc). I was wondering if I need to rearrange the directory by subject number or if I can still keep the data as it is. I was also wondering if there is a citation I could refer when using the method and also for further reference. Thank you,

Thank you very much for your interests in our work.

You can keep the data as it is.

The REST-GCA paper is in revision, hope it could be accepted successfully.

Currently, you can cite is as "(REST-GCA, by ZANG Zhen-Xiang et al.,".

Best wishes!

Thank you very much for your reply. I still have a few more questions if it is ok.
1. I would like to ask about my TR=3s. Is this too big for doing GCA?
2. Given this TR of 3s instead of 2s I was wondering if I also need to adapt the Band (hz) values.
3. For selecting the directory I wonder if I just need to select individual folders, or also add recursively all the subfolders of my subjects.
4. I have tried to run a Granger causality analysis with two ROIs (amygdala L and R), and for the Mask option I selected it as default.(given that I wanted the analysis for the whole brain). This gave the error below. So, I changed this option to "No Mask". I was wondering if by doing this I am still looking at correlations within the whole brain and the two ROIs.
Thank you in advance for your attention,

Load mask "Default".
Exception occured. ()
Error using ==> rest_loadmask at 37
There are no appropriate default mask file:
Volume size=79*95*69 ,Voxel size=2*2*2;
Volume size=53*63*46, Voxel size=3*3*3;
Volume size=91*109*91, Voxel size=2*2*2;
Volume size=61*73*61, Voxel size=3*3*3;
Please set bMask = 0.
37#line, rest_loadmask, in "/home/userbrain/Desktop/REST_V1.6_110505/rest_loadmask.m"
62#line, rest_bandpass, in "/home/userbrain/Desktop/REST_V1.6_110505/rest_bandpass.m"
796#line, BandPass, in "/home/userbrain/Desktop/REST_V1.6_110505/rest_gca_gui.m"
887#line, btnComputeGCA_Callback, in "/home/userbrain/Desktop/REST_V1.6_110505/rest_gca_gui.m"
96#line, gui_mainfcn, in "/home/userbrain/toolbox/matlab/guide/gui_mainfcn.m"
39#line, rest_gca_gui, in "/home/userbrain/Desktop/REST_V1.6_110505/rest_gca_gui.m"

Hello again. I just came across an additional question. I would like to compare two groups with two sample-t test. But for loading the data it needs the "group images". I would really appreciate if you could kindly direct me how to find these. I am not sure whether this is part of the outcome from the GCA or if I need to run a previous analysis first.
Thank you very much,

In group analysis, i.e., second level analysis, we usually need the first-level results from all subjects. I think this is the " group images ".
In GCA case, the first-level result can be the "GC brain" for each subject you got from GCA analysis.

Thank you very much for your answers.
If it is ok I have a conceptual question that I would like to ask about GCA:
1. I started doubting whether GCA is the right analysiss for me. I would like to examine all the possible connections from the amygdala, set as a seed region, to all the specific areas across the whole brain. When I found out that GCA gives coefficients of x2y, y2x and the Autoregressive coefficient for x and y, I wondered whether this will really tell me which specific areas are connected to the amygdala. I would like to ask you if this is correct or perhaps there is a way to map all the connections from the amygdala across the whole brain using GCA.
2. Regarding the question of group analysis. I haven't figure it out yet. I tried to follow your advice and run selected stats using my results by individual subject. But when I click "group images" and tried to load them it won't recognize any file. Do you have any idea what could be the problem?
Thanks again for providing REST toolkit,

I have an additional question if it is possible. I have data collected with the phillips format, which I had converted to analyze format. But given I have incompatibilities betwen de normalization of my data and REST- mask I decided to try preprocessing with DPARSF. Following the first step of sorting dicom files I notice that I cannot select my raw, given that is not dicom format. I also noted that for the preprocessing with DPARSF it asks for the dicom files as well. So, does this mean that I will have to steek to my initial preprocessing or there is a way to preprocess REC/PAR format images with DPARSF ?

Here is my two cents:
1. TR=3 seems donnot have big difference with TR=2 case. If TR=2 can do GCA, TR=3 is also good. However, to ensure this, you should check out literature to see if GCA study can use TR=3, although I think it's not a long TR:)
2. I can't get the reason why you need to change filtering parameters. Basically if you increase TR, you decrease sampling rate, so you cannot capture the fast changes (high frequency component) as those in case of small TR. Since the filtering parameters will change with your TR settings, you don't need to change it manually.
3. If you add all subjects' directory, the toolkit can process them one by one.
4. Seems like your images is not in standard space (i.e. not normalized), so the default mask cannot be matched with your current images. So the error jumps out. Possible solution is you should preprocess your data, at least make them in standard space, i.e. MNI space. If you insist processing your data in individual space, you can choose no mask, that's all right.

Hi I met the following error when I use AlphaSim in REST. It occurs for any masks I used. Does anyone know how to solve it?

??? Undefined function or method 'normrnd' for input arguments of type 'double'.

Error in ==> rest_AlphaSim at 61

Error in ==> rest_AlphaSim_gui>pushbuttonrun_Callback at 55

Error in ==> gui_mainfcn at 96

Error in ==> rest_AlphaSim_gui at 27
gui_mainfcn(gui_State, varargin{:});

??? Error while evaluating uicontrol Callback

Thank you!


Hi, this command need the support of Statistics Toolbox.