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

Mrtpipelines update #17

Merged
merged 20 commits into from
Nov 13, 2022
Merged

Mrtpipelines update #17

merged 20 commits into from
Nov 13, 2022

Conversation

kaitj
Copy link
Collaborator

@kaitj kaitj commented Nov 2, 2022

Proposed changes

A number of quality changes (primarily to mrtpipelines.smk) to try to bring this up-to-date as of snakebids==0.6.2. Includes updates to:

  • pybids_inputs
  • Use of variables instead of grabbing from config for every rule
  • Renamed rules to reflect similar naming of mrtrix functions
  • Update mrtrix container to 3.0.3.
  • Make use of functools.partial

See the commit notes for full details.

Types of changes

What types of changes does your code introduce? Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionalitiy)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you are unsure about any of the choices, don't hesitate to ask!

  • Changes have been tested to ensure that fix is effective or that a feature works.
  • Changes pass the unit tests
  • Code has been run through the poe quality task
  • I have included necessary documentation or comments (as necessary)
  • Any dependent changes have been merged and published

Notes

All PRs will undergo the unit testing before being reviewed. You may be requested to explain or make additional changes before the PR is accepted.

kaitj added 8 commits November 2, 2022 18:05
- Add associated citation in comments
- Renamed rules to match mrtrix function names
- Updated mrtrix to latest release version
- Updated pybids_inputs for diffusion
- Updated names to more similarly match what was used in a different
workflow (https://github.com/kaitj/mrtproc.git)
- Updated notes to indicate whether TODO was for v0.1.x or v0.2.x
- Define variables at top of .smk file to avoid grabbing from config for
each rule
- Fix remaining group directives that were missed
Copy link
Collaborator

@tkkuehn tkkuehn left a comment

Choose a reason for hiding this comment

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

I haven't actually tried running this yet, but a few comments from looking over the rules...

dbsc/workflow/rules/mrtpipelines.smk Outdated Show resolved Hide resolved
dbsc/workflow/rules/mrtpipelines.smk Outdated Show resolved Hide resolved
dbsc/workflow/rules/mrtpipelines.smk Outdated Show resolved Hide resolved
dbsc/workflow/rules/mrtpipelines.smk Outdated Show resolved Hide resolved
dbsc/workflow/rules/mrtpipelines.smk Show resolved Hide resolved
dbsc/workflow/rules/mrtpipelines.smk Outdated Show resolved Hide resolved
dbsc/workflow/rules/mrtpipelines.smk Outdated Show resolved Hide resolved
dbsc/workflow/rules/mrtpipelines.smk Outdated Show resolved Hide resolved
dbsc/workflow/rules/mrtpipelines.smk Outdated Show resolved Hide resolved
- Replace config['derivatives'] with config['bids_dir'] and update join
- Change config to get to return None if flags not defined
- Remove unnecessary lambda calls
- Update params for passing shell and lmax variables to command
  - Simplify shell commands
- Add missing ',' for tck2connectome
- Update param for defining node labels in connectome2tck
- Update naming of filtered files to be more BIDSesque
@kaitj kaitj force-pushed the mrtpipelines-update branch from 28fb0f9 to 9669f8a Compare November 3, 2022 17:16
- Redefined outputs to make use of wildcards to describe different
tissue types
- Kept responsemean call in one rule as the task it is performing is the
same rather than split into separate rules
- Consider using wildcards for tractograpy down the line
@kaitj kaitj requested a review from tkkuehn November 3, 2022 17:43
kaitj added 3 commits November 3, 2022 13:49
- Revert usage back to config["input_path"]
- Set mrtrix_dir to make use of the output_dir rather than bids_dir
@kaitj kaitj added the maintenance Updates or improvements that do not change functionality of the code label Nov 3, 2022
Copy link
Collaborator

@tkkuehn tkkuehn left a comment

Choose a reason for hiding this comment

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

A couple of things that I'm pretty sure will break the workflow, and some stylistic suggestions that you can take or leave depending on your preference. We should also put together some test data (even if just empty files) and make sure a dry-run of this completes before merging.

dbsc/config/snakebids.yml Show resolved Hide resolved
dbsc/workflow/Snakefile Outdated Show resolved Hide resolved


# ------------ MRTRIX PREPROC BEGIN ----------#
rule nii2mif:
Copy link
Collaborator

Choose a reason for hiding this comment

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

It strikes me now that this is another rule that could be split into two. Not a huge benefit, but would allow a bit more parallelization. Up to you.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed we could split this into two. I just figured to keep the two things that are doing the same thing together - the parallelization wouldn't speed up the workflow too much anyways.

sfwm=expand(rules.estimate_response.output.sfwm, subject=config['subjects']),
gm=expand(rules.estimate_response.output.gm, subject=config['subjects']),
csf=expand(rules.estimate_response.output.csf, subject=config['subjects'])
wm_rf=expand(rules.dwi2response.output.wm_rf, subject=config["subjects"]),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I missed this before, but I would think this should be expanding over input_zip_lists.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was loosely based off of the workflow here: https://github.com/kaitj/mrtproc/blob/main/mrtproc/workflow/Snakefile

I'd probably hold off on making this change until we have a chance to test.

dbsc/workflow/rules/mrtpipelines.smk Show resolved Hide resolved

rule compute_tensor:

rule dwi2tensor:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is another rule that could be split into two.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes agreed, although again, not too much benefit and ultimately this could be an optional rule down the line (may not want tensor measures).

dbsc/workflow/rules/mrtpipelines.smk Show resolved Hide resolved
dbsc/workflow/rules/mrtpipelines.smk Outdated Show resolved Hide resolved
kaitj added 2 commits November 4, 2022 13:31
- Changes `use_bids_inputs=False` in config
- Removed group analysis level in `snakebids.yml`
- Added `desc` as a wildcard in `snakebids.yml`
- Added missing '&&' in mrtpipelines.smk
- Make use of functools.partial to iterate over different wildcards
rather than expand
@kaitj
Copy link
Collaborator Author

kaitj commented Nov 4, 2022

I just went through and replaced any use of expand for the old outputs to make use of functools.partial as of d80dbe2

@kaitj kaitj force-pushed the mrtpipelines-update branch from daf4b3c to 5df79d5 Compare November 7, 2022 22:44
kaitj added 2 commits November 7, 2022 17:51
- Fixes pattern for and expands over node1 and node2
- Snakefmt fixes
@kaitj kaitj changed the base branch from main to smk-updates November 13, 2022 22:52
@kaitj kaitj merged commit ffb5c94 into smk-updates Nov 13, 2022
@kaitj kaitj deleted the mrtpipelines-update branch November 13, 2022 22:56
@kaitj kaitj mentioned this pull request Nov 13, 2022
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Updates or improvements that do not change functionality of the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants