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.