'Group events by their row and col axis values
@param cumulative: include previous events'

def group(self, cumulative=False):

    event_sets = [self.cevents]
    if cumulative:
        event_sets.append(self.pevents)
    rows = {}
    cols = {}
    matrix = {}
    from itertools import product
    for (index, events) in enumerate(event_sets):
        for (event_id, event) in events.items():
            for key in event.rows:
                row = rows.get(key)
                if (row is None):
                    row = rows[key] = (set(), set())
                row[index].add(event_id)
            for key in event.cols:
                col = cols.get(key)
                if (col is None):
                    col = cols[key] = (set(), set())
                col[index].add(event_id)
            for key in product(event.rows, event.cols):
                cell = matrix.get(key)
                if (cell is None):
                    cell = matrix[key] = (set(), set())
                cell[index].add(event_id)
    self._rows = rows
    self._cols = cols
    self._matrix = matrix
