示例#1
0
    def test_read_segment_lazy(self):
        r = ExampleIO(filename=None)
        seg = r.read_segment(lazy=True)
        for ana in seg.analogsignals:
            self.assertEqual(ana.size, 0)
            assert hasattr(ana, 'lazy_shape')
        for st in seg.spiketrains:
            self.assertEqual(st.size, 0)
            assert hasattr(st, 'lazy_shape')

        seg = r.read_segment(lazy=False)
        for anasig in seg.analogsignals:
            self.assertNotEqual(anasig.size, 0)
        for st in seg.spiketrains:
            self.assertNotEqual(st.size, 0)

        # annotations
        assert 'seg_extra_info' in seg.annotations
        assert seg.name == 'Seg #0 Block #0'
        for anasig in seg.analogsignals:
            assert anasig.name is not None
        for st in seg.spiketrains:
            assert st.name is not None
        for ev in seg.events:
            assert ev.name is not None
        for ep in seg.epochs:
            assert ep.name is not None
示例#2
0
    def test_read_segment_lazy(self):
        r = ExampleIO(filename=None)
        seg = r.read_segment(lazy=True)
        for ana in seg.analogsignals:
            assert isinstance(ana, AnalogSignalProxy)
            ana = ana.load()
            assert isinstance(ana, AnalogSignal)
        for st in seg.spiketrains:
            assert isinstance(st, SpikeTrainProxy)
            st = st.load()
            assert isinstance(st, SpikeTrain)

        seg = r.read_segment(lazy=False)
        for anasig in seg.analogsignals:
            assert isinstance(ana, AnalogSignal)
            self.assertNotEqual(anasig.size, 0)
        for st in seg.spiketrains:
            assert isinstance(st, SpikeTrain)
            self.assertNotEqual(st.size, 0)

        # annotations
        assert 'seg_extra_info' in seg.annotations
        assert seg.name == 'Seg #0 Block #0'
        for anasig in seg.analogsignals:
            assert anasig.name is not None
        for st in seg.spiketrains:
            assert st.name is not None
        for ev in seg.events:
            assert ev.name is not None
        for ep in seg.epochs:
            assert ep.name is not None
示例#3
0
    def test_read_segment_lazy(self):
        r = ExampleIO(filename=None)
        seg = r.read_segment(lazy=True)
        for ana in seg.analogsignals:
            self.assertEqual(ana.size, 0)
            assert hasattr(ana, 'lazy_shape')
        for st in seg.spiketrains:
            self.assertEqual(st.size, 0)
            assert hasattr(st, 'lazy_shape')

        seg = r.read_segment(lazy=False)
        for anasig in seg.analogsignals:
            self.assertNotEqual(anasig.size, 0)
        for st in seg.spiketrains:
            self.assertNotEqual(st.size, 0)

        # annotations
        assert 'seg_extra_info' in seg.annotations
        assert seg.name == 'Seg #0 Block #0'
        for anasig in seg.analogsignals:
            assert anasig.name is not None
        for st in seg.spiketrains:
            assert st.name is not None
        for ev in seg.events:
            assert ev.name is not None
        for ep in seg.epochs:
            assert ep.name is not None
示例#4
0
    def test_read_segment_lazy(self):
        r = ExampleIO(filename=None)
        seg = r.read_segment(lazy=True)
        for ana in seg.analogsignals:
            assert isinstance(ana, AnalogSignalProxy)
            ana = ana.load()
            assert isinstance(ana, AnalogSignal)
        for st in seg.spiketrains:
            assert isinstance(st, SpikeTrainProxy)
            st = st.load()
            assert isinstance(st, SpikeTrain)

        seg = r.read_segment(lazy=False)
        for anasig in seg.analogsignals:
            assert isinstance(ana, AnalogSignal)
            self.assertNotEqual(anasig.size, 0)
        for st in seg.spiketrains:
            assert isinstance(st, SpikeTrain)
            self.assertNotEqual(st.size, 0)

        # annotations
        assert 'seg_extra_info' in seg.annotations
        assert seg.name == 'Seg #0 Block #0'
        for anasig in seg.analogsignals:
            assert anasig.name is not None
        for st in seg.spiketrains:
            assert st.name is not None
        for ev in seg.events:
            assert ev.name is not None
        for ep in seg.epochs:
            assert ep.name is not None
示例#5
0
    def test_read_block_with_time_slices(self):
        r = ExampleIO(filename=None)
        bl = r.read_block(time_slices=None)
        real_segments = bl.segments
        assert len(real_segments) == 2

        time_slices = [(1, 3), (4, 5), (16, 21), (21.5, 22.)]
        bl = r.read_block(time_slices=time_slices)
        sliced_segments = bl.segments
        assert len(sliced_segments) == len(time_slices)

        with self.assertRaises(ValueError):
            buggy_time_slices = [(11, 14)]
            bl = r.read_block(time_slices=buggy_time_slices)
示例#6
0
    def test_read_segment_lazy(self):
        r = ExampleIO(filename=None)
        seg = r.read_segment(cascade=True, lazy=True)
        for ana in seg.analogsignals:
            self.assertEqual(ana.size, 0)
            assert hasattr(ana, 'lazy_shape')
        for st in seg.spiketrains:
            self.assertEqual(st.size, 0)
            assert hasattr(st, 'lazy_shape')

        seg = r.read_segment(cascade=True, lazy=False)
        for ana in seg.analogsignals:
            self.assertNotEqual(ana.size, 0)
        for st in seg.spiketrains:
            self.assertNotEqual(st.size, 0)
示例#7
0
 def test_read_block_with_time_slices(self):
     r = ExampleIO(filename=None)
     bl = r.read_block(time_slices=None)
     real_segments = bl.segments
     assert len(real_segments)==2
     
     
     time_slices = [(1, 3), (4, 5), (16, 21), (21.5, 22.)]
     bl = r.read_block(time_slices=time_slices)
     sliced_segments = bl.segments
     assert len(sliced_segments)==len(time_slices)
     
     with self.assertRaises(ValueError):
         buggy_time_slices = [(11, 14)]
         bl = r.read_block(time_slices=buggy_time_slices)
示例#8
0
    def test_read_segment_lazy(self):
        r = ExampleIO(filename=None)
        seg = r.read_segment(cascade=True, lazy=True)
        for ana in seg.analogsignals:
            self.assertEqual(ana.size, 0)
            assert hasattr(ana, 'lazy_shape')
        for st in seg.spiketrains:
            self.assertEqual(st.size, 0)
            assert hasattr(st, 'lazy_shape')

        seg = r.read_segment(cascade=True, lazy=False)
        for ana in seg.analogsignals:
            self.assertNotEqual(ana.size, 0)
        for st in seg.spiketrains:
            self.assertNotEqual(st.size, 0)
示例#9
0
    def test_read_segment_with_time_slice(self):
        r = ExampleIO(filename=None)
        seg = r.read_segment(time_slice=None)
        shape_full = seg.analogsignals[0].shape
        spikes_full = seg.spiketrains[0]
        event_full = seg.events[0]

        t_start, t_stop = 260 * pq.ms, 1.854 * pq.s
        seg = r.read_segment(time_slice=(t_start, t_stop))
        shape_slice = seg.analogsignals[0].shape
        spikes_slice = seg.spiketrains[0]
        event_slice = seg.events[0]

        assert shape_full[0] > shape_slice[0]

        assert spikes_full.size > spikes_slice.size
        assert np.all(spikes_slice >= t_start)
        assert np.all(spikes_slice <= t_stop)
        assert spikes_slice.t_start == t_start
        assert spikes_slice.t_stop == t_stop

        assert event_full.size > event_slice.size
        assert np.all(event_slice.times >= t_start)
        assert np.all(event_slice.times <= t_stop)
示例#10
0
    def test_read_segment_with_time_slice(self):
        r = ExampleIO(filename=None)
        seg = r.read_segment(time_slice=None)
        shape_full = seg.analogsignals[0].shape
        spikes_full = seg.spiketrains[0]
        event_full = seg.events[0]

        t_start, t_stop = 260 * pq.ms, 1.854 * pq.s
        seg = r.read_segment(time_slice=(t_start, t_stop))
        shape_slice = seg.analogsignals[0].shape
        spikes_slice = seg.spiketrains[0]
        event_slice = seg.events[0]

        assert shape_full[0] > shape_slice[0]

        assert spikes_full.size > spikes_slice.size
        assert np.all(spikes_slice >= t_start)
        assert np.all(spikes_slice <= t_stop)
        assert spikes_slice.t_start == t_start
        assert spikes_slice.t_stop == t_stop

        assert event_full.size > event_slice.size
        assert np.all(event_slice.times >= t_start)
        assert np.all(event_slice.times <= t_stop)
示例#11
0
 def test_read_block(self):
     r = ExampleIO(filename=None)
     bl = r.read_block(lazy=True)
示例#12
0
 def test_read_block(self):
     r = ExampleIO(filename=None)
     bl = r.read_block(lazy=True)
     assert len(bl.list_units) == 3
     assert len(bl.channel_indexes) == 1 + 3  # signals grouped + units
示例#13
0
 def test_read_analogsignal(self):
     r = ExampleIO(filename=None)
     r.read_analogsignal(lazy=False, segment_duration=15., t_start=-1)
示例#14
0
 def test_read_segment_cascade(self):
     r = ExampleIO(filename=None)
     seg = r.read_segment(cascade=False)
     self.assertEqual(len(seg.analogsignals), 0)
     seg = r.read_segment(cascade=True, num_analogsignal=4)
     self.assertEqual(len(seg.analogsignals), 4)
示例#15
0
 def test_read_block(self):
     r = ExampleIO(filename=None)
     bl = r.read_block(lazy=True)
     assert len(bl.list_units) == 3
     assert len(bl.channel_indexes) == 1 + 3  # signals grouped + units
示例#16
0
 def test_read_segment_cascade(self):
     r = ExampleIO(filename=None)
     seg = r.read_segment(cascade=False)
     self.assertEqual(len(seg.analogsignals), 0)
     seg = r.read_segment(cascade=True, num_analogsignal=4)
     self.assertEqual(len(seg.analogsignals), 4)
示例#17
0
 def test_read_analogsignal(self):
     r = ExampleIO(filename=None)
     r.read_analogsignal(lazy=False, segment_duration=15., t_start=-1)
示例#18
0
 def read_spiketrain(self):
     r = ExampleIO(filename=None)
     r.read_spiketrain(lazy=False,)
示例#19
0
 def read_spiketrain(self):
     r = ExampleIO(filename=None)
     r.read_spiketrain(lazy=False, )