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

FIX _is_oblique #194

Merged
merged 1 commit into from
Mar 27, 2024
Merged

FIX _is_oblique #194

merged 1 commit into from
Mar 27, 2024

Conversation

mvdoc
Copy link
Member

@mvdoc mvdoc commented Mar 27, 2024

As described in #158 (comment), currently _is_oblique fails to detect certain oblique dataset. The reason (and fix) is very simple. Checking the implementation in AFNI (https://github.com/afni/afni/blob/b6a9f7a21c1f3231ff09efbd861f8975ad48e525/src/thd_coords.c#L689), the minimum across the three dimensions is computed before the arccos. However, in the implementation in nitransforms the minimum was computed after the arccos, which is incorrect--the max should be computed instead.

Example with the current PR:

import numpy as np
from nitransforms.io.afni import _is_oblique, obliquity

affine = np.array([[ -0.5       ,   0.        ,   0.        ,  70.10167694],
           [  0.        ,  -0.2254388 ,  -0.44629291, -36.50873947],
           [  0.        ,   0.44629291,  -0.2254388 , -90.31697845],
           [  0.        ,   0.        ,   0.        ,   1.        ]])
print(_is_oblique(affine))
>>> True

Note that now the implementation in AFNI and nitransforms should match:

print(obliquity(affine).max()*180/np.pi)
26.800002993238653

and the output of 3dinfo:

3dinfo epi2d_run1_masked_volreg.nii.gz | grep Oblique
Data Axes Tilt:  Oblique (26.800 deg. from plumb)

@effigies effigies merged commit 0027d1b into nipy:master Mar 27, 2024
6 checks passed
@oesteban
Copy link
Collaborator

Ugh, thanks for catching this :)

@mvdoc mvdoc deleted the fix/oblique branch April 3, 2024 18:46
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.

3 participants