Move and generalise threshold
Attempt at transforming event matrix, probably too slow to be practical