Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New proposal for epoch times #115

Open
bburan opened this issue Jun 13, 2018 · 1 comment
Open

New proposal for epoch times #115

bburan opened this issue Jun 13, 2018 · 1 comment

Comments

@bburan
Copy link
Contributor

bburan commented Jun 13, 2018

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
Copy link
Contributor Author

bburan commented Jun 13, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant