Menu

Package that provides tools for brain MRI Deep Learning pre-processing.

Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the gallery for the big picture.

brainprep.connectivity.func_connectivity(fmri_file, counfounds_file, mask_file, tr, outdir, low_pass=0.1, high_pass=0.01, scrub=5, fd_threshold=0.2, std_dvars_threshold=3, detrend=True, standardize=True, remove_volumes=False, fwhm=0.0)[source]ΒΆ

Compute ROI-based functional connectivity from fMRIPrep pre-processing.

This function applies the Yeo et al. (2011) timeseries pre-processing schema:

  • detrend.

  • low- and high-pass filters.

  • remove confounds.

  • standardize.

The filtering stage is composed of:

  • low pass filter out high frequency signals from the data (upper than 0.1 Hz by default). fMRI signals are slow evolving processes, any high frequency signals are likely due to noise.

  • high pass filter out any very low frequency signals (below 0.001 Hz by default), which may be due to intrinsic scanner instabilities.

The confound regressors are composed of:

  • 1 global signal.

  • 12 motion parameters + derivatives.

  • 8 discrete cosines transformation basis regressors to handle low-frequency signal drifts.

  • 2 confounds derived from white matter and cerebrospinal fluid.

This is a total of 23 base confound regressor variables.

According to Lindquist et al. (2018), removal of confounds will be done orthogonally to temporal filters (low- and/or high-pass filters), if both are specified.

Parameters:

fmri_file : str

the fMRIPrep pre-processing file: *desc-preproc_bold.nii.gz.

counfounds_file : str

the path to the fMRIPrep counfounds file: *desc-confounds_regressors.tsv.

mask_file : str

signal is only cleaned from voxels inside the mask. It should have the same shape and affine as the fmri_file: *desc-brain_mask.nii.gz.

tr : float

the repetition time (TR) in seconds.

outdir : str

the destination folder.

low_pass : float, default 0.1

the low-pass filter cutoff frequency in Hz. Set it to None if you dont want low-pass filtering.

high_pass : float, default 0.01

the high-pass filter cutoff frequency in Hz. Set it to None if you dont want high-pass filtering.

scrub : int, default 5

after accounting for time frames with excessive motion, further remove segments shorter than the given number. The default value is 5. When the value is 0, remove time frames based on excessive framewise displacement and DVARS only. One-hot encoding vectors are added as regressors for each scrubbed frame.

fd_threshold : float, default 0.2

Framewise displacement threshold for scrub. This value is typically between 0 and 1 mm.

std_dvars_threshold : float, default 3

standardized DVARS threshold for scrub. DVARs is defined as root mean squared intensity difference of volume N to volume N + 1. D refers to temporal derivative of timecourses, VARS referring to root mean squared variance over voxels.

detrend : bool, default True

detrend data prior to confound removal.

standardize : default True

set this flag if you want to standardize the output signal between [0 1].

remove_volumes : bool, default False

this flag determines whether contaminated volumes should be removed from the output data.

fwhm : float or list, default 0.

smoothing strength, expressed as as Full-Width at Half Maximum (fwhm), in millimeters. Can be a single number fwhm=8, the width is identical along x, y and z or fwhm=0, no smoothing is peformed. Can be three consecutive numbers, fwhm=[1,1.5,2.5], giving the fwhm along each axis.

Returns:

corrfiles : dict

the connectivity matrix resulting files.

Notes

Connectivity extraction parameters can be changed by setting the following module global parameters: CONNECTIVITIES, ATLASES.

Follow us

© 2025, brainprep developers