Scrubbing 4D images after fMRIPrep preprocessing

Hi everyone,
I use nilearn.interfaces.fmriprep.load_confound to scrub the points after fmriPrep preprocessing,however, whatever the FD threshold value and std_dvars_threshold value are set,it don’t change in the fourth dimension of fmri data.
Why does this happen?
my script:

import nilearn 
from nilearn.image import clean_img
from nilearn.interfaces.fmriprep import load_confounds
import nibabel as nb
from nilearn.image import get_data
import numpy as np
from  nilearn.maskers import NiftiMasker
from nilearn.datasets import load_mni152_brain_mask 
img = "/mnt/sda1/fhao/fmriPrep/preprocessing_pipeline/drivatives/fmriprep/sub-042/func/sub-042_task-restingstate_space-MNI152NLin6Asym_res-2_desc-preproc_bold.nii.gz"
mask = "/mnt/sda1/fhao/fmriPrep/preprocessing_pipeline/drivatives/fmriprep/sub-042/func/sub-042_task-restingstate_space-MNI152NLin6Asym_res-2_desc-brain_mask.nii.gz"
img_data = get_data(img)
print(img_data.shape)
# mask_img = load_mni152_brain_mask(resolution=2)

# regress 36P
confounds,sample_mask =load_confounds(img, strategy=('motion', 'high_pass', 'wm_csf',"global_signal"), 
    motion='full', scrub=5, fd_threshold=0.5, std_dvars_threshold=1.5, wm_csf='full', 
    global_signal='full',demean=True)


#sample_data = get_data(sample_mask)
print(sample_mask)
masker = NiftiMasker(mask_img=mask, memory="nilearn_cache", memory_level=1)

regression_img = masker.fit_transform(img,sample_mask=sample_mask)
print(regression_img.shape)

terminal command result

(91, 109, 91, 120)
None
(120, 221655)
confounds,sample_mask =load_confounds(img, strategy=('motion', 'high_pass', 'wm_csf',"global_signal"), 
    motion='full', scrub=5, fd_threshold=0.001, std_dvars_threshold=0.1, wm_csf='full', 
    global_signal='full',demean=True)
(91, 109, 91, 120)
None
(120, 221655)

fmriprep command

fmriprep-docker  $bids $bids/derivatives/fmriprep participant \
         --participant_label sub-042 \
	--output-spaces MNI152NLin6Asym \
	--fs-license-file /mnt/sda1/Tian/Application/freesurfer/license.txt \
	--fs-no-reconall \
	--nthreads 40 \
	--omp-nthreads 20 \
	--clean-workdir \
	-w ./work/

Hi @fhaos123

Scrubbing refers to adding one-hot encoded vectors to your design matrix to regress out the effect of the high-motion volumes. You do not want to manipulate the timeseries because then your events timings would be not valid.

Best,
Steven

Best Steven
Appreciating your prompt reply! I understand it.

Hi,@Steven
https://neurostars.org/t/scrubbing-rs-fmri-images-using-nilean-clean-img/29507?u=fhaos123

I want to scrub exceeded a threshold of 0.5-mm framewise displacement or 1.5 standardized DVARS The scrubbed preprocessed BOLD image was then linearly detrended, band-pass filtered (0.01-0.08 Hz), confounder regressed (total of 36 confound regressors).If use this methods,this time volume should be less than 120,because I check the confound csv file whose several time points exceed this threshold.

If this time point’s high-motion exceed the threshold,I would like to know whether interpolate a value after scrubbing this points automatically during running the load_confound script.

Hi @fhaos123,

From load_confounds documentation: nilearn.interfaces.fmriprep.load_confounds - Nilearn

Returns:

confounds pandas.DataFrame, or list of pandas.DataFrame

A reduced version of fMRIPrep confounds based on selected strategy and flags. The columns contains the labels of the regressors.

sample_mask None, numpy.ndarray or, list of numpy.ndarray or None

When no volumns require removal, the value is None. Otherwise, shape: (number of scans - number of volumes removed, ) The index of the niimgs along time/fourth dimension for valid volumes for subsequent analysis. This attribute should be passed to parameter sample_mask of nilearn.maskers.NiftiMasker or nilearn.signal.clean. Volumns are removed if flagged as following:

  • Non-steady-state volumes (if present)
  • Motion outliers detected by scrubbing

No interpolation is done unless you provide the sample mask to NiftiMasker or signal.clean.

Also see the signal.clean documentation: nilearn.signal.clean - Nilearn

When performing scrubbing (censoring high-motion volumes) with butterworth filtering, the signal is processed in the following order, based on the second recommendation in Lindquist et al. [1]:

  • interpolate high motion volumes with cubic spline interpolation
  • detrend
  • low- and high-pass butterworth filter
  • censor high motion volumes
  • remove confounds
  • standardize

Best,
Steven

Hi @Steven
First of all, thank you very much for spending the time on my issue, I also have a question about sample_mask, because when I change the threshold, there may be a time point where the motion exceeds the threshold, but in the above code, the sample_mask is still None, even if I set the threshold very low.