Scrub parameter nilearn.interfaces.fmriprep.load_confounds


I am using nilearn.interfaces.fmriprep.load_confounds to create a sample_mask to scrub my resting state images (preprocessed in fmriprep). The function works really well - thank you for developing this. However in addition to removing the flagged volumes, I would also like to remove 1 volume 1 after the high motion volume. This is my code (note that I set DVARS super high because I dont want to flag volumes based on DVARS):

confounds_scrub, sample_mask = load_confounds(

How should I set the ‘scrub’’ parameter to achieve removing volumes around the flagged volume (e.g. one after)? I played with the parameter, setting it to 0 then 1 then 2 etc but it is not doing what I thought it would do.

On the github page the parameter is defined in the following way: Scrub, default 5: After accounting for time frames with excessive motion, further remove segments shorter than the given number.

What does that exactly mean?

Thank you in advance for your help!

Hi @NinaD,

The scrub parameter says that after removing motion outliers, no segments of volumes shorter than the scrub value are allowed to exist. So if it was set to 5, for example, and you had initially scrubbed volumes 1 and 5 due to motion, then volumes 2-4 would also be removed, because that remaining segment length of 3 is less than the supplied value of 5. The reasoning comes from Power et al 2012 that recommends that short discontinuous segments might confound connectivity estimates.

If you want to remove volumes immediately after initially scrubbed volumes, you might have to go about confound removal more manually, editing the motion outliers columns either in the confounds tsv or after loading it into python.


Thanks Steven! In my case it is for pattern similarity analyses at a TR to TR basis so discontinuous events should not be a problem. I will go with a manual approach - does not take much effort to just manually adjust the sample_mask.


1 Like