[ENH]: Add scrubbing support in fMRIPrepConfoundRemover #421
No reviewers
Labels
No labels
CRITICAL
Stale
WIP
bug
concept
coordinate
dataset
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
maintenance
maps
marker
mask
on hold
parcellation
preprocess
question
ready
storage
template-space
triage
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
juaml/junifer!421
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/fmriprepconfoundremover-dvars-scrub"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR adds scrubbing support in
fMRIPrepConfoundRemoverby usingstd_dvarsfrom fMRIPrep output.Codecov Report
All modified and coverable lines are covered by tests ✅
❌ Your project status has failed because the head coverage (85.72%) is below the target coverage (90.00%). You can increase the head coverage or adjust the target coverage.
Additional details and impacted files
85.72% <100.00%> (+0.05%)Flags with carried forward coverage won't be shown. Click here to find out more.
99.46% <100.00%> (+0.07%)std_dvars should not be added as a regressor to perform scrubbing, but used to generate a mask that is then passed on to
signal.cleanSo the mask would be temporal which should remove the timepoints from both BOLD image and confounds table and then pass the result to
nilearn.image.clean_img()?https://juaml.github.io/junifer/pr-preview/pr-421/
Built to branch
gh-pagesat 2025-01-29 11:06 UTC.Preview will be ready when the GitHub Pages deployment is complete.
Two comments:
I think the implementation should come from nilearn: https://nilearn.github.io/stable/modules/generated/nilearn.interfaces.fmriprep.load_confounds.html#nilearn.interfaces.fmriprep.load_confounds
Basically here you can set the
fd_thresholdandstd_dvars_thresholdand it will give you thesample_masknilearn.image.load_confoundshas a parameterstd_dvars_thresholdfor scrubbing, so I went for it as well. We support FD via thespikeparameter offMRIPrepConfoundRemover.It generates a mask for indexing the time dimension and passes it to
nilearn.image.cleanas you suggested in your previous comment.We don't use
load_confoundsbut select the confounds we want to remove and pass it tonilearn.image.clean_img. Also,load_confoundsrelies on the confound file by following the path from the image file. Is that something we go for?spikeis to add as a regressor, which is not scrubbing:github.com/juaml/junifer@e392c7bef7/junifer/preprocess/confounds/fmriprep_confound_remover.py (L411)I see that you use
input["confounds"]for the scrub mask and notconfounds_df. We are good as long as dvars or any confounds used for the scrubbing appear in the confounds ofclean_imgWe need to somehow "mimic" that behaviour. That's what I meant. The scrubbing mask can be either from dvars or fd.
Do the new commits address it?
We are still missing the
fd_thresholdand thescrubparameter. Also check the reference for scrubbing: https://www.sciencedirect.com/science/article/abs/pii/S1053811913009117?via%3DihubCoverage is low, meaning that we are missing tests.
Just so that it's explicit:
strategytake a key namedscrubor does one pass it via the parameters?load_confoundsdocs:“scrub” regressors for Power et al.[[3]](https://nilearn.github.io/stable/modules/generated/nilearn.interfaces.fmriprep.load_confounds.html#footcite-power2014) scrubbing approach. Associated parameter: scrub, fd_threshold, std_dvars_threshold. It treats them as "regressors" and when you pass"scrub"in thestrategy, it does not return eitherframewise_displacementorstd_dvarsin the returned confounds dataframe.I thought the columns should be in the returned dataframe?
std_dvars_thresholdis currently implemented for fMRIPrepConfoundRemover, I can addfd_thresholdas well. I'm not sure howscrubis supposed to be implemented?@fraimondo would really appreciate your feedback to the previous comment.
I've updated the interface and also improved the logic by replicating nilearn's implementation, would appreciate a review @fraimondo @kaurao
Here you add the required variables for scrubbing to the df. Are they used later as regressors? Or they are not considered?
I fear that we might be regressing out this variables too.
You can actually check the thresholds and which samples should be removed here.
Motion outlier regressors are generated using the thresholds:
github.com/nilearn/nilearn@7a8cd0ee71/nilearn/interfaces/fmriprep/load_confounds_components.py (L222)and then added to the df:github.com/nilearn/nilearn@7a8cd0ee71/nilearn/interfaces/fmriprep/load_confounds.py (L484)which then gets processed to generate the sample mask and the added motion outlier regressors are removed to return the proper confounds. This is leveraging nilearn's implementation so no code of ours should affect it.ok then.
Once CI is ready, we can merge