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

MRG: update to plot_2d fixes and tests #543

Merged
merged 10 commits into from Jan 6, 2015
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -45,6 +45,8 @@ script:
# Change into an innocuous directory and find tests from installation
- mkdir for_testing
- cd for_testing
# No figure windows for mpl; quote to hide : from travis-ci yaml parsing
- 'echo "backend : agg" > matplotlibrc'
- if [ "${COVERAGE}" == "1" ]; then
cp ../.coveragerc .;
COVER_ARGS="--with-coverage --cover-package dipy";
Expand Down
12 changes: 8 additions & 4 deletions dipy/align/imwarp.py
Expand Up @@ -611,16 +611,18 @@ def _warp_forward(self, image, interpolation='linear', world_to_image=None,
space we need to bring via interpolation). So, S is the matrix that
converts the sampling grid (whose shape is given as parameter
'sampling_shape' ) to space coordinates.

"""
#if no world-to-image transform is provided, we use the codomain info
if world_to_image is None:
world_to_image = self.codomain_affine_inv
#if no sampling info is provided, we use the domain info
if sampling_shape is None:
if self.domain_shape is None:
raise ValueError('Unable to infer sampling info. Provide a valid sampling_shape.')
raise ValueError('Unable to infer sampling info. '
'Provide a valid sampling_shape.')
sampling_shape = self.domain_shape
else:
sampling_shape = np.asarray(sampling_shape, dtype=np.int32)
if sampling_affine is None:
sampling_affine = self.domain_affine

Expand Down Expand Up @@ -801,12 +803,14 @@ def transform(self, image, interpolation='linear', world_to_image=None,
See _warp_forward and _warp_backward documentation for further
information.
"""
if sampling_shape is not None:
sampling_shape = np.asarray(sampling_shape, dtype=np.int32)
if self.is_inverse:
warped = self._warp_backward(image, interpolation, world_to_image,
sampling_shape, sampling_affine)
sampling_shape, sampling_affine)
else:
warped = self._warp_forward(image, interpolation, world_to_image,
sampling_shape, sampling_affine)
sampling_shape, sampling_affine)
return np.asarray(warped)

def transform_inverse(self, image, interpolation='linear', world_to_image=None,
Expand Down