NIPY logo

Site Navigation

NIPY Community

Table Of Contents

This Page

core.reference.array_coords

Module: core.reference.array_coords

Inheritance diagram for nipy.core.reference.array_coords:

Some CoordinateMaps have a domain 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 function_domain 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)

Methods

from_shape
__init__(coordmap, shape)
Parameters:

coordmap : CoordinateMap

A CoordinateMap with function_domain 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.function_domain are ‘array’ coordinates.
transposed_values
Get values of ArrayCoordMap in an array of shape (self.coordmap.ndims[1],) + self.shape)
values
Get values of ArrayCoordMap in a 2-dimensional array of shape (product(self.shape), self.coordmap.ndims[1]))

Grid

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

Bases: object

Simple class to construct AffineTransform 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.function_domain
CoordinateSystem(coord_names=('i0', 'i1'), name='product', coord_dtype=float64)
>>> print points.coordmap.function_range
CoordinateSystem(coord_names=('x', 'y'), name='input', 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 AffineTransform instance is created with coords with identity transformation.