Skip to content

Creating epochs from events #388

Closed
Closed

Description

@mdenker

An array of events (class Event) [t1, t2, t3] can be transformed into an array of epochs (class Epoch), [(t1, t2), (t2, t3)].

It would be useful to add this as a method Event.to_epoch()

Example:

>>> import numpy as np
>>> from neo import Epoch, Event, Segment

>>> seg = Segment(name="test")
>>> event = Event(times=np.array([5.0, 12.0, 23.0, 45.0]), units="ms", labels=np.array(["A", "B", "C", "D"]))
>>> event.segment = seg

>>> epoch = event.to_epoch()
>>> epoch.times
array([5.0, 12.0, 23.0]) * ms
>>> epoch.durations
array([7.0, 11.0, 22.0]) * ms
>>> epoch.labels
array(['A-B', 'B-C', 'C-D'])
>>> epoch.segment.name
"test"

Activity

  1. added this to the future milestone on Sep 26, 2017
  2. apdavison commented on Oct 22, 2018

    @apdavison
    Member

    Replaced #404 by #586

  3. zm711 commented on Feb 10, 2024

    @zm711
    Contributor

    This appears to be closed by #586. Reopen if I am wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions