Table Of Contents

Previous topic

mvpa.misc.stats

Next topic

mvpa.misc.transformers

This Page

Quick search

mvpa.misc.support

Support function – little helpers in everyday life

The comprehensive API documentation for this module, including all technical details, is available in the Epydoc-generated API reference for mvpa.misc.support (for developers).

Classes

Event

class mvpa.misc.support.Event(**kwargs)

Bases: dict

Simple class to define properties of an event.

The class is basically a dictionary. Any properties can be pass as keyword arguments to the constructor, e.g.:

>>> ev = Event(onset=12, duration=2.45)

Conventions for keys:

onset
The onset of the event in some unit.
duration
The duration of the event in the same unit as onset.
label
E.g. the condition this event is part of.
chunk
Group this event is part of (if any), e.g. experimental run.
features
Any amount of additional features of the event. This might include things like physiological measures, stimulus intensity. Must be a mutable sequence (e.g. list), if present.
asDescreteTime(dt, storeoffset=False)

Convert onset and duration information into descrete timepoints.

Parameters:
  • dt (float) – Temporal distance between two timepoints in the same unit as onset and duration.
  • storeoffset (bool) – If True, the temporal offset between original onset and descretized onset is stored as an additional item in features.
Return:

A copy of the original Event with onset and optionally duration replaced by their corresponding descrete timepoint. The new onset will correspond to the timepoint just before or exactly at the original onset. The new duration will be the number of timepoints covering the event from the computed onset timepoint till the timepoint exactly at the end, or just after the event.

Note again, that the new values are expressed as #timepoint and not in their original unit!

See also

Derived classes might provide additional methods via their base classes. Please refer to the list of base classes (if it exists) at the begining of the Event documentation.

Full API documentation of Event in module mvpa.misc.support.

Harvester

class mvpa.misc.support.Harvester(source, calls, simplify_results=True)

Bases: object

World domination helper: do whatever it is asked and accumulate results

XXX Thinks about:
  • Might we need to deepcopy attributes values?
  • Might we need to specify what attribs to copy and which just to bind?

Initialize

Parameters:
  • source – Generator which produce food for the calls.
  • calls (sequence of HarvesterCall instances) – Calls which are processed in the loop. All calls are processed in order of apperance in the sequence.
  • simplify_results (bool) – Remove unecessary overhead in results if possible (nested lists and dictionaries).

See also

Derived classes might provide additional methods via their base classes. Please refer to the list of base classes (if it exists) at the begining of the Harvester documentation.

Full API documentation of Harvester in module mvpa.misc.support.

HarvesterCall

class mvpa.misc.support.HarvesterCall(call, attribs=None, argfilter=None, expand_args=True, copy_attribs=True)

Bases: object

Initialize

Parameters:
  • expand_args (bool) – Either to expand the output of looper into a list of arguments for call
  • attribs (list of basestr) – What attributes of call to store and return later on?
  • copy_attribs (bool) – Force copying values of attributes

See also

Derived classes might provide additional methods via their base classes. Please refer to the list of base classes (if it exists) at the begining of the HarvesterCall documentation.

Full API documentation of HarvesterCall in module mvpa.misc.support.

MapOverlap

class mvpa.misc.support.MapOverlap(overlap_threshold=1.0)

Bases: object

Compute some overlap stats from a sequence of binary maps.

When called with a sequence of binary maps (e.g. lists or arrays) the fraction of mask elements that are non-zero in a customizable proportion of the maps is returned. By default this threshold is set to 1.0, i.e. such an element has to be non-zero in all maps.

Three additional maps (same size as original) are computed:

  • overlap_map: binary map which is non-zero for each overlapping element.

  • spread_map: binary map which is non-zero for each element that is

    non-zero in any map, but does not exceed the overlap threshold.

  • ovstats_map: map of float with the raw elementwise fraction of overlap.

All maps are available via class members.

Nothing to be seen here.

See also

Derived classes might provide additional methods via their base classes. Please refer to the list of base classes (if it exists) at the begining of the MapOverlap documentation.

Full API documentation of MapOverlap in module mvpa.misc.support.

Functions

mvpa.misc.support.RFEHistory2maps(history)

Convert history generated by RFE into the array of binary maps

Example:
history2maps(N.array( [ 3,2,1,0 ] ))
results in
array([[ 1., 1., 1., 1.],
[ 1., 1., 1., 0.], [ 1., 1., 0., 0.], [ 1., 0., 0., 0.]])

See also

Full API documentation of RFEHistory2maps() in module mvpa.misc.support.

mvpa.misc.support.getBreakPoints(items, contiguous=True)

Return a list of break points.

Parameters:
  • items (iterable) – list of items, such as chunks
  • contiguous (bool) – if True (default) then raise Value Error if items are not contiguous, i.e. a label occur in multiple contiguous sets
Raises:

ValueError

Returns:

list of indexes for every new set of items

See also

Full API documentation of getBreakPoints() in module mvpa.misc.support.

mvpa.misc.support.getUniqueLengthNCombinations(data, n)

Generates a list of lists containing all combinations of elements of data of length ‘n’ without repetitions.

data: list n: integer

This function is adapted from a Java version posted in some forum on the web as an answer to the question ‘How can I generate all possible combinations of length n?’. Unfortunately I cannot remember which forum it was.

mvpa.misc.support.idhash(val)
Craft unique id+hash for an object

See also

Full API documentation of idhash() in module mvpa.misc.support.

mvpa.misc.support.indentDoc(v)

Given a value returns a string where each line is indented

Needed for a cleaner __repr__ output v - arbitrary

See also

Full API documentation of indentDoc() in module mvpa.misc.support.

mvpa.misc.support.isInVolume(coord, shape)

For given coord check if it is within a specified volume size.

Returns True/False. Assumes that volume coordinates start at 0. No more generalization (arbitrary minimal coord) is done to save on performance

See also

Full API documentation of isInVolume() in module mvpa.misc.support.

mvpa.misc.support.isSorted(items)

Check if listed items are in sorted order.

Parameters:
  • items (iterable container) –
Returns:

True if were sorted. Otherwise False + Warning

See also

Full API documentation of isSorted() in module mvpa.misc.support.

mvpa.misc.support.reuseAbsolutePath(file1, file2, force=False)

Use path to file1 as the path to file2 is no absolute path is given for file2

Parameters:
  • force (bool) – if True, force it even if the file2 starts with /

See also

Full API documentation of reuseAbsolutePath() in module mvpa.misc.support.

mvpa.misc.support.transformWithBoxcar(data, startpoints, boxlength, offset=0, fx=<function mean at 0x879909c>)

This function extracts boxcar windows from an array. Such a boxcar is defined by a starting point and the size of the window along the first axis of the array (boxlength). Afterwards a customizable function is applied to each boxcar individually (Default: averaging).

Parameters:
  • data (array) – An array with an arbitrary number of dimensions.
  • startpoints (sequence) – Boxcar startpoints as index along the first array axis
  • boxlength (int) – Length of the boxcar window in #array elements
  • offset (int) – Optional offset between the configured starting point and the actual begining of the boxcar window.
Return type:

array (len(startpoints) x data.shape[1:])

See also

Full API documentation of transformWithBoxcar() in module mvpa.misc.support.