mne-tools/mne-python — pull request #229 by dengemann (2012-12-05 19:21:56+00:00)
Title: ENH: dict features for Epochs objects

- parameter event_id now takes either int or dict. Internalla a dict of event_label : event_id mappings will be created which are exposed to the user.
- On init the events passed are reduced to the events available in the event_id dict. The dict is then used to subset the available events
- for this purpose I added a private function ._get_events() that is about compliant with Python dictionary .get --- returns None, if not in event_ids, else it returns the events associated with the key.
- I found instead of passing keys to average / std_error, etc. It is less testing affordant and cleaner to extend .__get_item__. It now checks, whether the key is an int or str. if int, as before subsettig by epoch number, if str and in self.event_ids an Epochs subset associated with the key is returned.

To get what @agramfort initially wanted he now can say epochs['audio'].average()

A simple test case is:

```Python

run examples/plot_read_and_write_raw_data.py

import mne

events = mne.find_events(raw)

epochs = mne.Epochs(raw, events, dict(a=1, v=2, button=32), tmin=-0.2, tmax=0.5)

epochs['button']

epochs['b']

epochs['a'].average().plot()

```

Let me know what you think about this take befor I get into further details

D