Skip to content

Commit 9dfcfb9

Browse files
authored
Merge pull request #18 from oesteban/pin/nibabel-master
ENH: Use ``obliquity`` directly from nibabel
2 parents 72a8264 + 9f93415 commit 9dfcfb9

File tree

4 files changed

+3
-44
lines changed

4 files changed

+3
-44
lines changed

nitransforms/linear.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
from pathlib import Path
1414

1515
from nibabel.loadsave import load as loadimg
16-
from nibabel.affines import from_matvec, voxel_sizes
16+
from nibabel.affines import from_matvec, voxel_sizes, obliquity
1717
from .base import TransformBase
18-
from .patched import obliquity, shape_zoom_affine
18+
from .patched import shape_zoom_affine
1919

2020

2121
LPS = np.diag([-1, -1, 1, 1])

nitransforms/patched.py

-25
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,4 @@
11
import numpy as np
2-
from nibabel.affines import voxel_sizes
3-
4-
5-
def obliquity(affine):
6-
r"""
7-
Estimate the *obliquity* an affine's axes represent.
8-
The term *obliquity* is defined here as the rotation of those axes with
9-
respect to the cardinal axes.
10-
This implementation is inspired by `AFNI's implementation
11-
<https://github.com/afni/afni/blob/b6a9f7a21c1f3231ff09efbd861f8975ad48e525/src/thd_coords.c#L660-L698>`_.
12-
For further details about *obliquity*, check `AFNI's documentation
13-
<https://sscc.nimh.nih.gov/sscc/dglen/Obliquity>_.
14-
Parameters
15-
----------
16-
affine : 2D array-like
17-
Affine transformation array. Usually shape (4, 4), but can be any 2D
18-
array.
19-
Returns
20-
-------
21-
angles : 1D array-like
22-
The *obliquity* of each axis with respect to the cardinal axes, in radians.
23-
"""
24-
vs = voxel_sizes(affine)
25-
best_cosines = np.abs((affine[:-1, :-1] / vs).max(axis=1))
26-
return np.arccos(best_cosines)
272

283

294
def shape_zoom_affine(shape, zooms, x_flip=True, y_flip=False):

nitransforms/tests/test_affines.py

-16
This file was deleted.

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ python_requires = >= 3.5
77
install_requires =
88
numpy
99
scipy
10-
nibabel
10+
nibabel @ git+https://github.com/nipy/nibabel@cd48bf05bc567387afe4504eda1da15324bb616f
1111
h5py
1212
test_requires =
1313
pytest

0 commit comments

Comments
 (0)