LBHB / NEMS0

THIS VERSION OF NEMS IS NO LONGER SUPPORTED. PLEASE USE THE NEW NEMS REPOSITORY OR INSTALL NEMS_DB TO GET NEMS0 SUPPORT.
GNU General Public License v3.0
8 stars 4 forks source link

New proposal for epoch times #115

Open bburan opened 6 years ago

bburan commented 6 years ago

Many of the utility epoch functions take Nx2 arrays. I think it might be useful to have an Epoch object with overloaded operators. So, rather than doing:

a = epoch_intersection(z, y)
c = epoch_union(a, b)
e = epoch_difference(c, d)

You can do

e = ((z & y) + b) - d

You'd create the epoch:

recording_duration = 30 # duration of recording in seconds
epoch_name = 'TRIAL'
times = [
    [5, 10],
    [20, 25],
]
z = Epoch(times, epoch_name)

Note that we can do things like invert the epochs. For example:

m = ~z
m.times # now will be [[0, 5], [10, 20], [25, np.inf]]

Note that we now have a placeholder for the end of the last inverted epoch as np.inf (meaning that the epoch is essentially infinite).

When needed, we can convert it to a mask:

mask = z.as_mask(fs, duration) # provide sampling rate and duration to generate mask
bburan commented 6 years ago

@crheller @svdavid Here's a proposal that may allow us to improve the shortcomings of the epoch library.