def testSliceExcludeEvents(self): sig = analogs.AnalogSignal(np.sin(np.arange(10000.)), 0.1) # check something in the middle splits in 2 res0 = list(sig.slice_exclude_events([500.0],t_min=0., t_max=0.)) assert len(res0)==2 assert res0[0].t_stop == res0[1].t_start assert res0[0].t_start == sig.t_start assert res0[1].t_stop == sig.t_stop # check that event at t_start yields only one slice, removing t_max res1 = list(sig.slice_exclude_events([0.0],t_min=10., t_max=10.)) assert len(res1)==1 assert res1[0].t_start == sig.t_start+10.0 assert res1[0].duration() == 990.0 # check something in the middle splits in 2 res2 = list(sig.slice_exclude_events([250.0, 750.0], t_min=50., t_max=50.)) assert len(res2)==3 assert res2[0].duration() == 200.0 assert res2[1].duration() == 400.0 assert res2[2].duration() == 200.0 # check behaviour at the end (t_stop) res3 = list(sig.slice_exclude_events([1000.0], t_min=50., t_max=50.)) assert len(res3)==1 assert res3[0].duration() == 950.0
def testThresholdDetection(self): sig = np.zeros(10000) for idx in xrange(10): sig[100*idx:100*idx+50] = 0.5 sig = analogs.AnalogSignal(sig, 0.1) res = sig.threshold_detection(0.1) assert len(res) == 10
def testCovariance(self): a1 = analogs.AnalogSignal(np.random.normal(size=10000),dt=0.1) a2 = analogs.AnalogSignal(np.random.normal(size=10000),dt=0.1) assert a1.cov(a2) < 0.5 assert a1.cov(a1) > 0.5
def testSliceByEvents(self): sig = analogs.AnalogSignal(np.sin(np.arange(10000.)), 0.1) res1 = sig.slice_by_events([0, 50, 100],t_min=0, t_max=50) res2 = sig.slice_by_events(analogs.SpikeTrain([0, 50, 100]),t_min=0, t_max=50) assert len(res1) == 3 and len(res2) == 3
def testTimeSlice(self): sig = analogs.AnalogSignal(np.sin(np.arange(10000.)), 0.1) res = sig.time_slice(0,500) self.assertEqual(len(res), 5000) res = sig.time_slice(250,750) self.assertEqual(len(res), 5000)
def testTimeAxis(self): sig = analogs.AnalogSignal(np.sin(np.arange(10000.)), 0.1) assert len(sig.time_axis() == len(sig)+1)
def testCreateAnalogSignalWithTstartTstop(self): sig = analogs.AnalogSignal(np.sin(np.arange(10000.)), 0.1, 10, 1010) self.assertEqual(len(sig), 10000) self.assertEqual(sig.t_start, 10.0) self.assertEqual(sig.t_stop, 1010.0)
def testCreateAnalogSignal(self): sig = analogs.AnalogSignal(np.sin(np.arange(10000.)), 0.1) assert len(sig) == 10000
def testAppend(self): analog = analogs.AnalogSignal(np.arange(10000), 0.1) self.assertRaises(Exception, self.analog.append, 0, analog)