I have a feeling this line will fail in certain circumstances. What happens if the events channel ends with an event on, e.g., `[0, 0, 0, 0, 1, 1, 1, 1]`? I think there would be one element in onsets, and zero in offsets, and you'll get an array mismatch. I imagine there would be other circumstances where that was the case, too. Something like `[0, 0, 0, 1, 2, 3, 4]` would have an even greater onset-offset mismatch.

A safer way would be to use the moving-average filter I mentioned before to quickly "look ahead" in time to see if there's another edge soon. For a given stim channel `x`, if we wanted to get all the samples that were constant for at least 3 samples, we could do it with a one-liner as:
```
>>> from scipy import signal
>>> n_constant = 3  # number of samples in a row that must be constant
>>> x = np.array([0, 0, 0, 0, 1, 1, 1, 1, 2, 1, 0])
>>> # now what we want for output is the ones that are constant that long:
>>> y = np.array([1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0])
>>> is_useable = np.r_[1-np.flipud(signal.lfilter(np.ones(n_constant - 1), [1], np.flipud(np.abs(np.diff(x).astype(float))))).astype(bool).astype(int), 0]
>>> assert np.all(y == is_useable)
```
Note that you'd just need to check to see if `n_constant` was > 1; if `n_constant = 1` you don't need to run this line (and it would fail anyway). This also needs PEP8 cleanup.

It's probably also possible to implement this more efficiently since the `diff()` operation is also quite easily expressed in pole-zero form, but I don't want to take the time to think about that in conjunction with the time reversals :)

Note that you can also do something similar to decide if the trailing-edge indices are "useable"...