本文整理匯總了Python中neo.core.event.Event.to_epoch方法的典型用法代碼示例。如果您正苦於以下問題:Python Event.to_epoch方法的具體用法?Python Event.to_epoch怎麽用?Python Event.to_epoch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類neo.core.event.Event
的用法示例。
在下文中一共展示了Event.to_epoch方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_to_epoch
# 需要導入模塊: from neo.core.event import Event [as 別名]
# 或者: from neo.core.event.Event import to_epoch [as 別名]
def test_to_epoch(self):
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
# Mode 1
epoch = event.to_epoch()
self.assertIsInstance(epoch, Epoch)
assert_array_equal(epoch.times.magnitude, np.array([5.0, 12.0, 23.0]))
assert_array_equal(epoch.durations.magnitude, np.array([7.0, 11.0, 22.0]))
assert_array_equal(epoch.labels, np.array(['A-B', 'B-C', 'C-D']))
# Mode 2
epoch = event.to_epoch(pairwise=True)
assert_array_equal(epoch.times.magnitude, np.array([5.0, 23.0]))
assert_array_equal(epoch.durations.magnitude, np.array([7.0, 22.0]))
assert_array_equal(epoch.labels, np.array(['A-B', 'C-D']))
# Mode 3 (scalar)
epoch = event.to_epoch(durations=2.0 * pq.ms)
assert_array_equal(epoch.times.magnitude, np.array([5.0, 12.0, 23.0, 45.0]))
assert_array_equal(epoch.durations.magnitude, np.array([2.0, 2.0, 2.0, 2.0]))
self.assertEqual(epoch.durations.size, 4)
assert_array_equal(epoch.labels, np.array(['A', 'B', 'C', 'D']))
# Mode 3 (array)
epoch = event.to_epoch(durations=np.array([2.0, 3.0, 4.0, 5.0]) * pq.ms)
assert_array_equal(epoch.times.magnitude, np.array([5.0, 12.0, 23.0, 45.0]))
assert_array_equal(epoch.durations.magnitude, np.array([2.0, 3.0, 4.0, 5.0]))
assert_array_equal(epoch.labels, np.array(['A', 'B', 'C', 'D']))
# Error conditions
self.assertRaises(ValueError, event.to_epoch, pairwise=True, durations=2.0 * pq.ms)
odd_event = Event(times=np.array([5.0, 12.0, 23.0]), units="ms",
labels=np.array(["A", "B", "C"]))
self.assertRaises(ValueError, odd_event.to_epoch, pairwise=True)