-
Notifications
You must be signed in to change notification settings - Fork 297
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
REF: Split final boldref generation from BOLD-BOLD resampling, eliminate extra per-echo computation #2181
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.
Should we rebase this PR on the head of #1803? I think yielding until that one is merged will help clarify this.
fmriprep/utils/misc.py
Outdated
@@ -11,3 +11,22 @@ def check_deps(workflow): | |||
for node in workflow._get_all_nodes() | |||
if (hasattr(node.interface, '_cmd') and | |||
which(node.interface._cmd.split()[0]) is None)) | |||
|
|||
|
|||
def select_first(in_files): |
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.
Let's use niworkflows.utils.connections.pop_file
instead (requires nipreps/niworkflows#408 to be merged)
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.
Do we want to use the first echo's brain mask, though? I am using it to fix the bug, but I don't know if it's the appropriate choice.
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.
I think we can also replace fmriprep.workflows.bold.resampling._first
with pop_file
as well.
# Conflicts: # fmriprep/utils/misc.py
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.
Okay, I see the problem now. Because we run the bold resampling workflow as an iterable, we are generating one mask per echo, regardless of the changes in niworkflows to use the first echo only.
Although this looks like it fixes the problem, I believe that we are running some unnecessary stuff in the bold resampling workflow we should avoid (starting with the masking of each echo).
Please allow me some time to draft how the bold transform workflow could be improved and send a PR to your branch.
Not to step on @oesteban's toes, but it looks like this would be good to get into the next release, if it's not too far from ready. I can plan to review tomorrow. @tsalo Would you be willing to rebase on top of the refactors in #2239? Sorry to do this to you, but I think we've almost certainly interfered with your changes. |
Test failures are related to nipreps/niworkflows#556. |
Tests fixed. |
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 for this. The connections look good. I also see what @oesteban was saying, which is that we are calculating new masks for each echo, and throwing away all but the first:
The simple solution is to remove this from init_bold_preproc_trans_wf
, and put it directly into init_func_preproc_wf
, connecting from init_bold_preproc_trans_wf.outputs.outputnode.bold
or join_echos.outputs.bold_files
. There might be a more clever way to do it without moving the workflow, but I'm not sure that cleverness would be worth it.
WDYT?
To clarify, Then, I think the one in If so, then we could label these as "first pass" and "second pass" reference image estimation, correct? In any case, I think that moving the second run of the reference workflow to |
Yes, that makes sense to me. I might call them |
Awesome! I think I can handle the refactor, but would it be better to have it here or in a separate PR? |
Co-authored-by: Chris Markiewicz <[email protected]>
I don't think it makes any difference to me. I would just have a look and see how much of this PR would need to be undone, and whether it makes sense to start fresh from |
@effigies. Okay, I think I got it working. It did involve switching a lot of the stuff in the PR back, but I don't think that's too much of a problem. We'll see how the tests do. |
Crashed...
The issue isn't obvious to me. Could just be a cache that needs clearing. |
I think it's a genuine error... The T2* workflow expects a list (with a minimum of 3 entries), but a string is being passed. I wonder if |
Good catch. JoinNodes. |
Co-authored-by: Chris Markiewicz <[email protected]>
Co-authored-by: Chris Markiewicz <[email protected]>
Okay, looks like this is working. Nice! I'll review for aesthetic/style stuff, and I think we can call this done. |
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.
Mostly suggestions to compact the diff. One verification.
Would you rather we merge by squashing or merge commit?
('outputnode.bold_mask', 'inputnode.bold_mask_native')]), | ||
(bold_bold_trans_wf if not multiecho else bold_t2s_wf, outputnode, [ |
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 seems to be a semantic change, not just a reorganization. Was this something we were doing wrong?
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.
Sorry, yes, I think it was wrong before, since it took the BOLD files from bold_bold_trans_wf
for the native-space BOLD outputs.
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.
Looking through, I agree with this change. If I'm reading it right, a native BOLD space derivative for MEEPI will be the optimal combination, which seems appropriate.
Thanks @effigies. Co-authored-by: Chris Markiewicz <[email protected]>
Generally speaking, I prefer squash and merge. It's a fairly cohesive set of changes, so the individual commits don't provide any extra information, IMHO. Especially given the pivot in approach. |
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.
LGTM. We'll let the CI run through one more time to be safe, but I think we're good to go, and anybody with permissions should feel free to squash and merge.
Closes #2175. It appears that dropping the tedana-based mask in #2109 led to un-joined echo-specific masks being used after echo combination throughout the workflow. This led to many redundant nodes in the workflow being created, including multiple runs of ICA-AROMA, although those nodes should be duplicates of one another except for the difference, if any, in masks.
Changes proposed in this pull request
init_bold_preproc_trans_wf
and intoinit_func_preproc_wf
. The workflow is calledfinal_boldref_wf
.bold_reference_wf
ininit_func_preproc_wf
toinitial_boldref_wf
.bold_files
injoin_echos
JoinNode with reference native-space BOLD files frombold_bold_trans_wf
.skullstripped_bold_files
tojoin_echos
JoinNode, to combine skullstripped BOLD files fromskullstrip_bold_wf
and feed them tobold_t2s_wf
. (These were thebold_files
injoin_echos
before.)Documentation that should be reviewed
None