nipreps / niworkflows

Common workflows for MRI (anatomical, functional, diffusion, etc)
https://www.nipreps.org/niworkflows
Apache License 2.0
90 stars 52 forks source link

Improvements when using N4BiasFieldCorrection #388

Closed oesteban closed 5 years ago

oesteban commented 5 years ago

As a result of a thorough bug report from @Shotgunosine, in ANTsX/ANTs#822 several recommendations we should adopt for fMRIPrep are given:

effigies commented 5 years ago

From my understanding, we don't need to rescale, we just need to threshold the outputs of registration to >= 0.

Shotgunosine commented 5 years ago

Thresholding actually didn't fully address the issues. Rescaling did work on that one test case though. I'm debugging another issue that may be related to this one and will try to get more information shortly.

On Thu, Aug 29, 2019 at 9:11 AM Chris Markiewicz notifications@github.com wrote:

From my understanding, we don't need to rescale, we just need to threshold the outputs of registration to >= 0.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/poldracklab/niworkflows/issues/388?email_source=notifications&email_token=ABILLGC7J4LNZ36EC36USNLQG7DJJA5CNFSM4IQSYSL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5ONQOQ#issuecomment-526178362, or mute the thread https://github.com/notifications/unsubscribe-auth/ABILLGDWJEBX4JDJBB5RWLLQG7DJJANCNFSM4IQSYSLQ .

oesteban commented 5 years ago

Thresholding changes the distribution and the step it creates is exaggerated by the initial log transform of N4. It makes sense that rescaling works better.

effigies commented 5 years ago

If the issue is interpolation-induced negative values, then it's not clear that preserving that particular aspect of the distribution is worthwhile, as it's already an artifact. Rescaling while preserving these artifacts could shift the background noise up significantly.

oesteban commented 5 years ago

It is undesired and it doesn't make sense as MRI signal, but not an artifact. BSpline interpolation can do this to ensure continuity of the distribution, which is necessary for N4 to find the bias field, which will become an additive offset after log transform.

Finding truncated values breaks the continuity constraints of the BSplines modeling the bias field.

Shotgunosine commented 5 years ago

As I'm trying to track my other masking bug down with this data, I've found that the output of split_opt_comb appears to already be partially brain masked. Is that correct behavior? If it is supposed to be masked, is that discontinuity going to disrupt the N4 normalization that happens when masking the bold after transformation to standard space?

effigies commented 5 years ago

Okay. So what if we transform the uniformized image, rather than uniformize the transformed image?

effigies commented 5 years ago

But @Shotgunosine, I think the issue here was specifically with blip-up/blip-down, which are registered to each other and then N4-corrected? Or was it the EPI masking in template space?

Shotgunosine commented 5 years ago

Yeah, that was where the N4 issue was occurring for this particular failure. I'm trying to track down other masking/registrations issues with other scans from this same dataset and I'm suspicious that those other issues may also be related to this same N4 issue. I can move questions about debugging that out to another thread till I've confirmed those suspicions though.