-
Notifications
You must be signed in to change notification settings - Fork 16
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
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
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.
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
nitransforms/io/afni.py
Outdated
moving = reference | ||
|
||
if reference is None: | ||
warnings.warn('At least, the reference image should be set.') |
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.
do we want to just warn or error here?
nitransforms/io/afni.py
Outdated
post = np.linalg.inv(post) | ||
|
||
# swapaxes is necessary, as axis 0 encodes series of transforms | ||
ras = self.structarr['parameters'].copy() |
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.
is copy
necessary here?
nitransforms/io/afni.py
Outdated
@@ -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() |
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.
just to simplify initialization
pre = LPS.copy() | |
pre = post = LPS.copy() |
2ec1f10
to
1b1958a
Compare
Best reviewed: commit by commit
Optimal code review plan (2 warnings, 2 commits squashed)
|
Hello @oesteban! Thanks for updating this PR.
|
Superseded by #117 |
Comments on how to de-duplicate code very welcome :)
Now, these are not xfailing: