open-discussion > Including CompCor (CONN toolbox) into SPM batch
Showing 1-4 of 4 posts
Results per page:
Jan 30, 2019  03:01 PM | Sara Calzolari
Including CompCor (CONN toolbox) into SPM batch
Hello everyone,

I am preprocessing some fMRI resting-state data and would like to perform denoising using CompCor (CONN toolbox).
Is there a way to include denoising in my SPM batch? If not can I just preprocess data on SPM and then use conn only for denoising?

Thank you, this is the first time I analyse fMRI data so apologies for the basic questions.

Jan 31, 2019  07:01 AM | Lars Kasper - Translational Neuromodeling Unit, IBT, University of Zurich and ETH Zurich
RE: Including CompCor (CONN toolbox) into SPM batch
Dear Sara,

I am sure you can combine preprocessing in SPM with the conn toolbox for denoising.

However, if you want to stay within the SPM framework completely, we have implemented a simple version of aCompCor in the PhysIO Toolbox (, which is integrated with the SPM Batch Editor. All you need to put there is a dependency on the warped white matter/CSF (wc2*,wc3*) tissue probability maps from unified segmentation to specify those as noise ROIs, and the warped (and realigned etc.) fMRI time series, from which the time series shall be extracted.

The help in the batch editor, after installing the toolbox, should give you more details. PhysIO is part of the TAPAS suite, and more info on it can be found in the README (

All the best,
Feb 11, 2019  05:02 AM | Sara Calzolari
RE: Including CompCor (CONN toolbox) into SPM batch
Dear Lars,

many thanks for your reply, I will then use the PhysIO toolbox.

So, if I understood correctly,  in the SPM batch module "TAPAS PhysIO toolbox" I will have to focus just on the "model" part (see image attached), as I haven't collected physiological measures and I just want to perform aCompCor...correct? Can I just edit the batch script to delete the sections "log_files","scan_timing" and "preproc"?

Also, my preprocessing pipeline includes realignment (estimation and reslicing), slice timing, coregistration (estimate), segmentation, normalisation (write), smoothing. Anything else I would need for a successful denoising?

Many thanks for your help.

Feb 12, 2019  07:02 PM | Lars Kasper - Translational Neuromodeling Unit, IBT, University of Zurich and ETH Zurich
RE: Including CompCor (CONN toolbox) into SPM batch
Dear Sara,

concerning your first question how to setup the SPM batch: You can just start with the default batch that comes with the toolbox


and apply the following modifications:

  • Setting the log file names to empty values (press done w/o selecting a file in the batch editor)
  • Selecting model.noise_rois = Yes, and RETROICOR = No. In the noise_rois section, specify the fmri time series file (I would use the unsmoothed but normalized, preprocessed nifti file here) as well as the noise ROIs image files (the normalized tissue probability maps of white matter and csf, wc2* and wc3*, from unified segmentation would be a good choice). ROI thresholding and cropping as well as PCA number of components/explained share of variance can be set to your liking, see the attached examples.
  • You will still have to specify the sqpar values (number of slices, volumes, TR) to create the regressors in a meaningful way.
  • Everything else (scan_timing, preproc) can stay at its default values, because the modules are ignored, if no log_files are specified.

I have attached a batch that includes the PhysIO module, but makes a "refined" choice of the noise_rois parameters (basically adjusting their erosion/thresholding and number of components to robust values after visual inspection of the results when running with default values for my dataset).

Note that the output of the PhysIO module will only be the nuisance regressors for the GLM (as text file). In order to remove their variance from the nifti file, you will have to specify the GLM with those and then choose to "write residuals" in the model estimation module (or spm_write_residuals in the command line). There is one file (Res*) for each volume, and the new, preprocessed time series with noise filtered out is the combination of those. You can add a batch utility to create a single 4D file from these residual images as well. The attached batch file includes GLM, estimation, residuals and 4D file combination after the PhysIO module as well (*noise_regression.m). The only deviation from a classical GLM specification here is that the model only include multiple regressors, but no conditions, and that I set the masking threshold to 0.05 (instead of 0.8). This is very liberal, but avoids holes in the output nifti file which could otherwise occur in low intensity regions still of interest to your resting state analysis.

Concerning your question about the preprocessing pipeline, these seem to be the right modules in the right order (one could debate whether slice timing or realignment goes first, but often this is an empirical question). I would only advise to do the noise regression on the unsmoothed time series, because otherwise you might smooth gray matter voxels (and their temporal signature) partly into your noise ROI, and consequently regress them out of your data. You can smooth the data after denoising by adding this module at the end of this third batch.

I hope that helps!

All the best,