Table Of Contents

Previous topic

core.image.roi

Next topic

core.reference.coordinate_map

This Page

core.reference.array_coords

Module: core.reference.array_coords

Inheritance diagram for nipy.core.reference.array_coords:

Some CoordinateMaps have input_coords that are ‘array’ coordinates, hence the function of the CoordinateMap can be evaluated at these ‘array’ points.

This module tries to make these operations easier by defining a class ArrayCoordMap that is essentially a CoordinateMap and a shape.

This class has two properties: values, transposed_values the CoordinateMap at np.indices(shape).

The class Grid is meant to take a CoordinateMap and an np.mgrid-like notation to create an ArrayCoordMap.

Classes

ArrayCoordMap

class nipy.core.reference.array_coords.ArrayCoordMap(coordmap, shape)

Bases: object

When the input_coords of a CoordinateMap can be thought of as ‘array’ coordinates, i.e. an ‘input_shape’ makes sense. We can than evaluate the CoordinateMap at np.indices(input_shape)

__init__(coordmap, shape)
Parameters:

coordmap : CoordinateMap

A CoordinateMap with input_coords that are ‘array’ coordinates.

shape : sequence of int

The size of the (implied) underlying array.

static from_shape(coordmap, shape)
Create an evaluator assuming that coordmap.input_coords are ‘array’ coordinates.
transposed_values
Get values of ArrayCoordMap in an array of shape (self.coordmap.ndim[1],) + self.shape)
values
Get values of ArrayCoordMap in a 2-dimensional array of shape (product(self.shape), self.coordmap.ndim[1]))

Grid

class nipy.core.reference.array_coords.Grid(coords)

Bases: object

Simple class to construct Affine instances with slice notation like np.ogrid/np.mgrid.

>>> c = CoordinateSystem('xy', 'input')
>>> g = Grid(c)
>>> points = g[-1:1:21j,-2:4:31j]
>>> points.coordmap.affine
array([[ 0.1,  0. , -1. ],
       [ 0. ,  0.2, -2. ],
       [ 0. ,  0. ,  1. ]])
>>> print points.coordmap.input_coords
name: 'product', coord_names: ('i0', 'i1'), coord_dtype: float64
>>> print points.coordmap.output_coords
name: 'input', coord_names: ('x', 'y'), coord_dtype: float64
>>> points.shape
(21, 31)
>>> print points.transposed_values.shape
(2, 21, 31)
>>> print points.values.shape
(651, 2)
__init__(coords)

Initialize Grid object

Parameters:

coords: ``CoordinateMap`` or ``CoordinateSystem`` :

A coordinate map to be ‘sliced’ into. If coords is a CoordinateSystem, then an Affine instance is created with coords with identity transformation.