def _get_blocks(self, n1, n2): """Wraps EEGFile._get_blocks to change the montage of the data""" block = EEGFile._get_blocks(self, n1, n2) new_block = self._block_descriptor.new(len(block)) for label, elec1, elec2 in self.indices: new_block[label] = block[elec2] - block[elec1] return new_block
def _cache_blocks(self, n2): """Cache the first n blocks if not already done""" # Retrieve blocks n1 = self._last_block blockseg = EEGFile._get_blocks(self, n1, n2) block_ind = len(self._blocksegments) self._blocksegments.append((blockseg, n1)) for n in range(n1, n2): self._blockrefs[n] = block_ind self._last_block = n2
def _get_blocks(self, n1, n2): block = EEGFile._get_blocks(self, n1, n2) block_new = block.copy() # Hopefully the filtering has previously ended on the block before initial_states = self._filter_states.get(n1, self._zero_states) final_states = [] for name, f, zi in zip(block.keys(), self._filters, initial_states): x_old = block[name] x_new, zf = self._apply_filter(x_old, f, zi) block_new[name] = numpy.round(x_new) final_states.append(zf) self._filter_states[n2] = final_states # Return as normal return block_new
def _get_blocks(self, n1, n2): """Wraps EEGFile._get_block to return a different block""" n1, n2 = [n + self._n1 for n in (n1, n2)] return EEGFile._get_blocks(self, n1, n2)