-
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
No more slice removal for odd number of slices #218
No more slice removal for odd number of slices #218
Conversation
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.
Thanks Michiel. Is this tested? It looks good from a code skim.
I'm running some overnight tests on HCP YA data. I'll let you know tomorrow |
This is working, I've tested it in three specific cases. In all cases the input was the HCP YA adult data, which has an odd number of slices.
The error message raised by topup if the subsampling levels are incompatible with the image dimensions
|
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.
This is nearly there. I do think the topup error message is actually not as userfriendly as we would like. It would be better to catch the error early in the pipeline (before much processing has taken place) and to suggest the user to 1) Use a different config file (recommended) or 2) Use the --ensure-even-slices flag (if trying to replicate legacy behavior or if not using advanced eddy features). Does that seem reasonable to you?
Sounds reasonable. I thought that I might need to parse the topup config file to do that. However, I just realised that we could simply raise an error if (1) there is an odd number of slices and (2) there is no That would mean that if the user provides a topup config file that is incompatible with the data dimensions, they would still get the topup error. Is that okay with you? |
Is parsing the file hard? @coalsont might be able to help with the code for this. Basically it needs to grep the line: |
Only compatibility with the default topup configuration is checked. User-provided configuration files are assumed to be compatible.
It would take me quite a while to code that up in bash (I'm not very good in bash, grep, etc.). If someone can give me the code, I'll be happy to put it in. |
@coalsont is better than me, but I think it will be a one-liner. Something like testing whether |
Honestly, if the user supplies their own topup config, I think they can deal with the errors they get from topup themselves, so I don't know that I would try to parse it to give an error in advance (maybe a future topup feature will allow subsampling without requirements on dimensions, which could make our error on someone else's config wrong and annoying). I would recommend an option to ignore this check if we want our script to check custom config files by default. If you want to try to protect users from their own custom config "mistakes" anyway, if grep -e "--subsamp=" <config> | sed 's/^.*--subsamp=//g' | grep -Evq '^[:space:]*(1,)*1[:space:]$' && [[ <slice count is odd> && "$EnsureEvenSlices" != "true" ]]
then
log_Err_Abort "topup config uses subsampling, use --ensure-even-slices"
fi If topup configs forbid whitespace, then some of the extra stuff in the regexps can be removed. Technically, this assumes that the only kind of subsampling that will ever be in anyone's config is 2, since it assumes that an even number makes anything fine. The current code also assumes that only the slice direction can be an issue. Not sure how deep into this rabbit hole we really want to go, as long as we give the user the option of "just try it and see what topup thinks". Really, the right solution is to ask FSL to improve topup's error messages. |
Given that a 4x subsampling config file is now an option that FSL provides, and that the proposed check is only on the slice dimension, maybe it is indeed best to not get into the checking business at all (given that what we are proposing is not a complete check for the ways that the config file can be incorrect relative to the image dimensions). But I defer to the consensus of others. |
The topup error doesn't really tell the user how to resolve the problem as far as the HCP Pipelines are concerned. If we wanted to catch and parse the topup error, that would be another option... |
Detecting that topup crashed with a custom config and saying "if your config contains subsampling, make sure your image dimensions are an exact multiple" wouldn't require parsing anything. When using the pipelines' own config files, we can provide more accurate errors in advance (because we know what they require), again without parsing anything. |
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.
Looks good. Thanks @MichielCottaar. I've suggested some minor tweaks to some of the messages.
Apply suggestions from code review from @mharms Co-authored-by: Michael Harms <mharms@wustl.edu>
I agree that the error messages from topup could be improved, but this does not seem to be the place to do so. Messages like "if your config contains subsampling, make sure your image dimensions are an exact multiple", would be much more useful in FSL's topup itself (there is nothing particular to the HCP pipelines about this). I agree with @coalsont of checking the data dimensions in advance if using the HCP pipeline's config file (as we now do), but we should just leave it to topup if the user is confident enough to provide their own config file. |
Ok |
Well, I'd like things to be as userfriendly as possible, but don't want to hold things up if there isn't consensus on that. |
Shall we merge this so that we can tag a release once the tICA testing is done? |
That's fine with me. |
This is meant to address #217 . This pull request is still in draft, because the topup will crash for any images with odd number of slices. We still need to adjust the topup config file used (either for all input volumes or only for those with odd number of slices).