Skip to content

Commit 3144331

Browse files
committed
sty: pep8 complaints
1 parent 930569b commit 3144331

File tree

5 files changed

+36
-11
lines changed

5 files changed

+36
-11
lines changed

nitransforms/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ def _to_hdf5(self, group):
8787

8888
def __eq__(self, other):
8989
try:
90-
return np.allclose(
91-
self.affine, other.affine, rtol=EQUALITY_TOL) and self.shape == other.shape
90+
return (
91+
np.allclose(self.affine, other.affine, rtol=EQUALITY_TOL)
92+
and self.shape == other.shape
93+
)
9294
except AttributeError:
9395
pass
9496
return False

nitransforms/conftest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ def get_data():
5858
newaff[0, 0] *= -1.0
5959
newaff[1, 1] *= -1.0
6060
newaff[:2, 3] = imgaff.dot(np.hstack((np.array(img.shape[:3]) - 1, 1.0)))[:2]
61-
_data['LPS'] = nb.Nifti1Image(np.flip(np.flip(img.get_fdata(), 0), 1), newaff, img.header)
62-
A = nb.volumeutils.shape_zoom_affine(img.shape, img.header.get_zooms(), x_flip=False)
61+
_data['LPS'] = nb.Nifti1Image(
62+
np.flip(np.flip(img.get_fdata(), 0), 1), newaff, img.header
63+
)
64+
A = nb.volumeutils.shape_zoom_affine(
65+
img.shape, img.header.get_zooms(), x_flip=False
66+
)
6367
R = nb.affines.from_matvec(nb.eulerangles.euler2mat(x=0.09, y=0.001, z=0.001))
6468
newaff = R.dot(A)
6569
oblique_img = nb.Nifti1Image(img.get_fdata(), newaff, img.header)

nitransforms/linear.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ def __init__(self, matrix=None, reference=None):
5858

5959
self._matrix = np.array(matrix)
6060
assert self._matrix.ndim == 3, 'affine matrix should be 3D'
61-
assert self._matrix.shape[-2] == self._matrix.shape[-1], 'affine matrix is not square'
61+
assert (
62+
self._matrix.shape[-2] == self._matrix.shape[-1]
63+
), 'affine matrix is not square'
6264

6365
if reference:
6466
if isinstance(reference, str):
@@ -196,7 +198,9 @@ def map_voxel(self, index, nindex=0, moving=None):
196198
if index.shape[0] == self._matrix[nindex].shape[0] - 1:
197199
index = np.append(index, [1])
198200

199-
matrix = reference.affine.dot(self._matrix[nindex].dot(np.linalg.inv(moving.affine)))
201+
matrix = reference.affine.dot(
202+
self._matrix[nindex].dot(np.linalg.inv(moving.affine))
203+
)
200204
return tuple(matrix.dot(index)[:-1])
201205

202206
def _to_hdf5(self, x5_root):
@@ -235,7 +239,10 @@ def to_filename(self, filename, fmt='X5', moving=None):
235239
T = self.matrix.copy()
236240
pre = LPS
237241
post = LPS
238-
if obliquity(self.reference.affine).min() * 180 / pi > OBLIQUITY_THRESHOLD_DEG:
242+
if (
243+
obliquity(self.reference.affine).min() * 180 / pi
244+
> OBLIQUITY_THRESHOLD_DEG
245+
):
239246
print('Reference affine axes are oblique.')
240247
M = self.reference.affine
241248
A = shape_zoom_affine(self.reference.shape,
@@ -245,7 +252,11 @@ def to_filename(self, filename, fmt='X5', moving=None):
245252
if not moving:
246253
moving = self.reference
247254

248-
if moving and obliquity(moving.affine).min() * 180 / pi > OBLIQUITY_THRESHOLD_DEG:
255+
if (
256+
moving
257+
and obliquity(moving.affine).min() * 180 / pi
258+
> OBLIQUITY_THRESHOLD_DEG
259+
):
249260
print('Moving affine axes are oblique.')
250261
M2 = moving.affine
251262
A2 = shape_zoom_affine(moving.shape,

nitransforms/nonlinear.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def _interp_transform(self, coords):
219219
self._coeffs[ijk] if not np.any(offbounds)
220220
else [0.0] * self.ndim)
221221

222-
coords[:3] += weights.dot(np.array(coeffs, dtype=float))
222+
# coords[:3] += weights.dot(np.array(coeffs, dtype=float))
223223
return self.reference.inverse.dot(np.hstack((coords, 1)))[:3]
224224

225225
def map_voxel(self, index, moving=None):
@@ -237,7 +237,9 @@ def resample(self, moving, order=3, mode='constant', cval=0.0, prefilter=True,
237237
>>> coeffs = np.zeros((6, 6, 6, 3))
238238
>>> coeffs[2, 2, 2, ...] = [10.0, -20.0, 0]
239239
>>> aff = ref.affine
240-
>>> aff[:3, :3] = aff[:3, :3].dot(np.eye(3) * np.array(ref.header.get_zooms()[:3]) / 6.0)
240+
>>> aff[:3, :3] = aff[:3, :3].dot(np.eye(3) * np.array(
241+
... ref.header.get_zooms()[:3]) / 6.0
242+
... )
241243
>>> coeffsimg = nb.Nifti1Image(coeffs, ref.affine, ref.header)
242244
>>> xfm = BSplineFieldTransform(ref, coeffsimg)
243245
>>> new = xfm.resample(ref) # doctest: +SKIP

nitransforms/tests/test_transform.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,13 @@ def test_linear_save(data_path, get_data, image_orientation, sw_tool):
104104
'RAS', 'LAS', 'LPS', # 'oblique',
105105
])
106106
@pytest.mark.parametrize('sw_tool', ['itk', 'fsl', 'afni'])
107-
def test_apply_linear_transform(tmpdir, data_path, get_data, image_orientation, sw_tool):
107+
def test_apply_linear_transform(
108+
tmpdir,
109+
data_path,
110+
get_data,
111+
image_orientation,
112+
sw_tool
113+
):
108114
"""Check implementation of exporting affines to formats."""
109115
tmpdir.chdir()
110116

0 commit comments

Comments
 (0)