-
Notifications
You must be signed in to change notification settings - Fork 272
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
Don't use motion-corrupted b0's in topup #158
Don't use motion-corrupted b0's in topup #158
Conversation
I am not following, are we using the first b0 or the best b0 in topup for both phase encoding directions? |
Let's distinguish the reference b0, which is the first volume passed on to both topup and eddy, from the other b0. We would choose the reference b0 to be the first b0 of some acquisition block (i.e., the first b0 of 98AP, 98PA, 99AP, or 99PA), so that we don't have to reorder the data within a block. My proposal is to select this reference b0 to be the highest-scoring one from these 4 options. Once we have selected a reference b0, we can select any b0 with the opposite phase encoding to be the other b0. So for this one, I would propose to select the best b0 even if it is not the first. |
ok thta makes sense. |
Thanks @MichielCottaar for kicking this off.
That's only really true to the extent that the subject didn't move between the "reference b0" and the 2nd b0 of opposite polarity that gets selected for inclusion in 'topup'. And that can be a long interval under the proposal. The optimal situation for SBM would be to preferentially select the b0 from the end of one run, and the beginning of the following run with opposite polarity, assuming that both are of "good" quality. Does that impact your thinking on which b0's to preferentially select? Alternatively, given that the proposal isn't really optimal for SBM considerations, would we be better off continuing with the existing approach of supplying multiple b0's to 'topup' as a way to help ensure that the topup field estimate is robust? (i.e., supply all the same b0's to topup that we currently do, except simply remove those that are deemed "bad").
|
On how many b0's to pass to topup: using only two b0's might be indeed a bit too few unless we want to optimise the SBM. However, I think the main advantage of having more b0's was that if one or two of them were corrupted by motion, they would not affect the final estimate too much. When we preselect good b0's, my understanding is that there is really no reason to go beyond 2 or 3 b0's per phase encode direction.
|
The apache license appears to be a permissive license (like BSD or MIT, not copyleft like GPL), and the main reason it is so long is to prevent abuse by patenting code and then copyright licensing it "openly", while keeping the patent private, and later suing people for infringing the patent. I think all we need to do is include the original license notice (and mention if we made changes to the code, and include any related notices if they exist on the original code) on that part of the code and we are covered (we don't need to change any of our licenses). |
I feel that we would benefit from Jesper contributing to this discussion. |
Do we really think this is a real problem? For this to be an issue the first b0 would have to be broken in all 4 blocks. |
My point was that we should think beyond the standard HCP-LS protocol. What about protocols that collect only a pair of scans? Or those like UK Biobank with only a single dMRI scan? In those cases, you only have 2 or even just 1 chance to get a "good" b0 that is also at the start of a run. Also, I don't think we should necessarily let Great to hear about the possible substantial decreases in execution time! |
Hi again Mike. I see your point about thinking beyond the HCP-LS project, but I also think we should be careful not to try and solve "every" problem, and in the process end up overcomplicating and delaying the HCP-LS pipelines. |
So it seems like we have two options:
It sounds like either would work fine. I think both would have a similar complexity to implement. I'm happy to go with the second option, if you still have a preference for it, @mharms? |
@MichielCottaar: Yes, that is a nice concise summary of the situation. Ultimately I think you, Jesper, Saad, and Stam need to make the decision as to what is "best". That said, I think I have a decent understanding of the issues and uncertainties involved, and based on my synthesis of the issues, I've come to the point where I favor NOT using
So, first I think we need to come to agreement on whether or not we are going to use I guess another consideration, that should at least be on the table, is that with Option (1), a user could still choose to use |
Sorry if this has already been discussed, but will this impact use of susceptibility with movement interaction correction? |
No, MBS related variance itself is removed equally well, per #158 (comment) That said, if the pair of b=0's used for |
034a86d
to
e372e60
Compare
Debugging this code will probably take a while, but in the meantime more comments are welcome. I went with the strategy of adopting the best b0 overall out of the positive and the negative volumes (i.e., ignoring that they are not at the start of a series). The best b0 of the positive series is prepended to the full dataset, so that topup and eddy have the same reference b0. This reference b0 is removed again after eddy is finished. |
60a5a8e
to
78564e7
Compare
Based on the discussion above I decided to just get the best b0, irrespective of when it was acquired. This best b0 is determined in one of two ways:
After the best b0's are found for each phase encode direction, they are combined for a full run of topup. The best b0 with positive phase encoding is also prepended to the dataset sent to eddy. This can cause misalignment between the first two volumes. To get eddy to successfully register these volumes, I had to decrease the FWHM in the first few iterations of eddy (according to Jesper, these first few iterations should be very quick, so this should not slow down the eddy run). |
@glasserm @mharms @VosperFlopstop: do any of you have any feedback on this update to the pipeline? Given that we prepend a new b0 to the data given to eddy, it might be prudent to test this on a few more subjects to check whether eddy reliably converges. But it would be good to get some feedback before running larger scale tests... |
It sounds good to me. |
We are probably a couple months out on having processing resources available to begin the dMRI processing, so now is a good time for us to (re)engage on this with @MichielCottaar and @VosperFlopstop. Toward that goal, some Q's for @MichielCottaar (noting that I haven't reviewed the code in any detail yet):
|
Replies to @mharms comments below:
I'm not sure what your proposal is here, but there is no matching of b0's between the two polarities irrespective of the number of b0's. The goal is to identify undistorted b0's, not b0's with opposite polarities that "match" well. If some polarity has enough b0's, I can safely assume the avearge b0 at that polarity will be undistorted and hence use that as a reference to identify the undistorted b0's. So, there is no real advantage of including the b0's with opposite polarities in that case.
This makes sense to me. I've added to my TODO list to put the old code back in.
This also sounds reasonable. I'll have a look at the distribution of the similarities to the average b0 to see if we can define a reasonable(~3 sigma) threshold to get rid of distorted b0's that are so different that they would significantly bias the average b0. |
@MichielCottaar: My point in (1) was the following: Once we've identified the best "positive" b0, why not pick the best "negative" b0 against that positive b0, rather than against the average of the negative b0's? The best positive b0 should be uncorrupted, and thus the negative b0 that best matches that should also be uncorrupted, thus achieving that goal. The rationale for this proposal was that it would tend to also pick the negative b0 that was close in space (i.e., little movement) to the positive (reference) b0. Admittedly, @VosperFlopstop indicated above that this consideration shouldn't be seen as critical (#158 (comment)), but all else being equal, isn't it still preferable to have a pos/neg pair for |
@mharms: Hmm, I don't see a straightforward way to do that. For example, if we have N b0's with Pos polarity, and already found the best b0 with Neg polarity, would we just put all of those together and run If we want to encourage a similar head position in our final pos/neg pair, I think it would be better to just make this an explicit part of the selection procedure. So keep the rating procedure we have now to identify the uncorrupted images, but when selecting the final pair also take into account that we want a similar head orientation. I'm not sure how to weight these two goals, but it should be possible to come up with some trade-off (i.e., how much more corrupted can the image be to get a better alignment in head position by N degrees). Still I think this would be quite a bit of work with little extra gain... |
Hmm. I didn't think through the practical issues/challenges of how one would actually implement my proposal of selecting the "best" (uncorrupted by motion) Pos and Neg b0, while also selecting a pair close in space. Input from @VosperFlopstop would be nice here again. i.e., I'd feel assured about the proposed approach if he signs off that we simply shouldn't worry (and/or that it simply isn't practical) about getting a b0 pair that is close in space. |
Hi guys, sorry for the delay. I think it is sufficient to pick the best b0 for each PE-direction individually. Unless the subject has moved massively, or for some reason has left the scanner, the errors will be very small. If you were to pursue the strategy of finding the "best pair" I would suggest using the current strategy to pick a set of b0 for each PE-direction that are all "good", then to put all of those b0s into a 4D file that you run topup on with the test_acqp.cnf configuration file. That configuration file runs just the early, low resolution, steps of the full topup and is intended mainly for checking that ones acqparams.txt file is correct before running the full, and more time consuming, topup. But importantly for your case the movement parameters are well estimated already by these steps, and typically change very little if/when running to the full resolution. So that means you have a way to determine the relative positions of all the b0s in there, and use that to pick a "best pair" of Pos and Neg. I hope that addresses your questions? |
@MichielCottaar Could you please go through and "Resolve conversation" on all the items where you either accepted my suggestions, or is simply no longer relevant? Thx. |
I believe these changes address all of your comments. Let me know if anything else comes up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Michael Harms <mharms@wustl.edu>
c1f4ed8
to
183ef9c
Compare
This version of the code succesfully ran on jalapeno (or more technically the version a few days ago, but we have only tweaked the comments & error messages since, so it should still be fine). The error message of combining the --select-best-bo and --extra-eddy-arg=--dont-peas flags also works. |
Looks good. |
Are we waiting for anyone else to review this? |
I merged it |
Here is a proposed piece of code to identify the bad b0's. The new code below extracts all b0's and runs topup (with the configuration file set for quick convergence). After topup each b0 is then scored based on its average square residual from the average b0.
The next step is to decide how to use these b0's in the later analysis. My proposal is to:
Feedback on this proposal would be very welcome, before I spend too much time trying to implement it.