Physiological Log Extraction for Modeling (PhLEM) Toolbox


PhLEM is a Matlab toolbox written to extract physiological recordings during MRI scanning and estimate the signal phases so that they can be used as a covariate in your general linear model (GLM). The main output are optimized to be included as regressors in the GLM routines for SPM5 and has since been confirmed to work with SPM8. I cannot guarantee backwards compatibility for earlier SPM versions nor with another analysis packages.

PhLEM can generate multiple models of physiological noise to include as regressors in your GLM model from either ECG, pneumatic breathing belt or pulse-oximetry data.  These are described in the paper by myself and Vibhas Deshpande "Using pulse oximetry to account for high and low frequency physiological artifacts in the BOLD signal."  

Briefly, you can do 3 types of models:

  • RETROICOR:  A phasic decomposition method that isolates the fourier series that best describes the spectral properties of the input signal.  This was first described by Glover and colleagues.  See his website for more info (url). Note: In our implementation, the amplitude of respiration signals is discarded.  Future updates of the PhLEM toolbox will change this to be more inline with the traditional RETROICOR model).
  • Variation Models:  For low frequency signals (like the pneumatic belt and low-pass filtered pulse-oximetry) this does the combined respiration variance and response function described by Birn and colleagues (2008).  For high frequency signals (i.e., ECG or high-pass filtered pulse-oximetry), this generates the heart-rate variance and cardiac response function described by Chang and colleagues (2009).
  • Downsampled Model: Performs a simple filtering and downsampling of a raw signal as was done for the pulse-oximetry signal in Verstynen and Deshpande (2011).
These regression models are generated in Matlab but can easily be saved as text files to load into other programs.


Currently the loader functions for physiological data are written only for the Siemens Trio 3T system.  If you have loader functions written for other systems, feel free to send them along to me via email (see developer information below) and I'll incorporate them into the processing stream.

The main PhLEM functions were written in Matlab R2007a (7.4.0).  I cannot gaurantee backwards compatibility to earlier versions of this software.    In addition, the toolbox function (particularly the make_physio_regressors.m file) is designed to output regressors for use in SPM5.  Some attempt has been made to make the functions back compatible to SPM2.  If you manage to make any progress on making this work with other versions of SPM (or other analysis software), feel free to send it along and I'll put it in the code base.


The PhLEM toolbox depends on some functions drawn from the Signal Processing (temporal filtering) and Statistics toolboxes (distribution simulation and GLM functions) in Matlab.  Be sure these are in your path and updated before using.  If you have a good, free open-source alternatives to any of these dependencies, please email me (see Contact below) as I'd like to make this as independent as possible.


Some example presentations of the performance of this software can be found in the Downloads page.  Since this isn't necessarily using a novel method, these are just examples of what you can do with the software.


To find out more about the structure and functions in the PhLEM toolbox, visit the Tutorial page.

How to Cite

If you have had good luck using PhLEM and are submitting a paper for publication, please reference the following manuscript that describes how the toolbox works and its applications:
Verstynen TD, Deshpande V. "Using pulse oximetry to account for high and low frequency physiological artifacts in the BOLD signal." Neuroimage. 2011 Apr 15;55(4):1633-44. PubMed PMID: 21224001


This toolbox was written in active collaboration between myself (Timothy Verstynen)and Joern Diedrichsen, and John Schlerf.  The Siemens loader functions and basic testing were done in collaboration with Vibhas Deshpande who works for Siemens at the NIC.  If you contribute to the code base, I will of course acknowledge your contribution.


All code written here is distributed under the GPL License (version 3.0).  Any derivative work must thus fall under this license.  A copy of the GPL can be found here.


Email all inquiries and questions to timothyv [at]