Department of Biomedical Engineering and Computational Science BECS

An SPM toolbox for removing periodic noise in fMRI data

Maintainers: Arno Solin ( and Simo Särkkä (


Date Bulletin
2012-04-25 Fixed broken RETROICOR support.
2012-04-17 The toolbox has now been fully updated. The changes include: complex-valued data accepted, changed the way data is loaded in SPM (support for larger matrix sizes without running out of memory), empty matrices now interpreted as unset, accepts 1D data for filtering, checks online for updates on each run.


This SPM toolbox is an implementation of the DRIFTER algorithm [1], which is a Bayesian method for physiological noise modeling and removal allowing accurate dynamical tracking of the variations in the cardiac and respiratory frequencies by using Interacting Multiple Models (IMM), Kalman Filter (KF) and Rauch-Tung-Striebel (RTS) smoother algorithms.

The frequency trajectories can be either estimated from reference signals (e.g., by using pulse meters and respiratory belts), or if the time resolution allows, directly from the fMRI signal. The estimated frequency trajectory is used for accurate model based separation of the fMRI signal into activation, physiological noise and white noise components using Kalman filter and RTS smoother algorithms. This separation is done for each voxel in the image separately. The basic idea of the method is to build a stochastic model for each component of the signal: the cleaned BOLD signal (including haemodynamical effects) is a relatively slowly varying signal, cardiac and respiration induced noise components are stochastic resonators with multiple harmonics, and the rest of the signal is white noise.

To get started using the DRIFTER toolbox, the user is required to specify at least the following parameters for the data section: EPI files (the fMRI data files) and TR (Repetition time in ms). And for each reference signal: Reference signal data, the Sampling interval, and a List of possible frequencies.

The physiological noise components are usually cardiac- and respiration-induced signals. However, the toolbox is not limited to these two in any way. Furthermore, the toolbox interface lets the user modify virtually every parameter in the estimation process. The default setup is not optimized for any particular purpose, and the user is encouraged to test the effects and abilities of the toolbox for the particular data at hand.

For further details on the methodology, refer to the article [1], and for instructions how to use the toolbox, scroll down for the toolbox manual.

The animated demonstration above should be playable in most modern web browsers. The two figures on the left show the slice orientation and one voxel chosen for further study (marked with a white dot). The upmost figure on the left side shows the noisy voxel time series together with the cleaned brain signal (the measurement noise not added back), the next figure shows the estimated physiological oscillator components, and the figure at the bottom the white measurement noise component. The TR in this study was 100 ms, as is the frame rate in the video.

References and DRIFTER Related Publications:


Download the latest version of the toolbox as a ZIP file. Unzip the file. Copy the DRIFTER folder to your SPM toolbox folder that can be found directly under your SPM path. SPM should now recognize the DRIFTER toolbox once you start the application in Matlab. The toolbox has been tested only with SPM8, and it can also be run without SPM.

Toolbox ZIP-file (2012-04-25) Toolbox Documentation (2012-04-17)

License and Referring

Please cite the DRIFTER Reference Paper [1] when you have used DRIFTER for data analysis in your study.

This software is distributed under the GNU General Public License (version 3 or later). You should have received a copy of the GNU General Public License along with this program. If not, see

Basic Usage

The figures below demonstrate how to access the toolbox functionalities through the graphical user interface in SPM. Only some parameters are obligatory and the toolbox can be configured in a couple of easy steps.

Illustrative screenshot of toolbox use.

Code Examples

SPM Batch Example

The toolbox can easily be used in batch mode. It creates an SPM batch job structure which can be run using the normal spm_jobman method in SPM. Below a basic example of the toolbox use is demonstrated. Refer to the more advanced settings above to modify the job structure.

The example data and the batch code is included in the toolbox zip-file. A step-by-step version of the code (written by the Matlab publish functionality) is available. Move to the 'demo_drifter' code.

An Example of Running DRIFTER Without SPM

The toolbox can also be run without SPM by calling the drifter function in Matlab. Make sure the DRIFTER code folder is in your path before calling the function. The function takes to input arguments: a data structure that defines the data that is used, and a refdata cell array defining the periodic components that will be estimated.

The batch code is included in the toolbox zip-file. A step-by-step version of the code (written by the Matlab publish functionality) is available. Move to the 'demo_drifter_no_SPM' code.