Integrating fmriprep and rapidart

As you might have gathered from my recent posts, I’m trying to build subsequent processing off of fmriprep outputs. One thing I’d like to explore is the inclusion of RapidART-identified outliers to be censored.

It’s not clear how best to do this. Specifically, what’s the best way of getting the fmriprep confound outputs into an input.realignment_parameters file that RapidART likes, and what should I tell rapidART the inputs.parameter_source is?

Thanks, and sorry if I’m missing something obvious!
Todd

You may want to write a simple function to pull out the correct parameters. I haven’t tested the following:

def get_mcparams(in_tsv):
    import os
    import pandas as pd
    pd.load_table(in_tsv).to_csv(
        'mcparams.tsv', delimiter='\t',
        columns=['X', 'Y', 'Z', 'RotX', 'RotY', 'RotZ'],
        header=False, index=False)
    return os.path.abspath('mcparams.tsv')

Once you have a function that gets you a whitespace separated motion parameter file, you can wrap it in a Function interface (nipype.interfaces.utility.Function(function=get_mcparams)). The motion parameters are already ordered in SPM format, so that would be the appropriate parameter_source.

That said, I’m sure the addition of a BIDS parameter source, which would do the column selection internally to the interface, would be accepted.

1 Like

Thanks, Chris. This seems fairly straight-forward. Do you know how to translate the FD calculation to RapidART’s norm_threshold? I ask because we’re re-implementing a protocol that calls an FD > .4 as an outlier volume, but I’m not sure what that looks like in terms of RapidART’s distance metric.

Thanks again!

1 Like

I’m not sure what the relation is between FD and RapidArt’s norm, though of course they’re highly correlated. You have FD in your confounds file, so you could calculate the norm, and get a rough ratio with mean(FD/norm).

1 Like

We could add precalculated norm ot confounds.tsv if there is a desire for such feature from user community.

I don’t know this for sure, but I suspect most people who are interested in the precalculated norm are probably interested in running rapidART anyway? I’m not sure ART’s norm measure is one that’s typically reported in descriptive motion summaries for publications. (Though, as always, I could be wrong…)

I’d guess there is a reasonable amount of interest in running rapidART at some point during preprocessing, but it’s hard to know how to implement this. At the least, it would be nice to simplify the handshake between fmriprep and rapidART (perhaps by making rapidART also accept the fmriprep confounds.tsv file as an input). I think it’s also worth considering whether you want to make running rapidART an option within fmriprep. On the one hand, it’s a fairly typical part of preprocessing for a lot of labs. On the other hand, the workflow for fmriprep gets complicated. You’d need a bunch of command-line flags to handle the ART parameters, which do vary between labs and between experiments/populations.

I think the approach of providing everything RapidArt needs is better than baking it into FMRIPREP, because different labs will use different thresholds (similar to traditional FD based scrubbing). Which implementation of RapidArt are you using?

I was thinking it’d be simplest just to use nipype.algorithms.rapidart from the current-ish version of nipype. Were you asking which nipype version I’m using or about nipype vs. non-nipype implementation?

I reread the discussion more carefully and I take back what I said. It seems that FMRIPREP produces everything you need to apply rapidART (realigned volumes and motion parameters).

I do like the idea of having new parameter_source class of BIDS that would do the parsing @effigies posted. Seems like an easy addition to nipype. @toddt - would you like to contribute such PR?