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: AFNI - Enable conversion to RAS+ of affine transforms #49

Closed
wants to merge 6 commits into from

Conversation

oesteban
Copy link
Collaborator

@oesteban oesteban commented Nov 12, 2019

Comments on how to de-duplicate code very welcome :)

Now, these are not xfailing:

nitransforms/tests/test_io.py::test_Linear_common[afni-RAS] XPASS        [ 21%]
nitransforms/tests/test_io.py::test_Linear_common[afni-LAS] XPASS        [ 22%]
nitransforms/tests/test_io.py::test_Linear_common[afni-LPS] XPASS        [ 23%]

@oesteban oesteban requested a review from mgxd November 12, 2019 15:02
@codecov-io
Copy link

codecov-io commented Nov 12, 2019

Codecov Report

Merging #49 into master will decrease coverage by 1.09%.
The diff coverage is 60%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master      #49     +/-   ##
=========================================
- Coverage   98.76%   97.67%   -1.1%     
=========================================
  Files          10       10             
  Lines         810      817      +7     
  Branches      106      104      -2     
=========================================
- Hits          800      798      -2     
- Misses          6       13      +7     
- Partials        4        6      +2
Flag Coverage Δ
#unittests 97.67% <60%> (-1.1%) ⬇️
Impacted Files Coverage Δ
nitransforms/io/afni.py 89.53% <60%> (-9.17%) ⬇️
nitransforms/base.py 98.8% <0%> (-0.6%) ⬇️
nitransforms/io/itk.py 100% <0%> (ø) ⬆️
nitransforms/io/base.py 100% <0%> (ø) ⬆️

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 0ec1eb3...710f077. Read the comment docs.

Copy link
Member

@mgxd mgxd left a comment

Choose a reason for hiding this comment

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

would be nice to unifying the reference / moving oblique calculation, maybe something like:

def from_oblique(image, itype):
    M = image.affine
    if itype == 'reference':
         A = shape_zoom_affine(image.shape, voxel_sizes(M), x_flip=False, y_flip=False)
         aff = M.dot(np.linalg.inv(A)).dot(LPS)
    elif itype == 'moving':
         A = shape_zoom_affine(image.shape, voxel_sizes(M), x_flip=True, y_flip=True)
         aff = A.dot(np.linalg.inv(M))
    return aff
        

moving = reference

if reference is None:
warnings.warn('At least, the reference image should be set.')
Copy link
Member

Choose a reason for hiding this comment

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

do we want to just warn or error here?

post = np.linalg.inv(post)

# swapaxes is necessary, as axis 0 encodes series of transforms
ras = self.structarr['parameters'].copy()
Copy link
Member

Choose a reason for hiding this comment

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

is copy necessary here?

@@ -18,6 +19,39 @@ def __str__(self):
param = self.structarr['parameters']
return '\t'.join(['%g' % p for p in param[:3, :].reshape(-1)])

def to_ras(self, moving=None, reference=None):
"""Convert to RAS+ coordinate system."""
pre = LPS.copy()
Copy link
Member

Choose a reason for hiding this comment

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

just to simplify initialization

Suggested change
pre = LPS.copy()
pre = post = LPS.copy()

@oesteban oesteban force-pushed the fix/enable-afni-to-ras branch from 2ec1f10 to 1b1958a Compare November 15, 2019 18:45
@pull-assistant
Copy link

pull-assistant bot commented Nov 15, 2019

Score: 0.70

Best reviewed: commit by commit


Optimal code review plan (2 warnings, 2 commits squashed)

ENH: Enable conversion to RAS+ of affine transforms

nitransforms/io/afni.py 69% changes removed in enh: working on afni...

     fix: first stab at AFNI obliques

enh: working on afni's affine oblique

...ransforms/tests/test_linear.py 67% changes removed in fix: testing with ca...

fix: does AFNI use t... ... fix: rethink ras2afn...

Squashed 2 commits:

     fix: testing with cat_matvec-built matrices

Powered by Pull Assistant. Last update a21bbd5 ... b8a715f. Read the comment docs.

@pep8speaks
Copy link

Hello @oesteban! Thanks for updating this PR.

Line 112:1: E302 expected 2 blank lines, found 1

@oesteban
Copy link
Collaborator Author

Superseded by #117

@oesteban oesteban closed this Feb 16, 2022
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