nipreps / smriprep

Structural MRI PREProcessing (sMRIPrep) workflows for NIPreps (NeuroImaging PREProcessing tools)
https://nipreps.github.io/smriprep
Apache License 2.0
132 stars 39 forks source link

On the feasibility of replacing N4BiasFieldCorrection with SPM Segment #153

Open dangom opened 4 years ago

dangom commented 4 years ago

Hi guys,

I've noticed anecdotally (though I've heard this from others as well) that for better FreeSurfer surface reconstruction, the choice of bias field correction makes a huge difference. In this regard, the SPM bias field correction tends to perform much better than the N4 algorithm.

In order to use the SPM bias field correction and still benefit from smriprep, I'm thus left with 2 options:

  1. run SPM bias field correction BEFORE smriprep

This should work, but requires that I replace the original T1 with a bias corrected in my experiment-datasets BIDS directory, which is OK but goes against the principles of reproducibility I suppose. Once N4 comes along, there should be no bias to estimate, and so N4 should hopefully act as no-op. Somewhat hacky and not something I'd like to rely on.

  1. replace N4 with SPM in smriprep

Replacing N4 with SPM in workflows/anatomical.py seems trivial, and I'd be willing to provide a PR if there is interest. However, given that SPM requires Matlab, I don't know how this pans out for docker/singularity containers. And even if N4 were not to be replaced with SPM in master, I would like to be able to use my own fork. Is it currently possible to pass a patched smriprep directory for an fmriprep singularity image? And how does one go about having the container access the external Matlab?

Any tips of suggestions are most welcome. As always, thanks for this awesome project.

Possibly related #7

mafortin commented 2 years ago

@dangom any updates about that? I've randomly ended up on that issue and was wondering about the "flexibility" of the sMRIPrep pipeline in general (I'm a new sMRIPrep user).

dangom commented 2 years ago

For end users, flexible as a diamond by design. The goal is to be robust, not malleable. I moved away from sMRIPrep because I wanted to switch to FS 7, and at that time sMRIPrep still relied on FS 6. I haven't checked whether that's changed already - if so maybe it's time to give it a try again. With that said, there is no problem at all in just running the SPM bias field correction before sMRIPrep. That works without issues. Replacing N4 for SPM is not the way to go since it requires Matlab. Ideally someone would bite the bullet and reimplement the SPM algo outside of matlab, and then replacing N4 could be a project worth pursuing (if NNs don't replace the SPM bias field correction by then, that is).