-
Notifications
You must be signed in to change notification settings - Fork 24
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
[ENH] Reorient bvecs from affs #49
Conversation
…ine transform list
Best reviewed: commit by commit
Optimal code review plan (1 warning)
|
Hello @dPys, Thank you for updating! Cheers! There are no style issues detected in this Pull Request. 🍻 To test for issues locally, Comment last updated at 2020-01-15 16:31:35 UTC |
ecfd113
to
513764d
Compare
…ine transform list [FIX] Correct PEP8 violations
513764d
to
03829b3
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.
I believe this is what is causing Travis to be unhappy: https://travis-ci.org/nipreps/dmriprep/jobs/636585523#L563
Thanks for the review on this @arokem . Will try to incorporate your changes tomorrow and add some other updates to this proposed interface that I've made since. -D |
Co-Authored-By: Ariel Rokem <arokem@gmail.com>
Co-Authored-By: Ariel Rokem <arokem@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #49 +/- ##
==========================================
- Coverage 54.59% 54.26% -0.34%
==========================================
Files 11 11
Lines 773 798 +25
Branches 116 117 +1
==========================================
+ Hits 422 433 +11
- Misses 350 364 +14
Partials 1 1
Continue to review full report at Codecov.
|
>>> res = reor_vecs.run() | ||
>>> out_rasb = res.outputs.out_rasb | ||
>>> out_rasb_mat = np.loadtxt(out_rasb, skiprows=1) | ||
>>> npt.assert_equal(oldrasb_mat, out_rasb_mat) |
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.
We need to import npt
before reaching this line (see: https://travis-ci.org/nipreps/dmriprep/jobs/637522010#L577)
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.
On further thought, maybe replace this with something like:
>>> oldrasb_mat == out_rasb_mat
True
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 would keep squeezing the data structure of Vectors
@@ -375,3 +375,50 @@ def bvecs2ras(affine, bvecs, norm=True, bvec_norm_epsilon=0.2): | |||
rotated_bvecs[~b0s] /= norms_bvecs[~b0s, np.newaxis] | |||
rotated_bvecs[b0s] = np.zeros(3) | |||
return rotated_bvecs | |||
|
|||
|
|||
def reorient_vecs_from_ras_b(rasb_file, affines, b0_threshold=B0_THRESHOLD): |
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 we make it a method of the vectors object (and therefore, it will only take the affines
parameter)? Also drop the b0_threshold
argument, since that should set only once in the vectors class.
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.
yes we can
might cause systematic bias in rotationally invariant measures, such as FA | ||
and MD, and also cause characteristic biases in tractography, unless the | ||
gradient directions are appropriately reoriented to compensate for this | ||
effect [Leemans2009]_. |
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.
Undefined reference
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.
Pruning out since I think it's extraneous here.
cwd = Path(runtime.cwd).absolute() | ||
reor_rasb_file = fname_presuffix( | ||
self.inputs.in_rasb, use_ext=False, suffix='_reoriented.tsv', | ||
newpath=str(cwd)) | ||
np.savetxt(str(reor_rasb_file), reor_table, | ||
delimiter='\t', header='\t'.join('RASB'), | ||
fmt=['%.8f'] * 3 + ['%g']) | ||
|
||
self._results['out_rasb'] = reor_rasb_file |
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 would use a Vector instance here and just call the reorient member (if transferred there, see other comment).
function + interface + 1st docstring test for reorienting vectors from/to rasb .tsv given a list of affine transforms.