Skip to content

Commit 68959a1

Browse files
committed
sty: run black on related files
1 parent c689721 commit 68959a1

File tree

3 files changed

+34
-16
lines changed

3 files changed

+34
-16
lines changed

niworkflows/interfaces/images.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,22 @@
2626

2727

2828
class _RegridToZoomsInputSpec(BaseInterfaceInputSpec):
29-
in_file = File(exists=True, mandatory=True,
30-
desc="a file whose resolution is to change")
31-
zooms = traits.Tuple(traits.Float, traits.Float, traits.Float,
32-
mandatory=True, desc="the new resolution")
29+
in_file = File(
30+
exists=True, mandatory=True, desc="a file whose resolution is to change"
31+
)
32+
zooms = traits.Tuple(
33+
traits.Float,
34+
traits.Float,
35+
traits.Float,
36+
mandatory=True,
37+
desc="the new resolution",
38+
)
3339
order = traits.Int(3, usedefault=True, desc="order of interpolator")
34-
clip = traits.Bool(True, usedefault=True,
35-
desc="clip the data array within the original image's range")
40+
clip = traits.Bool(
41+
True,
42+
usedefault=True,
43+
desc="clip the data array within the original image's range",
44+
)
3645

3746

3847
class _RegridToZoomsOutputSpec(TraitedSpec):
@@ -47,8 +56,10 @@ class RegridToZooms(SimpleInterface):
4756

4857
def _run_interface(self, runtime):
4958
from ..utils.images import resample_by_spacing
59+
5060
self._results["out_file"] = fname_presuffix(
51-
self.inputs.in_file, suffix="_regrid", newpath=runtime.cwd)
61+
self.inputs.in_file, suffix="_regrid", newpath=runtime.cwd
62+
)
5263
resample_by_spacing(
5364
self.inputs.in_file,
5465
self.inputs.zooms,

niworkflows/utils/images.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,19 @@ def resample_by_spacing(in_file, zooms, order=3, clip=True):
160160
new_card = nb.affines.from_matvec(np.diag(zooms), card[:3, 3] + offset)
161161

162162
# Calculate the new indexes
163-
new_grid = np.array(np.meshgrid(
164-
np.arange(new_size[0]),
165-
np.arange(new_size[1]),
166-
np.arange(new_size[2]),
167-
indexing="ij")
163+
new_grid = np.array(
164+
np.meshgrid(
165+
np.arange(new_size[0]),
166+
np.arange(new_size[1]),
167+
np.arange(new_size[2]),
168+
indexing="ij",
169+
)
168170
).reshape((3, -1))
169171

170172
# Calculate the locations of the new samples, w.r.t. the original grid
171-
ijk = np.linalg.inv(card).dot(new_card.dot(
172-
np.vstack((new_grid, np.ones((1, new_grid.shape[1]))))
173-
))
173+
ijk = np.linalg.inv(card).dot(
174+
new_card.dot(np.vstack((new_grid, np.ones((1, new_grid.shape[1])))))
175+
)
174176

175177
# Resample data in the new grid
176178
resampled = map_coordinates(

niworkflows/utils/tests/test_images.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
import numpy as np
33

44
import pytest
5-
from ..images import update_header_fields, overwrite_header, dseg_label, resample_by_spacing
5+
from ..images import (
6+
update_header_fields,
7+
overwrite_header,
8+
dseg_label,
9+
resample_by_spacing,
10+
)
611

712

813
def random_image():

0 commit comments

Comments
 (0)