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

[ENH] Reorient bvecs from affs #49

Closed
wants to merge 9 commits into from

Conversation

dPys
Copy link
Collaborator

@dPys dPys commented Jan 13, 2020

function + interface + 1st docstring test for reorienting vectors from/to rasb .tsv given a list of affine transforms.

@pep8speaks
Copy link

pep8speaks commented Jan 13, 2020

Hello @dPys, Thank you for updating!

Cheers! There are no style issues detected in this Pull Request. 🍻 To test for issues locally, pip install flake8 and then run flake8 dmriprep.

Comment last updated at 2020-01-15 16:31:35 UTC

@dPys dPys force-pushed the reorient_bvecs_from_affs branch from ecfd113 to 513764d Compare January 13, 2020 21:46
…ine transform list

[FIX] Correct PEP8 violations
@dPys dPys force-pushed the reorient_bvecs_from_affs branch from 513764d to 03829b3 Compare January 13, 2020 21:49
Copy link
Collaborator

@arokem arokem left a 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

dmriprep/interfaces/vectors.py Outdated Show resolved Hide resolved
dmriprep/interfaces/vectors.py Outdated Show resolved Hide resolved
@dPys
Copy link
Collaborator Author

dPys commented Jan 15, 2020

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

@dPys dPys changed the title Reorient bvecs from affs [ENH] Reorient bvecs from affs Jan 15, 2020
dPys and others added 2 commits January 15, 2020 08:31
Co-Authored-By: Ariel Rokem <arokem@gmail.com>
Co-Authored-By: Ariel Rokem <arokem@gmail.com>
@codecov
Copy link

codecov bot commented Jan 15, 2020

Codecov Report

Merging #49 into master will decrease coverage by 0.33%.
The diff coverage is 46.15%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
dmriprep/utils/vectors.py 95.23% <12.5%> (-4.77%) ⬇️
dmriprep/interfaces/vectors.py 88.52% <61.11%> (-11.48%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5282950...df7d72f. Read the comment docs.

>>> 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)
Copy link
Collaborator

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)

Copy link
Collaborator

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

Copy link
Member

@oesteban oesteban left a 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):
Copy link
Member

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.

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 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]_.
Copy link
Member

Choose a reason for hiding this comment

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

Undefined reference

Copy link
Collaborator Author

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.

Comment on lines +150 to +158
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
Copy link
Member

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).

@dPys dPys closed this Feb 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants