Skip to content
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

RF: Split anatomical workflow into fit and derivatives workflows #303

Merged
merged 49 commits into from
Jun 19, 2023

Conversation

effigies
Copy link
Member

Starting on #300.

@effigies effigies linked an issue Sep 30, 2022 that may be closed by this pull request
30 tasks
@codecov-commenter
Copy link

codecov-commenter commented Sep 30, 2022

Codecov Report

Patch coverage: 52.25% and project coverage change: +22.56 🎉

Comparison is base (b174172) 31.18% compared to head (22f236d) 53.75%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #303       +/-   ##
===========================================
+ Coverage   31.18%   53.75%   +22.56%     
===========================================
  Files          20       22        +2     
  Lines        1456     1600      +144     
  Branches      206      251       +45     
===========================================
+ Hits          454      860      +406     
+ Misses        987      672      -315     
- Partials       15       68       +53     
Flag Coverage Δ
ds005 ∅ <ø> (∅)
ds054 46.31% <51.65%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
smriprep/utils/bids.py 34.00% <4.54%> (-7.89%) ⬇️
smriprep/workflows/surfaces.py 12.23% <14.28%> (+0.25%) ⬆️
smriprep/cli/run.py 73.18% <42.85%> (+70.36%) ⬆️
smriprep/workflows/anatomical.py 45.41% <49.05%> (+28.85%) ⬆️
smriprep/interfaces/surf.py 42.85% <50.00%> (+7.24%) ⬆️
smriprep/workflows/base.py 75.00% <66.66%> (+45.00%) ⬆️
smriprep/workflows/outputs.py 55.76% <76.28%> (+43.55%) ⬆️
smriprep/workflows/fit/registration.py 92.50% <80.00%> (ø)

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@effigies effigies force-pushed the rf/split_workflow branch 4 times, most recently from ca58281 to abe2c05 Compare October 14, 2022 16:41
@effigies effigies force-pushed the rf/split_workflow branch 3 times, most recently from 224b305 to 6be5c53 Compare November 9, 2022 13:24
@effigies effigies changed the title RF: Split surface workflow into recon and derivative preparation RF: Split anatomical workflow into fit and derivatives workflows Nov 9, 2022
@effigies effigies force-pushed the rf/split_workflow branch 2 times, most recently from 2b40799 to e7628a0 Compare November 10, 2022 11:48
@effigies
Copy link
Member Author

Tests passing. Will start re-adding the workflow description.

Copy link
Member Author

@effigies effigies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mgxd @oesteban This is passing and ready for review.

I don't think we want to try to squeeze it into 0.10.0, but I've left some comments to help guide a review.

.github/workflows/pythonpackage.yml Outdated Show resolved Hide resolved
@@ -65,7 +65,6 @@
"seaborn",
"skimage",
"svgutils",
"templateflow",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully we don't end up downloading things during builds, but if so, so be it.

@@ -50,81 +51,6 @@ def get_outputnode_spec():
return fields


def predict_derivatives(subject_id, output_spaces, freesurfer):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This didn't seem to be used anywhere, and deleting this freed me up to change collect_derivatives to use BIDSLayout and use lists as "or" instead of "and" in io_spec.json.

name="anat_preproc_wf",
skull_strip_fixed_seed=False,
skull_strip_fixed_seed: bool = False,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type annotations grew out of frustration of not knowing what I was working with (particularly Reference and SpatialReference). The consequence of this was that I need to import Reference and SpatialReference at the module level, which meant that a mocked templateflow prevented the loading of spatial references.

smriprep/workflows/apply/resampling.py Outdated Show resolved Hide resolved
return workflow


def init_ds_template_wf(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we need a better name, but this is the subject template, not MNI or other template spaces.

return workflow


def init_anat_derivatives_wf(
def init_anat_second_derivatives_wf(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could definitely stand refactoring, but I'd prefer to keep that until later.

@@ -655,12 +932,104 @@ def init_anat_derivatives_wf(
return workflow


def init_template_iterator_wf(*, spaces, name="template_iterator_wf"):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this a lot. I feel like what we're going to want one of these sitting in the subject level that then gets passed as inputs to the baseline derivatives (registrations only), reporting and full derivative workflows.

Need to spend some time to work out what that would look like, in a separate PR. For now we spin one of these up inside the reporting and full derivatives workflows.

Comment on lines +243 to +258
if "fsnative" not in precomputed.get("transforms", {}):
fsnative2t1w_xfm = pe.Node(
RobustRegister(auto_sens=True, est_int_scale=True), name="fsnative2t1w_xfm"
)

# fmt:off
workflow.connect([
(inputnode, fsnative2t1w_xfm, [('t1w', 'target_file')]),
(autorecon1, fsnative2t1w_xfm, [('T1', 'source_file')]),
(fsnative2t1w_xfm, outputnode, [('out_reg_file', 'fsnative2t1w_xfm')]),
])
# fmt:on
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was all that was needed to isolate this step, which drew attention to the fact that we're not mapping skull-strips correctly into fsnative. This should be resolved in another PR.

name="outputnode",
)

aseg_to_native_wf = init_segs_to_native_wf()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated here and in init_surface_derivatives_wf. Acceptably small duplication of effort for conceptual clarity, IMO.

@effigies effigies changed the base branch from master to next June 19, 2023 19:09
@effigies
Copy link
Member Author

@mgxd @oesteban I've reset the merge target to a next branch. My plan is to merge this there and make PRs against that. If we need more updates to master before the final merge, I'll merge that to next as well. Feel free to comment here even after merge (and of course PRs against next are welcome).

I will be doing a similar thing over on fMRIPrep.

@effigies effigies merged commit c8853ef into nipreps:next Jun 19, 2023
16 checks passed
@effigies effigies deleted the rf/split_workflow branch June 19, 2023 19:42
@effigies effigies added the next label Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fit/apply breakdown
2 participants