Did I find the right examples for you? yes no

# volume_img.VolumeImg

All Samples(34)  |  Call(28)  |  Derive(0)  |  Import(6)

```        values = self.values_in_world(x, y, z)
# We import late to avoid circular import
from .volume_img import VolumeImg
return VolumeImg(values, affine,
```

```        values = self.values_in_world(x, y, z)
# We import late to avoid circular import
from .volume_img import VolumeImg
return VolumeImg(values, affine,
```

```from ...transforms.affine_transform import AffineTransform
from ...transforms.transform import Transform
from ..volume_img import VolumeImg, CompositionError

from nose.tools import assert_true
```
```    affine = np.eye(4)
affine[:3, -1] = 0.5*np.array(shape[:3])
ref_im = VolumeImg(data, affine, 'mine')
rot_im = ref_im.as_volume_img(affine, interpolation='nearest')
yield np.testing.assert_almost_equal, data, rot_im.get_data()
```
```    data = np.random.random(shape)
affine = np.eye(4)
ref_im = VolumeImg(data, affine, 'mine')
rot_im = ref_im.as_volume_img(2*affine, interpolation='nearest')
downsampled = data[::2, ::2, ::2, ...]
```
```    prng = np.random.RandomState(10)
data = prng.randint(4, size=(1, 4, 4))
img = VolumeImg(data, np.eye(4), 'mine', interpolation='nearest')
for angle in (0, np.pi, np.pi/2, np.pi/4, np.pi/3):
rot = rotation(0, angle)
```
```    affine = np.eye(4)
affine[:3, -1] = 0.5*np.array(shape[:3])
ref_im = VolumeImg(data, affine, 'mine')
# Test with purely positive matrices and compare to a rotation
for theta, phi in np.random.randint(4, size=(5, 2)):
```

```from ...transforms.affine_transform import AffineTransform
from ...transforms.transform import Transform
from ..volume_img import VolumeImg, CompositionError

from nose.tools import assert_true
```
```    affine = np.eye(4)
affine[:3, -1] = 0.5*np.array(shape[:3])
ref_im = VolumeImg(data, affine, 'mine')
rot_im = ref_im.as_volume_img(affine, interpolation='nearest')
yield np.testing.assert_almost_equal, data, rot_im.get_data()
```
```    data = np.random.random(shape)
affine = np.eye(4)
ref_im = VolumeImg(data, affine, 'mine')
rot_im = ref_im.as_volume_img(2*affine, interpolation='nearest')
downsampled = data[::2, ::2, ::2, ...]
```
```    prng = np.random.RandomState(10)
data = prng.randint(4, size=(1, 4, 4))
img = VolumeImg(data, np.eye(4), 'mine', interpolation='nearest')
for angle in (0, np.pi, np.pi/2, np.pi/4, np.pi/3):
rot = rotation(0, angle)
```
```    affine = np.eye(4)
affine[:3, -1] = 0.5*np.array(shape[:3])
ref_im = VolumeImg(data, affine, 'mine')
# Test with purely positive matrices and compare to a rotation
for theta, phi in np.random.randint(4, size=(5, 2)):
```

```# Local imports
from ..volume_grid import VolumeGrid
from ..volume_img import VolumeImg
from ...transforms.transform import Transform, CompositionError

```
```    # Check that if I 'resampled_to_img' on an VolumeImg, I get an
# VolumeImg, and vice versa
volume_image = VolumeImg(data, np.eye(4), 'world')
identity  = Transform('voxels', 'world', id, id)
image = VolumeGrid(data, identity)
```

```# Local imports
from ..volume_grid import VolumeGrid
from ..volume_img import VolumeImg
from ...transforms.transform import Transform, CompositionError

```
```    # Check that if I 'resampled_to_img' on an VolumeImg, I get an
# VolumeImg, and vice versa
volume_image = VolumeImg(data, np.eye(4), 'world')
identity  = Transform('voxels', 'world', id, id)
image = VolumeGrid(data, identity)
```