Linear trend removal

 Hi all,
Sorry to post this issue again, but I was hoping for some clarification so I can progress with my analysis.

I just have a question about the detrending and filtering. I have been looking at ROI time courses at various stages of detrending and filtering. 
I have noticed that after detrending, the linear trend does indeed seem to be removed, as is expected.
After filtering (.008 to .08 Hz) only (without detrending), I can clearly see the slower oscillations, although the linear trend is still present, as would be expected.
However, after detrending + filtering, the oscillations become very regular, and the time course has a strong linear trend.

This seems strange to me. Does the trend get added back into the time course during filtering? Does this sound normal?

Thanks for your help,

You may read rest_bandpass.m and you could use all REST's codes to build your personal preprocessing steps without REST's GUI.
Some REST's codes, specially filtering, adapts the same way of AFNI's codes.

In total, I think, REST's GUI is just a simple tool I made to help researchers easily get famillar with resting-state fMRI's data processing. However, under REST's GUI, there are many procedures/modules could be defined personally, like REST's fALFF, DPARSF and so on.

 Thanks for your response. I still have a few questions though.

1 - running rest_bandpass from the command line, there is an option to add the linear trend back to the data. I believe this is what happens by default when using the GUI. Can I ask why you would want to remove the trend, and then add it back in? Won't this cause spuriously high correlations in connectivity analyses?

2 - If I choose 'No' for adding the trend back in, the resulting volumes do not look like standard epi volumes, but rather look like statistical maps (e.g., very splotchy; see below). However, the time series look as they should be (i.e., detrended and filtered). Why do the images look like this?

3 - If I choose 'Yes', for adding the trend back in, the image look like normal epis, but the time series are very strange. In most voxels of my 840 volume dataset, I can see relatively small oscillations (intensity range 630-650) up to volume 600. After volume 600, there are a few massive oscillations, ranging from intensities 0 to 700 (see below). This seems very strange to me. Do you know why it occurs?

 Sorry, seems like pasting the pictures did not work. Is there some other way I can get the images to you if my written description does not make sense?

There seems to be something wrong with the image upload, I would revise it lately.
You may temporarily upload shared file to our public ftp ( ftp:// pub_upload : restfmri @ ).

Then your file's url would be:
which you should replace YOURFILENAME with your true file name.
( Blank in filename is not recommended. )


I'm sorry, but I tried to login and it asked me for a password. Do I need one, or is there a way to upload the files without a password?

Username: pub_upload
Password : restfmri
Ftp Upload address:

Sorry for I didn't make it very clear.

 Great, I've uploaded the files now as

There are two directories: one is called 'pcc_seed', which contains images of the time series for a 6mm spherical posterior cingulate seed region, while the other is called 'voxel', which contains the time series for a single voxel. I have included both because the results are quite different.

Within each directory, there are images of the time series after different stages of pre-processing.
_raw_ts is the raw time series, before any detrending and filtering.
_gui_detrend_only means that only detrending was performed, through the gui.
_gui_filt_only means that only temporal filtering (.008 to .08 Hz) was performed, through the gui.
_gui_detrended_filtered means that both detrending and filtering were performed through the gui.
_detrended_filtered_noretrend means that detrending and filtering were preformed using the rest_bandpass function, with 'No' selected for retrending.

In the voxel directory, there is also a picture of an EPI volume after detrending and filtering with no retrending.

For the voxel time series, detrending and filtering do strange things - the oscillations are very small until the last 200 volums, where they become massive. This pattern is consistent across many of the voxels I have examined. Detrending and filtering without retrending seems to give a more reasonable time series, but the actual images look like statistical maps rather than EPIs. I'm not sure why this is the case.

In contrast, filtering and detrending seem to produce reasonable results for the pcc seed time series, as does detrending + filtering with no retrending. However, with retrending (as is default through the gui), the timeseries becomes very regular. I'm not sure why this is the case.

So, my main questions, are:
1 - Why do the EPI volumes look like statistical maps after detrending + filtering with no retrending?
2 - Why do the voxel time series look so strange after detrending or filtering?
3 - Why does detrending + filtering with retrending (as through the gui) make the pcc time series so regular?
4 - Is there any reason why retrending is performed by default? I would have though that this would spuriously increase correlations between regions.

Thanks for your help,

Did you checked all your PCC time series?

I also suspected the preprocessing steps' contribution to correlational coefficients, however, I didn't testify this, so it is still a suspect. This may attribute to filter's algorithm, which may somehow do a rough detrend before filtering and add this trend back,  and it is according to a C algorithm book published in 1992.

 The PCC time series seem to behave as they should after each step of pre-processing; e.g., after detrending only, the linear trend is gone, after detrending + filtering with no retrending there is no linear trend and only the slower oscillations are retained, etc.

The timeseries for single voxels are however, somewhat strange. The only one that looks as it should is detrending + filtering with no retrending. Ultimately, this is the sort of pre-processing I want to do, because I imagine that adding the linear trend back into the data will cause spuriously high correlations. However, the images that get written our after detrending + filtering with no retrending look very strange (an example can be seen in voxel/vox_detrend_filtered_no_retrend_image, in the files I uploaded).

So, in summary, the pre-processing option that seems best to me is detrending + filtering with no retrending. The time series resulting from these steps seem as they should, but the volumes are quite strange. I don't know why the volumes look as they do.