-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FSL's topup implementation (fmriprep >=21) significantly worse than AFNI's Qwarp (fmriprep <20) #2830
Comments
Hi @Gilles86. Thanks for this report.
We found a number of datasets where 3dqwarp performed significantly worse than TOPUP. @oesteban may remember more clearly, but I believe the issue was that TOPUP performed better on high spatial-frequency distortion.
It seems like this is probably correct. Have you manually tried TOPUP and 3dqwarp on your dataset to verify that it's the quality of the tools on your data, and not some issue with how we're preparing the data for the tools? |
The reasons to abandon
Personally, I'd love to avoid FSL in general (for the commercial limitations) and topup in particular (it's a rather opaque tool). Unfortunately, field map estimation and SDC are pretty hairy problems. My lack of time is making SDCFlows accumulate a number of use cases like yours where it fails dramatically. I'll have a deep look into this tomorrow CEST. THANKS much for your patience |
This would go against the philosophy of fMRIPrep. The first necessary step here is to determine where SDCflows is failing. At the most abstract level there are two main possibilities:
Then, within option (1) there could be several reasons for it not to work:
Within option (2) there are other problems:
Why the former implementation with For example, the implementation with AFNI does not give any flexibility on the acquisition parameters, and the effective echo spacing / total readout time parameter had to be the same on all the EPIs involved. The new implementation allows:
In addition, the new implementation intends to make the fieldmap more robust across sessions: previously, using a fieldmap estimated on one session to correct EPIs from other sessions was risky. Now, since only the coefficients are mapped without interpolations, there's guarantee that the fieldmap is going to be very very consistent across all EPIs. I will prioritize SDCFlows so that it gets more stable ASAP. But, unless (at least that's my view on the problem) |
In more succinct words: this is not a regression, this is a new bug and addressing the problem comparatively to fMRIPrep < 20 is IMHO the wrong approach. |
Okay. It seems like you (obviously) gave this more thought than I did! One comment though: for the pepolar-approach, if you're using identical EPIs but with opposite phase encodings, it doesn't really matter what And where do you propose we go next? Would it be helpful to have some of my data? |
Partially correct for (1) but incorrect for (2). For topup, the actual TRT values don't matter. What matters is the ratios between them. In the case of (2) the TRT is critical with a decent implementation of susceptibility distortion correction. The reason is that you first estimate the fieldmap in Hz. To convert that to a displacements field you need to scale by the TRT and voxel size.
This would definitely help in two ways. First, because you've hit an instance of a problem with very obvious consequences (easier to debug). And second, because if we manage to spot the problem, you will quickly benefit that the fix is rolled out :) So, if you don't have any problem with sharing some data privately, I will allocate time next week to debug this. SDCFlows is currently a can of worms and I'm the main blocker to take action. |
OK, @oesteban . I sent you an email. :) |
Okay, I bear good and bad news. The good news is that, as in #2835, the fieldmap estimation looks good:
The bad news is I just started testing, so I have no clue of how long this may take. One thing that is suggested by the data is that either the fieldmap estimation has the wrong sign or the phase encoding of your EPIs have. Indeed, your SDC'd images look worse than before correction. Interestingly, this is exactly where I got with @mgxd's data one year ago. I hope that so much accumulated evidence allows me to catch the problem. |
ok. thx for the update and working on this. Hope you catch the potential bug! |
Okay, I narrowed it down to a field flip when generalizing topup's coefficients output. I still don't know if this flip on the PE direction is caused by the fact that the first PE that goes into topup is I have also looked into @mgxd's data and I believe there could be additional issues because his data are LAS too, but the first PE direction fed into topup is j. |
I just confirmed the flip. I'm not sure though what should be patched - the generalization of topup coefficients, or the generation of an actual displacements field that unwarps the dataset. If it were the latter, then we should see this problem on GRE and SE fieldmaps too, from time to time. I'll start with topup and generalization to see where I can get. |
While debugging nipreps/fmriprep#2830, I've found this potential issue. Inserting this change before major bugfixes are pushed.
@Gilles86 - as discussed in nipreps/sdcflows#278, I believe I've gotten to a point where topup is executed and processed more reliably. However, I have the impression that either your images in the If you open the fieldmap EPI with polarity i and one BOLD run of the same PE direction you'll see that the distortions are opposed. If you then open the fieldmap EPI with PE i-, then you see it matches the distortion of the fieldmap. |
@oesteban – thank you so much for your efforts! Is there an easy way that I can run a development version of fmriprep to test your work on my data myself?
This is not my experience. If I open Maybe you are looking at different files or I'm misunderstanding you somehow? Are you saying that I have used |
Yes, this is what I suspect happened. If the two files have clearly opposite distortions, then their metadata should have opposite
Actually the opposite: the warp field (as in, displacements field that unwarps the distortion) will have reversed directions between two opposed PE runs. The field map (as in, the deviation from nominal |
Sure. But I that's what I see in my data? Could you give me a very concrete example of where this goes wrong? |
subject 39, that's the one I was testing on and inferred all of them would have the PE confused. However, you are right that for subject 34, if I take the two first examples you gave ( could you confirm that subject 39 shows this issue? Meanwhile, I'm going to extend my tests to the rest of subjects you gave me (this far I only used 38 and 39). |
I've also noticed similar issues in the SDC workflows between fmriprep versions 20 and 21. I've attached two screenshots, one for each subject's run 1 across two fmriprep versions. Version 20.2.0 appears fine, while version 21.0.2 performs quite poorly. I have spin-echo fieldmaps with 180 degree flipped PEDs: PA ( I'd be happy to share my data and fmriprep html reports if that would be helpful. |
Should this issue now be fixed in the 22.1.1 version of fmriprep? |
This should be resolved in the 23.2.0a1 release. |
What would you like to see added in fMRIPrep?
I have noticed that since fmriprep version 21, the PEPOLAR SDC workflow using AFNI's qwarp was replaced by the topup-program of FSL.
During my time working on ultra-high (<1mm) resolution 7T data, I've used both FSL and AFNI for PEPOLAR SDC correction, and I remember getting much better results using AFNI's implementation. I also remember Chris Gorgolewski pointing this out in an earlier version of fmriprep, when he implemented versions with both.
It now has become a concrete problem for me. I just collected a 3T dataset at a modest 2.5mm resolution with LR-encoding. The distortions are pretty bad and fmriprep 21, using fsl's topup, underestimates them severly. The result of this is that the distortions of my LR runs are very different from my RL runs. With fmriprep 20 this problem was way smaller.
Note how in fmriprep 21, the gray matter in the EPI image really extends outside of the GM/CSF border in right frontal cortex. The issue is much less-pronounced in fmriprep 20. (note that fmriprep 21 does report having applied the pepolar SDC; also see the github repo below)
fmriprep 20
fmriprep 21
So:
sdcflows
, both are currently implemented. So this shouldn't be too complex:https://github.com/nipreps/sdcflows/blob/master/sdcflows/workflows/fit/pepolar.py
Do you have any interest in helping implement the feature?
Yes, but I would need guidance
Additional information / screenshots
You can find a bunch of examples of the problem in my github repo here:
https://github.com/Gilles86/topupvsafni
The text was updated successfully, but these errors were encountered: