# Neuroimaging Data Processing/Processing/Steps/Temporal Filtering
## Concept

Temporal filtering aims to remove or attenuate frequencies within the raw signal, that are not of interest. This can substantially improve the SNR. The tricky thing is to decide which frequencies are of interest and which are noise.
Frequencies of interest: In task-based fMRI mostly frequencies around the task-frequency are of interest (e.g. when presenting a stimulus every 5 sec, one would expect a response signal to also have a frequency around 0.2 Hz).
Noise Frequencies: Frequencies that are usually considered as noise are very low frequency trends (~< 0.01 Hz, linear or non-linear) resulting from scanner drifts, coil interference or slow vascular/metabolic oscillations as well as high frequency physiological fluctuations like breathing (~0.3 Hz) or heartbeat (~1.0 Hz)

#### Fourier Transform

Temporal filtering relies on the Fourier Transform: any series of data can be expressed as a linear sum of sine waves of different frequencies/amplitudes/phases. Thus a signal of intensity by time (or space) can be converted to a frequency spectrum, reflecting the contribution of each frequency to the signal (power by frequency). The frequency range covered by the spectrum depends on the sampling rate (TR), the highest identifiable frequency is 1/2 TR (Nyquist frequency). The contribution of higher frequencies will be aliased, i.e. artificially expressed, into lower frequencies.

#### Detrending

Prior to frequency based filtering, the data is usually also detrended using linear, quadratic or higher order polynomial algorithms or sometimes wavelets (seefor a comparison) Detrending is usually implemented as part of the temporal filtering method.

## Different Filters
#### High-pass filters

High pass filters cut off frequencies below a certain threshold which of course should below the lowest frequency of interest. Since in fMRI, noise is disproportionally expressed in low frequencies, high-pass filtering can also help whiten the noise (i.e. flattening the noise spectrum), which helps fulfill GLM assumptions. A very broad rule of thumb is to use a high-pass of 2-3x task frequency in task-based fMRI. The default in software ranges between 100-128 sec which is appropriate for trial length between 8-45 sec.

#### Low-pass filters

Low-pass filters attenuate high-frequency noise and are sometimes also referred to as temporal smoothing. They are often constructed as not merely a cut-off but in the shape of a canonical HRF in order to enhance signals of that shape (matched filter theorem). They also introduce a high degree of autocorrelation into the signal, which once was put forward as a way to deal with serial autocorrelation in the signal (called precoloring). But see Controversy

#### Band-pass / band stop filters

If only a limited frequency range is of interest, the signal can be filtered on specifically this band (band-pass). On the other hand, if a certain frequency is known to reflect only noise, it can be removed specifically from the signal (band-stop).

## Resting State

Resting state fMRI is mostly interested in low frequency fluctuations (< 0.1 Hz). But see. Therefore, most rsfMRI studies use a band-pass filter on frequencies between 0.01 Hz – 0.1 (or 0.08) Hz. But see Controversy

## Controversy

While high-pass filtering is used in most studies, low-pass filtering is controversial. It has been shown to decrease detection sensitivity w/o really increasing specificity Imposing a high level of autocorrelation on the signal it violates the temporal independency assumptions which are used for statistical testing. In rsfMRI it has been argued that band-pass filtering introduces spurious correlations, which should be accounted for by correcting for temporal filtering.
Physiological noise should anyway be addressed using Physiological noise regression especially since it is often undersampled and aliased into lower frequencies. However, most resting state studies additionally rely on low-pass filtering (band-pass filtering to be precise) to be even more on the safe side in terms of removing high-frequency noise.
Autocorrelation is often dealt with by means of pre-whitening in task-based fMRI. This has also been suggested for resting state fMRI where low-pass filtering might actually accelerate the problem of autocorrelation. However, for oscillating signals like BOLD time series a degree of autocorrelation is actually very natural. Eliminating autocorrelation eliminates important information from the time series. Prewhitened time series would only show correlation if the two signals are correlated with lag zero. However, this is rather unrealistic, given we are looking at BOLD responses which arguably differ across different brain regions even if the neural signals would be perfectly correlated.

## Implementation
#### AFNI

3dBandpass is used for FFT-based temporal filtering in AFNI.
Where fbot is the lowest andt ftop the highest frequency in the bandpass in Hz. To only low- or high pass one can use fbot=0 or ftop=99999 (or ftop> Nyquist frequency), respectively. However, the mean and Nyquist frequency are always removed. The procedure by default includes a check for initial transients and constant linear and quadratic detrending*, which however can be switched off (-notrans, -nodetrend). Other options are despiking (-despike), including other time series to also band-pass filter and orthogonalize the original time series to (-ort, -dsort), blurring inside a mask (-blur, -mask / -automask), calculation of local principal vectors.
NOTE: Detrending is also part of 3DToutcount (see Data Quality) and can be called explicitly with 3dDetrend
3dFourier is a less complex alternative for FFT filtering, where low- and or high-pass frequencies are included as options -lowpass f / -highpass f. 3dFourier has fewer options. However it can used to create a notch filter which does not seem to be possible with 3dBandpass
In afni_proc.py use the regression block for temporal filtering

#### FSL

Highpass temporal filtering uses a local fit of a straight line (Gaussian-weighted within the line to give a smooth response) to remove low frequency artefacts.
This is preferable to sharp rolloff FIR-based filtering as it does not introduce autocorrelations into the data.
Using GUI selecting FEAT FMRI analysis --> Pre-stats --> Temporal filtering --> High Pass --> check or uncheck
Lowpass temporal filtering reduces high frequency noise by Gaussian smoothing (sigma=2.8s), but also reduces the strength of the signal of interest, particularly for single-event experiments.
It is not generally considered to be helpful, so is turned off by default. By default, the temporal filtering that is applied to the data will also be applied to the model.
Filtering can be accomplished using `fslmaths` with the option `-bptf <hp_sigma> <lp_sigma>`. Either sigma may be set to a negative value to disable that filter. Example:

#### SPM

Por favor pongan información aquí
Gracias

## References

http://mindhive.mit.edu/node/116
* ↑ Jody Tanabe, David Miller, Jason Tregellas, Robert Freedman, Francois G. Meyer, Comparison of Detrending Methods for Optimal fMRI Preprocessing, NeuroImage, Volume 15, Issue 4, April 2002, Pages 902-907, ISSN 1053-8119, http://dx.doi.org/10.1006/nimg.2002.1053
* ↑ K.J. Friston, O. Josephs, E. Zarahn, A.P. Holmes, S. Rouquette, J.-B. Poline, To Smooth or Not to Smooth?: Bias and Efficiency in fMRI Time-Series Analysis, NeuroImage, Volume 12, Issue 2, August 2000, Pages 196-208, ISSN 1053-8119, http://dx.doi.org/10.1006/nimg.2000.0609.
* ↑ Boubela Roland Norbert, Kalcher Klaudius, Huf Wolfgang, Kronnerwetter Claudia, Filzmoser Peter, Moser Ewald , Beyond noise: using temporal ICA to extract meaningful information from high-frequency fMRI signal fluctuations during rest, Frontiers in Human Neuroscience, Volume 7, 2013, http://www.frontiersin.org/Journal/Abstract.aspx?s=537&name=human_neuroscience&ART_DOI=10.3389/fnhum.2013.00168
* ↑ Skudlarski et al. (1999), "ROC analysis of statistical methods used in functional MRI: individual subjects" NeuroImage, 1999, doi: 10.1006/nimg.1999.0402
* ↑ Della-Maggiore et. al (2002), "An empirical comparison of SPM preprocessing parameters to the analysis of fMRI data," NeuroImage, 2002, doi: 10.1006/nimg.2002.1113
* ↑ Catherine E. Davey, David B. Grayden, Gary F. Egan, Leigh A. Johnston, Filtering induces correlation in fMRI resting state data, NeuroImage, Volume 64, 1 January 2013, Pages 728-740, ISSN 1053-8119, http://dx.doi.org/10.1016/j.neuroimage.2012.08.022.
* ↑ P Christova and S M Lewis and T A Jerde and J K Lynch and A P Georgopoulos, True associations between resting fMRI time series based on innovations, Journal of Neural Engineering, Volume 8, Issue 4, 2011, http://stacks.iop.org/1741-2552/8/i=4/a=046025
* ↑ http://afni.nimh.nih.gov/pub/dist/doc/program_help/3dBandpass.html
* ↑ http://afni.nimh.nih.gov/pub/dist/doc/program_help/3dDetrend.html
* ↑ http://afni.nimh.nih.gov/pub/dist/doc/program_help/3dFourier.html