Exemplo n.º 1
0
    def test_trim_asymetric_min(self):

        V = np.array([0.401, 0.399, 0.381, 0.373, 0.368, 0.371])
        time = np.arange(0, len(V))
        time_spike = 5
        V_spike = 0.401
        global_index = 50

        spike = Spike(time, V, time_spike, V_spike, global_index,
                      xlabel="time", ylabel="voltage")

        spike.trim(0.4)

        self.assertTrue(np.array_equal(spike.time, np.arange(0, 2)))
        self.assertTrue(np.array_equal(spike.V, [0.401, 0.399]))
        self.assertEqual(spike.V_spike, 0.401)
        self.assertEqual(spike.time_spike, 5)
        self.assertEqual(spike.global_index, 50)
Exemplo n.º 2
0
    def test_trim_min(self):

        V = np.concatenate([np.arange(0, 11), np.arange(0, 10)[::-1]])
        time = np.arange(0, len(V))
        time_spike = 5
        V_spike = 10
        global_index = 50

        spike = Spike(time, V, time_spike, V_spike, global_index,
                      xlabel="time", ylabel="voltage")

        spike.trim(7, min_extent_from_peak=5)

        self.assertTrue(np.array_equal(spike.time, np.arange(5, 16)))
        self.assertTrue(np.array_equal(spike.V, [5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5]))
        self.assertEqual(spike.V_spike, 10)
        self.assertEqual(spike.time_spike, 5)
        self.assertEqual(spike.global_index, 50)
Exemplo n.º 3
0
    def test_trim(self):
        V = np.concatenate([np.arange(0, 11), np.arange(0, 10)[::-1]])
        time = np.arange(0, len(V))
        time_spike = 5
        V_spike = 10
        global_index = 50

        spike = Spike(time, V, time_spike, V_spike, global_index,
                      xlabel="time", ylabel="voltage")

        spike.trim(5)

        self.assertTrue(np.array_equal(spike.time, np.arange(5, 16)))
        self.assertTrue(np.array_equal(spike.V, [5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5]))
        self.assertEqual(spike.V_spike, 10)
        self.assertEqual(spike.time_spike, 5)
        self.assertEqual(spike.global_index, 50)


        V = np.concatenate([np.arange(0, 11), np.arange(0, 10)[::-1]])
        time = np.arange(0, len(V))
        time_spike = 5
        V_spike = 10
        global_index = 50

        spike = Spike(time, V, time_spike, V_spike, global_index,
                      xlabel="time", ylabel="voltage")

        spike.trim(-5)

        self.assertTrue(np.array_equal(spike.time, time))
        self.assertTrue(np.array_equal(spike.V, V))
        self.assertEqual(spike.V_spike, V_spike)
        self.assertEqual(spike.time_spike, time_spike)
        self.assertEqual(spike.global_index, global_index)


        V = np.concatenate([np.arange(0, 11), np.arange(0, 10)[::-1]])
        time = np.arange(0, len(V))
        time_spike = 5
        V_spike = 10
        global_index = 50

        spike = Spike(time, V, time_spike, V_spike, global_index,
                      xlabel="time", ylabel="voltage")

        # with self.assertRaises(RuntimeError):
        spike.trim(15)