PennLINC / xcp_d

Post-processing of fMRIPrep, NiBabies, and HCP outputs
https://xcp-d.readthedocs.io
BSD 3-Clause "New" or "Revised" License
73 stars 22 forks source link

Customizing motion scrubbing logic #724

Open Bramdiamond opened 1 year ago

Bramdiamond commented 1 year ago

Summary

Target volumes that exceed FD or DVARS thresholds. It would be nice to have the option to customize this boolean logic.

Next steps

For modified_data.py, add compute_dvars() and generate_mask() to include dvars. xcp_d options might include --dvars-thresh, --despike-logic <and, or>.

Additionally, xcp_p should be able to read FD/DVARS from fMRIPrep output.

tsalo commented 1 year ago

We discussed this in a recent meeting and agreed that it's a good idea. I like --dvars-thresh. Would you be willing to open a PR? If not, it might be a little bit before I'm able to implement this.

Bramdiamond commented 1 year ago

I've never submitted a PR, but I can take a look!

tsalo commented 6 months ago

We'll want to avoid extreme flexibility, so it would be great to limit this option to specific, established strategies. @Bramdiamond are you familiar with any citable approaches?

tsalo commented 5 months ago

I'm thinking of something like this:

--fd-thresh <FLOAT> [<FLOAT>]
--dvars-thresh <FLOAT> [<FLOAT>]
--censor-config [before=<INT>] [after=<INT>] [contiguous=<INT>]

I don't love how complicated it ends up being, but here's my thinking.

  1. The DCAN team prefers to fit the nuisance regression and perform the interpolation using one FD threshold, then censor the denoised, interpolated time series using a second, stricter threshold. Allowing a second, optional value for --fd-thresh and the new --dvars-thresh would support this behavior.
    • I believe the primary goal of this approach is to address the spreading of interpolated data to neighboring volumes by the temporal filter, but I will follow up with the DCAN team to make sure I'm understanding it correctly.
  2. Users would probably want to censor some number of volumes before and after the high-motion volumes, hence before and after.
  3. Users may want to censor short sets of low-motion volumes between censored volumes, hence contiguous. In this case, any runs of contiguous low-motion volumes shorter than the value would be censored.

One thing I'm not sure about is where the censoring should be done. On the one hand, we want to ensure that the nuisance regression is not adversely impacted by noisy volumes, which is what --fd-thresh is meant to address. On the other hand, interpolation + bandpass filtering + censoring with the original threshold will result in interpolated signal spread to neighboring volumes, so we need to apply some additional censoring unrelated to the nuisance regression.

Bramdiamond commented 5 months ago

Hi Taylor,

Thanks for returning to this!

I'm not familiar with a standard approach or recent research on the topic. I think the flags you've included above make the most sense. As for default values, I think that it worth a discussion.

Regarding when the censoring should be done, your guess is as good as mine. I think that Lindquist et al., 2018 was the first to propose filtering before nuisance regression.

Additionally, it would be helpful if frames censored for DVARS were identified on a time series plot just as frames censored for FD are on the summery PDF.