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

Revert #1204, and add a filter to suppress warnings. #1206

Merged
merged 2 commits into from Apr 3, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions dipy/align/reslice.py
@@ -1,4 +1,5 @@
from multiprocessing import Pool, cpu_count
import warnings

import numpy as np
from scipy.ndimage import affine_transform
Expand Down Expand Up @@ -66,9 +67,14 @@ def reslice(data, affine, zooms, new_zooms, order=1, mode='constant', cval=0,
>>> data2.shape == (77, 77, 40)
True
"""
# We are suppressing warnings emitted by scipy >= 0.18,
# described in https://github.com/nipy/dipy/issues/1107.
# These warnings are not relevant to us, as long as our offset
# input to scipy's affine_transform is [0, 0, 0]
warnings.simplefilter("ignore")
new_zooms = np.array(new_zooms, dtype='f8')
zooms = np.array(zooms, dtype='f8')
R = np.diag(new_zooms / zooms)
R = new_zooms / zooms
new_shape = zooms / new_zooms * np.array(data.shape[:3])
new_shape = tuple(np.round(new_shape).astype('i8'))
kwargs = {'matrix': R, 'output_shape': new_shape, 'order': order,
Expand All @@ -95,6 +101,8 @@ def reslice(data, affine, zooms, new_zooms, order=1, mode='constant', cval=0,
pool.close()

Rx = np.eye(4)
Rx[:3, :3] = R
Rx[:3, :3] = np.diag(R)
affine2 = np.dot(affine, Rx)
# Turn warnings back on:
warnings.filterwarnings('always')
return data2, affine2