Low-pass filter using basis functions (e.g., cosineXX)?


I would like to apply temporal-band-pass-equivalent filtering to my fmriprep output. I know there are concerns with “reintroducing” noise if one sequentially regresses out confounds (e.g., motion parameters) and proceeds in a subsequent step with a temporal filter such as a Butterworth (e.g., Hallquist et al., 2013, NeuroImage; Lindquist et al., Sept 13, 2018, BioRxiv). I currently high-pass filter my fmriprep-data using the CosineXX functions (included in the *confounds.tsv) along with other noise regressors (e.g., motion parameters, WM, CSF, etc.), but I am curious if this sort of basis function filtering is possible in the case of low-pass?

How might I obtain “low-pass CosineXX” equivalents for the stop-band above a certain frequency? Are there nipype functions for this? Am I understanding these basis functions in the correct way?


I’ll revamp this thread and ask @rastko to comment on this next Friday.

Sorry for the late reply, we missed this one out.

1 Like

pinging @rastko


Apologies for the slow response. As far as I can tell, your understanding of the basis functions is correct.

In short — in principle, it’s possible to use cosine basis functions to perform a bandpass (highpass + lowpass) filtering of the data. However, fmriprep currently generates a discrete cosine basis only for frequencies slower than 0.008 Hz, so in practice this will require a little bit of extra work.

To bandpass filter the data, you can thus either:

(i) use the same function that fmriprep uses to generate cosine time series and pass the relevant frequencies to regression later on, or

(ii) use a program that automatically generates the discrete cosine basis and performs the regression in a single shot (details below).

Option (i) is somewhat more flexible, since you’ll be able to fit the confound model to data at any analytic step. However, implementation can be quite complicated in practice, since the function lacks a nipype interface.

Option (ii), by contrast, is much more straightforward to implement — a single call to AFNI’s 3dTproject or nilearn’s clean_img, for instance, will generate the specified filter basis and perform regression — but might afford less control over when the denoising can be performed (since generating the cosine basis is coupled with the regression step).

In most cases, I think option (ii) should suffice. If, however, option (ii) doesn’t suit your needs, let us know — it’s possible that the features you need aren’t easily implementable yet, in which case a potential next step could be opening issues corresponding to those features.

Please let us know if there is anything else that we can help clarify.


Thanks for the detailed response @rastko , exactly what I needed! I’d prefer your option (i), as you note, offers more control about when the cosine filters are applied. I will explore how to implement cosine_filter() in my code and report back issues if I have them.



I used fMRIprep version 20.2.6 to preprocess single band resting state fMRI data. I would like to use the first 5 aCompCor components from CSF and WM in the nuisance regression step along with 6 head motion parameters and their derivatives, as described by Ciric et al. (2017). Initially, we also wanted to bandpass filter the data, for example, from 0.008 - 0.9 Hz. Is it possible/appropriate to bandpass filter the data when using aCompCor components which were generated from highpass filtered data?

Can we bypass using the cosine regressors in the regression matrix by using AFNI’s 3dTproject command with the -passband 0.08 0.09 argument to specify the filter and regress? Or is it only appropriate to use the aCompCor regressors on high-pass filtered data?

Thank you for your help,