Package mvpa :: Package mappers :: Module mask :: Class MaskMapper
[hide private]
[frames] | no frames]

Class MaskMapper

source code


Mapper which uses a binary mask to select "Features"
Instance Methods [hide private]
 
__init__(self, mask, **kwargs)
Initialize MaskMapper
source code
 
__str__(self)
str(x)
source code
 
__repr__(self)
repr(x)
source code
 
_initMask(self, mask)
Initialize internal state with mask-derived information
source code
 
forward(self, data)
Map data from the original dataspace into featurespace.
source code
 
reverse(self, data)
Reverse map data from featurespace into the original dataspace.
source code
 
getInSize(self)
InShape is a shape of original mask
source code
 
getOutSize(self)
OutSize is a number of non-0 elements in the mask
source code
 
getMask(self, copy=True)
By default returns a copy of the current mask.
source code
 
getInId(self, outId)
Returns a features coordinate in the original data space for a given feature id.
source code
 
getInIds(self)
Returns a 2d array where each row contains the coordinate of the feature with the corresponding id.
source code
 
isValidInId(self, inId)
Validate id in IN space.
source code
 
getOutId(self, coord)
Translate a feature mask coordinate into a feature ID.
source code
 
selectOut(self, outIds)
Only listed outIds would remain.
source code
 
discardOut(self, outIds)
Listed outIds would be discarded
source code
 
convertOutIds2OutMask(self, outIds)
Returns a boolean mask with all features in outIds selected.
source code
 
convertOutIds2InMask(self, outIds)
Returns a boolean mask with all features in ouIds selected.
source code

Inherited from base.Mapper: __call__, getMetric, getNeighbor, getNeighborIn, getNeighbors, isValidOutId, setMetric, train

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

Class Variables [hide private]
  __doc__ = enhancedDocString('MaskMapper', locals(), Mapper)
  mask = property(fget= lambda self: self.getMask(False))

Inherited from base.Mapper: metric, nfeatures

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, mask, **kwargs)
(Constructor)

source code 
Initialize MaskMapper
Parameters:
  • mask (array) - an array in the original dataspace and its nonzero elements are used to define the features included in the dataset
Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 
str(x)
Overrides: object.__str__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 
repr(x)
Overrides: object.__repr__
(inherited documentation)

_initMask(self, mask)

source code 

Initialize internal state with mask-derived information

It is needed to initialize structures for the fast and reverse lookup to don't impose performance hit on any future operation

forward(self, data)

source code 
Map data from the original dataspace into featurespace.
Overrides: base.Mapper.forward

reverse(self, data)

source code 
Reverse map data from featurespace into the original dataspace.
Overrides: base.Mapper.reverse

getInSize(self)

source code 
InShape is a shape of original mask
Overrides: base.Mapper.getInSize

getOutSize(self)

source code 
OutSize is a number of non-0 elements in the mask
Overrides: base.Mapper.getOutSize

getMask(self, copy=True)

source code 

By default returns a copy of the current mask.

If 'copy' is set to False a reference to the mask is returned instead. This shared mask must not be modified!

getInId(self, outId)

source code 

Returns a features coordinate in the original data space for a given feature id.

If this method is called with a list of feature ids it returns a 2d-array where the first axis corresponds the dimensions in 'In' dataspace and along the second axis are the coordinates of the features on this dimension (like the output of NumPy.array.nonzero()).

XXX it might become __get_item__ access method

Overrides: base.Mapper.getInId

isValidInId(self, inId)

source code 

Validate id in IN space.

Override if IN space is not simly a 1D vector

Overrides: base.Mapper.isValidInId
(inherited documentation)

selectOut(self, outIds)

source code 

Only listed outIds would remain.

Function assumes that outIds are sorted. In __debug__ mode selectOut would check if obtained IDs are sorted and would warn the user if they are not.

If you feel strongly that you need to remap features internally (ie to allow Ids with mixed order) please contact developers of mvpa to discuss your use case.

The function used to accept a matrix-mask as the input but now it really has to be a list of IDs

Feature/Bug:
  • Negative outIds would not raise exception - just would be treated 'from the tail'
Parameters:
  • outIds, sequence - Subset of ids of the current feature in OUT space to keep.
Overrides: base.Mapper.selectOut

convertOutIds2OutMask(self, outIds)

source code 
Returns a boolean mask with all features in outIds selected.
Parameters:
  • outIds, list, or, 1d, array - To be selected features ids in out-space.
Returns:
ndarray: dtype='bool'
All selected features are set to True; False otherwise.

convertOutIds2InMask(self, outIds)

source code 

Returns a boolean mask with all features in ouIds selected.

This method works exactly like Mapper.convertOutIds2OutMask(), but the feature mask is finally (reverse) mapped into in-space.

Parameters:
  • outIds, list, or, 1d, array - To be selected features ids in out-space.
Returns:
ndarray: dtype='bool'
All selected features are set to True; False otherwise.