Skip to content

Commit f803bdd

Browse files
committed
fix: address code review comments
1 parent cf6d6a0 commit f803bdd

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

niworkflows/utils/images.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,16 @@ def resample_by_spacing(in_file, zooms, order=3, clip=True, smooth=False):
195195
)
196196

197197
if smooth:
198+
from numbers import Integral
198199
from scipy.ndimage import gaussian_filter
199-
data = gaussian_filter(in_file.get_fdata(),
200-
2 if smooth is True else smooth).astype(dtype)
200+
if smooth is True:
201+
smooth = np.maximum(0, (pre_zooms / zooms - 1) / 2)
202+
data = gaussian_filter(in_file.get_fdata(), smooth)
203+
if issubclass(dtype, Integral):
204+
data = np.round(data)
205+
data = data.astype(dtype)
201206
else:
202-
data = np.asanyarray(in_file.dataobj)
207+
data = np.asarray(in_file.dataobj, dtype=dtype)
203208

204209
# Resample data in the new grid
205210
resampled = map_coordinates(

0 commit comments

Comments
 (0)