gastropy.neuro.fmri.regress_confounds#
- gastropy.neuro.fmri.regress_confounds(bold_2d, confounds_df, confound_cols=None)[source]#
Remove confound signals from BOLD data via GLM regression.
Performs ordinary least squares regression of confound regressors on each voxel’s BOLD time series and returns the z-scored residuals. This follows the approach used in standard fMRI denoising pipelines.
- Parameters:
bold_2d (array_like, shape (n_voxels, n_timepoints)) – BOLD time series for each voxel (e.g., from a masked NIfTI).
confounds_df (pandas.DataFrame) – Confounds table (e.g., from fMRIPrep
*_confounds_timeseries.tsv). Must have at leastn_timepointsrows.confound_cols (list of str, optional) – Column names to use as regressors. Default uses 6 motion parameters + 6 aCompCor components (12 regressors total).
- Returns:
residuals – Z-scored residuals after confound regression.
- Return type:
np.ndarray, shape (n_voxels, n_timepoints)
Notes
NaN values in the first row of derivative columns (common in fMRIPrep confounds) are replaced with 0 before regression.