-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
➕ Reorient resources to set orientation in config #2140
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.
This comment is my only substantive question & suggestion.
The rest is style that the ruff-format hook in pre-commit should have caught.
(I cherry-pick
'd these changes locally and ran pre-commit run
on them to catch these after I noticed a couple. Of
the errors that ruff
found
CPAC/pipeline/engine.py:1:1: D100 Missing docstring in public module
CPAC/pipeline/engine.py:73:7: D101 Missing docstring in public class
CPAC/pipeline/engine.py:136:9: D105 Missing docstring in magic method
CPAC/pipeline/engine.py:144:9: D105 Missing docstring in magic method
CPAC/pipeline/engine.py:149:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:197:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:200:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:208:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:211:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:214:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:217:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:220:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:223:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:240:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:257:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:270:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:278:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:328:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:396:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:437:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:455:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:462:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:466:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:469:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:491:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:504:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:519:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:529:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:549:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:562:9: PLR0912 Too many branches (69 > 50)
CPAC/pipeline/engine.py:562:9: PLR0915 Too many statements (155 > 100)
CPAC/pipeline/engine.py:562:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:814:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:930:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:1073:9: PLR0912 Too many branches (69 > 50)
CPAC/pipeline/engine.py:1073:9: PLR0915 Too many statements (171 > 100)
CPAC/pipeline/engine.py:1073:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:1073:37: A002 Argument `all` is shadowing a Python builtin
CPAC/pipeline/engine.py:1420:7: D101 Missing docstring in public class
CPAC/pipeline/engine.py:1431:17: PLW2901 `for` loop variable `node_block_function` overwritten by assignment target
CPAC/pipeline/engine.py:1492:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:1495:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:1500:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:1509:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:1519:9: PLR0912 Too many branches (91 > 50)
CPAC/pipeline/engine.py:1519:9: PLR0915 Too many statements (186 > 100)
CPAC/pipeline/engine.py:1519:9: D102 Missing docstring in public method
CPAC/pipeline/engine.py:1831:37: PLW2901 `for` loop variable `connection` overwritten by assignment target
CPAC/pipeline/engine.py:1910:5: D103 Missing docstring in public function
CPAC/pipeline/engine.py:1955:5: D103 Missing docstring in public function
CPAC/pipeline/engine.py:2047:5: D103 Missing docstring in public function
CPAC/pipeline/engine.py:2093:5: D103 Missing docstring in public function
CPAC/pipeline/engine.py:2216:17: E722 Do not use bare `except`
CPAC/pipeline/engine.py:2240:5: D103 Missing docstring in public function
CPAC/pipeline/engine.py:2315:5: D103 Missing docstring in public function
CPAC/pipeline/engine.py:2383:5: D103 Missing docstring in public function
CPAC/pipeline/engine.py:2391:5: D103 Missing docstring in public function
CPAC/pipeline/engine.py:2411:5: D103 Missing docstring in public function
CPAC/pipeline/engine.py:2680:9: E722 Do not use bare `except`
CPAC/pipeline/engine.py:2697:5: D103 Missing docstring in public function
CPAC/pipeline/utils.py:29:5: D103 Missing docstring in public function
CPAC/pipeline/utils.py:39:12: RET504 Unnecessary assignment to `orientation` before `return` statement
CPAC/pipeline/utils.py:42:5: D103 Missing docstring in public function
Found 63 errors.
I'd add docstrings for
CPAC/pipeline/utils.py:29:5: D103 Missing docstring in public function
CPAC/pipeline/utils.py:42:5: D103 Missing docstring in public function
and change
Lines 40 to 41 in dbdacd1
orientation = subprocess.run(cmd_3dinfo, capture_output=True, text=True).stdout.strip().upper() | |
return orientation |
return subprocess.run(cmd_3dinfo, capture_output=True, text=True).stdout.strip().upper()
(or
orientation = subprocess.run(cmd_3dinfo, capture_output=True, text=True).stdout.strip().upper() # noqa: RET504
return orientation
to mark the style violation as intentional if you think it's that much more readable) for
CPAC/pipeline/utils.py:39:12: RET504 Unnecessary assignment to `orientation` before `return` statement
. Once all the remaining ruff
violations are outside of the scope of the changes of this PR, I'd git commit --no-verify
to accept those style violations as acceptable for now.)
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.
To fix:
- broken calls via API changes:
-
T1w→ T2w (would be unnecessary if we do this optional change)
The SSOTing by functionalizing the creation of resample nodes is totally optional, just a suggestion.
c9e71f2
to
40ea22c
Compare
Co-authored-by: Jon Clucas <[email protected]>
Co-authored-by: Jon Clucas <[email protected]>
Co-authored-by: Jon Clucas <[email protected]>
Co-authored-by: Jon Clucas <[email protected]>
Co-authored-by: Jon Clucas <[email protected]>
Co-authored-by: Jon Clucas <[email protected]>
Co-authored-by: Jon Clucas <[email protected]>
Co-authored-by: Jon Clucas <[email protected]>
Co-authored-by: Jon Clucas <[email protected]>
Co-authored-by: Jon Clucas <[email protected]>
Co-authored-by: Jon Clucas <[email protected]>
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…tation set in config in the existing nodes for reorientations
for more information, see https://pre-commit.ci
96f5871
to
71dd070
Compare
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 looks good, and all the tests are passing (including the smoke tests I manually triggered to check that all the preconfigs build with these changes)!
I have a few suggestions and a question for the CHANGELOG, and one more request to fix a style violation, but otherwise I'm happy with this fix. Nice work!
Co-authored-by: Jon Clucas <[email protected]>
Co-authored-by: Jon Clucas <[email protected]>
Co-authored-by: Jon Cluce <[email protected]>
1b05911
to
2895e8c
Compare
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.
🎉
Related to
Fixes #2138 by @sgiavasis
Description
This PR fixes the different orientation in CPAC output dir that were caused by the different orientation of templates being ingressed.
desired_orientation
as config key inblank-config
and set it default toRPI
With this PR the desired orientation of the outputs can be selected by modifying this key in the config.
Technical details
First of all,
The reorientation of templates are done as below
orientation
as extra input.Tests
For testing you can run this branch of CPAC on one test subject / session with your config (set as
desired_orientation
) and check theorientations
of the images in the output directory bothanat
andfunc
cd
into theanat
orfunc
directory.for file in *.nii.gz; do orientation=$(3dinfo -orient "$file" 2>/dev/null); echo "$file: $orientation"; done
You should see the filename with orientations as below
anat :
func :
Screenshots
Problem: Different orientations in the CPAC output dir
anat dir:
func dir:
After fix:
anat dir:
func dir:
Checklist
Update index.md
).develop
branch of the repository.Developer Certificate of Origin
Developer Certificate of Origin