Added the possibility of an onset until data is stored, only in the mex
file however