Пример #1
0
def test_neo_object_sources():

    from neo.test.generate_datasets import generate_one_simple_segment
    import neo

    neo_seg = generate_one_simple_segment(supported_objects=[
        neo.Segment, neo.AnalogSignal, neo.Event, neo.Epoch, neo.SpikeTrain
    ])

    sources = ephyviewer.get_sources_from_neo_segment(neo_seg)

    for s in sources['signal']:
        print(s.t_start, s.nb_channel, s.sample_rate)
        print(s.get_chunk(i_start=0, i_stop=1024).shape)

    for s in sources['epoch']:
        print(s.t_start, s.nb_channel)
        print(s.get_chunk_by_time(chan=0, t_start=0, t_stop=10.))

    for s in sources['event']:
        print(s.t_start, s.nb_channel)
        print(s.get_chunk_by_time(chan=0, t_start=0, t_stop=10.))

    for s in sources['spike']:
        print(s.t_start, s.nb_channel)
        print(s.get_chunk_by_time(chan=0, t_start=0., t_stop=10.))
    def test_defaults(self):
        res = generate_one_simple_segment()

        self.assertTrue(isinstance(res, Segment))
        assert_neo_object_is_compliant(res)

        self.assertEqual(len(res.analogsignals), 0)
        self.assertEqual(len(res.irregularlysampledsignals), 0)
        self.assertEqual(len(res.spiketrains), 0)
        self.assertEqual(len(res.events), 0)
        self.assertEqual(len(res.epochs), 0)
Пример #3
0
    def test_defaults(self):
        res = generate_one_simple_segment()

        self.assertTrue(isinstance(res, Segment))
        assert_neo_object_is_compliant(res)

        self.assertEqual(len(res.analogsignals), 0)
        self.assertEqual(len(res.irregularlysampledsignals), 0)
        self.assertEqual(len(res.spiketrains), 0)
        self.assertEqual(len(res.events), 0)
        self.assertEqual(len(res.epochs), 0)
    def test_half_supported(self):
        objects = [Segment, IrregularlySampledSignal, SpikeTrain, Epoch]

        res = generate_one_simple_segment(supported_objects=objects)

        self.assertTrue(isinstance(res, Segment))
        assert_neo_object_is_compliant(res)

        self.assertEqual(len(res.analogsignals), 0)
        self.assertEqual(len(res.irregularlysampledsignals), 0)
        self.assertEqual(len(res.spiketrains), 6)
        self.assertEqual(len(res.events), 0)
        self.assertEqual(len(res.epochs), 2)
Пример #5
0
    def test_half_supported(self):
        objects = [Segment, IrregularlySampledSignal, SpikeTrain, Epoch]

        res = generate_one_simple_segment(supported_objects=objects)

        self.assertTrue(isinstance(res, Segment))
        assert_neo_object_is_compliant(res)

        self.assertEqual(len(res.analogsignals), 0)
        self.assertEqual(len(res.irregularlysampledsignals), 0)
        self.assertEqual(len(res.spiketrains), 6)
        self.assertEqual(len(res.events), 0)
        self.assertEqual(len(res.epochs), 2)
Пример #6
0
    def test_all_without_block(self):
        objects = [Segment, ChannelIndex, Unit, AnalogSignal, IrregularlySampledSignal, SpikeTrain,
                   Event, Epoch]

        res = generate_one_simple_segment(supported_objects=objects)

        self.assertTrue(isinstance(res, Segment))
        assert_neo_object_is_compliant(res)

        self.assertEqual(len(res.analogsignals), 4)
        self.assertEqual(len(res.irregularlysampledsignals), 0)
        self.assertEqual(len(res.spiketrains), 6)
        self.assertEqual(len(res.events), 3)
        self.assertEqual(len(res.epochs), 2)
Пример #7
0
    def test_all_without_block(self):
        objects = [Segment, ChannelIndex, Unit, AnalogSignal, IrregularlySampledSignal, SpikeTrain,
                   Event, Epoch]

        res = generate_one_simple_segment(supported_objects=objects)

        self.assertTrue(isinstance(res, Segment))
        assert_neo_object_is_compliant(res)

        self.assertEqual(len(res.analogsignals), 4)
        self.assertEqual(len(res.irregularlysampledsignals), 0)
        self.assertEqual(len(res.spiketrains), 6)
        self.assertEqual(len(res.events), 3)
        self.assertEqual(len(res.epochs), 2)
    def test_all_supported(self):
        objects = [Block, Segment,
                   RecordingChannelGroup, RecordingChannel, Unit,
                   AnalogSignal, AnalogSignalArray,
                   IrregularlySampledSignal, SpikeTrain,
                   Event, Epoch, Spike,
                   EventArray, EpochArray]

        res = generate_one_simple_segment(supported_objects=objects)

        self.assertTrue(isinstance(res, Segment))
        assert_neo_object_is_compliant(res)

        self.assertEqual(len(res.analogsignals), 4)
        self.assertEqual(len(res.analogsignalarrays), 0)
        self.assertEqual(len(res.irregularlysampledsignals), 0)
        self.assertEqual(len(res.spiketrains), 6)
        self.assertEqual(len(res.spikes), 0)
        self.assertEqual(len(res.events), 0)
        self.assertEqual(len(res.epochs), 0)
        self.assertEqual(len(res.eventarrays), 3)
        self.assertEqual(len(res.epocharrays), 2)
Пример #9
0
There are two approaches:
   * create each viewer with class method (TraceViewer.from_neo_analogsignal, ...)
   * magically create all sources by providing the neo.Segment

"""
from ephyviewer import mkQApp, MainViewer, TraceViewer, SpikeTrainViewer, EpochViewer, EventList
from ephyviewer import get_sources_from_neo_segment, compose_mainviewer_from_sources
import numpy as np

from neo.test.generate_datasets import generate_one_simple_segment
import neo

# here we generate a segment with several objects
# (this is a bad example because it mimics old neo behavior for signals (one channel=one object))
neo_seg = generate_one_simple_segment(supported_objects=[
    neo.Segment, neo.AnalogSignal, neo.Event, neo.Epoch, neo.SpikeTrain
])

# the global QT app
app = mkQApp()

##############################
# case 1 : create viewers one at a time directly from neo objects in memory
win = MainViewer(show_auto_scale=True)

# from one neo.AnalogSignal
view1 = TraceViewer.from_neo_analogsignal(neo_seg.analogsignals[0], 'sigs')
win.add_view(view1)

# from several neo.SpikeTrains (3 spiketrains here)
view2 = SpikeTrainViewer.from_neo_spiketrains(neo_seg.spiketrains[0:3],