-
Notifications
You must be signed in to change notification settings - Fork 533
[FIX] modified afni's cat_matvec to accept empty string opposed to opkey #2943
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
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 for this, I made some suggestions.
nipype/interfaces/afni/utils.py
Outdated
xfm_args += ' ' + v[0] + ' -' + v[1] + ' ' | ||
else: | ||
xfm_args += ' ' + v[0] + ' ' | ||
return spec.argstr % (xfm_args) |
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 it would be clearer to continue writing this as a comprehension, using the x if y else z
idiom, but we can use more verbose variable names to make the logic clearer. I also think it would be useful to include a comment:
# Concatenate a series of filenames, with optional opkeys
return ' '.join('%s -%s' % (mfile, opkey) if opkey else mfile
for mfile, opkey in value)
I dropped the initial spec.argstr %
, just because spec.argstr
is "%s"
, so there's no real point, but you could keep it if you wanted.
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 agree this is more elegant, I changed it and confirmed it passed my test for formatting.
return super(CatMatvec, self)._format_arg(name, spec, value) | ||
|
||
|
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.
Can you re-add this? Python style guidelines suggest 2 lines between classes.
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.
Done
Codecov Report
@@ Coverage Diff @@
## master #2943 +/- ##
==========================================
+ Coverage 67.14% 67.52% +0.37%
==========================================
Files 344 344
Lines 44091 44091
Branches 5556 5556
==========================================
+ Hits 29606 29771 +165
+ Misses 13703 13574 -129
+ Partials 782 746 -36
Continue to review full report at Codecov.
|
Please let me know if you want any other changes. |
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 LGTM. One style nitpick and I think this will be good to go.
The failing tests are due to an issue fixed in #2963. Can you merge master or rebase onto master? |
Co-Authored-By: Chris Markiewicz <effigies@gmail.com>
Thanks! Merging. |
Summary
AFNI's cat_matvec allows for transforms to be concatenated together. The opkey field after each transform allows for things like inversions but is non-mandatory. Currently, if no opkey is specified the - character is added resulting in an error when the interface is run.
Example:
cat_matvec a.1D - b.1D - > c.1D
Reference documentation:
https://afni.nimh.nih.gov/pub/dist/doc/program_help/cat_matvec.html
Fixes
Acknowledgment
I acknowledge that this contribution will be available under the Apache 2 license.