Package mvpa :: Package mappers :: Module metric :: Class DescreteMetric
[hide private]
[frames] | no frames]

Class DescreteMetric

source code


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.

Instance Methods [hide private]
 
__init__(self, elementsize=1, distance_function=cartesianDistance, compatmask=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
_expandRadius(self, radius) source code
 
_computeFilter(self, radius)
(Re)compute filter_coord based on given radius
source code
 
getNeighbors(self, origin, radius=0)
Returns coordinates of the neighbors which are within distance from coord.
source code
 
_setFilter(self, filter_coord)
Lets allow to specify some custom filter to use
source code
 
_getFilter(self)
Lets allow to specify some custom filter to use
source code
 
_setElementSize(self, v) source code
 
_getCompatMask(self)
Return compatmask
source code
 
_setCompatMask(self, compatmask)
Set new value of compatmask
source code

Inherited from Metric: getNeighbor

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  filter_coord = property(fget= _getFilter, fset= _setFilter)
  elementsize = property(fget= lambda self: self.__elementsize, ...
  compatmask = property(_getCompatMask, _setCompatMask)
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, elementsize=1, distance_function=cartesianDistance, compatmask=None)
(Constructor)

source code 
x.__init__(...) initializes x; see help(type(x)) for signature
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.
Overrides: object.__init__

getNeighbors(self, origin, radius=0)

source code 
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.
Overrides: Metric.getNeighbors

_getCompatMask(self)

source code 

Return compatmask

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

Class Variable Details [hide private]

elementsize

Value:
property(fget= lambda self: self.__elementsize, fset= _setElementSize)