Table Of Contents

Previous topic

mappers.mask

Next topic

mappers.pca

This content refers to the previous stable release of PyMVPA. Please visit www.pymvpa.org for the most recent version of PyMVPA and its documentation.

mappers.metric

Module: mappers.metric

Inheritance diagram for mvpa.mappers.metric:

Classes and functions to provide sense of distances between sample points

Classes

DescreteMetric

class mvpa.mappers.metric.DescreteMetric(elementsize=1, distance_function=<function cartesianDistance at 0x66a4e60>, compatmask=None)

Bases: mvpa.mappers.metric.Metric

Find neighboring points in descretized space

If input space is descretized and all points fill in N-dimensional cube, this finder returns list of neighboring points for a given distance.

For all origin coordinates this class exclusively operates on discretized values, not absolute coordinates (which are e.g. in mm).

Additionally, this metric has the notion of compatible and incompatible dataspace metrics, i.e. the descrete space might contain dimensions for which computing an overall distance is not meaningful. This could, for example, be a combined spatio-temporal space (three spatial dimension, plus the temporal one). This metric allows to define a boolean mask (compatmask) which dimensions share the same dataspace metrics and for which the distance function should be evaluated. If a compatmask is provided, all cordinates are projected into the subspace of the non-zero dimensions and distances are computed within that space.

However, by using a per dimension radius argument for the getNeighbor methods, it is nevertheless possible to define a neighborhood along all dimension. For all non-compatible axes the respective radius is treated as a one-dimensional distance along the respective axis.

Parameters:
  • elementsize (float | sequence) – The extent of a dataspace element along all dimensions.
  • distance_function (functor) – The distance measure used to determine distances between dataspace elements.
  • compatmask (1D bool array | None) – A mask where all non-zero elements indicate dimensions with compatible spacemetrics. If None (default) all dimensions are assumed to have compatible spacemetrics.
compatmask

Return compatmask

Note

Don’t modify in place since it would need to require to reset __filter_radius whenever changed

elementsize
filter_coord

Lets allow to specify some custom filter to use

getNeighbors(origin, radius=0)

Returns coordinates of the neighbors which are within distance from coord.

Parameters:
  • origin (1D array) – The center coordinate of the neighborhood.
  • radius (scalar | sequence) – If a scalar, the radius is treated as identical along all dimensions of the dataspace. If a sequence, it defines a per dimension radius, thus has to have the same number of elements as dimensions. Currently, only spherical neighborhoods are supported. Therefore, the radius has to be equal along all dimensions flagged as having compatible dataspace metrics. It is, however, possible to define variant radii for all other dimensions.

Metric

class mvpa.mappers.metric.Metric

Bases: object

Abstract class for any metric.

Subclasses abstract a metric of a dataspace with certain properties and can be queried for structural information. Currently, this is limited to neighborhood information, i.e. identifying the surround a some coordinate in the respective dataspace.

At least one of the methods (getNeighbors, getNeighbor) has to be overriden in every derived class. NOTE: derived #2 from derived class #1 has to override all methods which were overrident in class #1

getNeighbor(*args, **kwargs)

Generator to return coordinate of the neighbor.

Base class contains the simplest implementation, assuming that getNeighbors returns iterative structure to spit out neighbors 1-by-1

getNeighbors(*args, **kwargs)

Return the list of coordinates for the neighbors.

By default it simply constracts the list based on the generator getNeighbor