def test_gap_warning(self):
        nio = NeuralynxIO(self.sn, use_cache='never')

        with reset_warning_registry():
            with warnings.catch_warnings(record=True) as w:
                warnings.simplefilter('always')
                nio.read_block(t_starts=None, t_stops=None)

                self.assertGreater(len(w), 0)
                self.assertTrue(issubclass(w[0].category, UserWarning))
                self.assertEqual('Substituted t_starts and t_stops in order to'
                                 ' skip gap in recording session.',
                                 str(w[0].message))
示例#2
0
    def test_gap_warning(self):
        nio = NeuralynxIO(self.sn, use_cache='never')

        with reset_warning_registry():
            with warnings.catch_warnings(record=True) as w:
                warnings.simplefilter('always')
                nio.read_block(t_starts=None, t_stops=None)

                self.assertGreater(len(w), 0)
                self.assertTrue(issubclass(w[0].category, UserWarning))
                self.assertEqual('Substituted t_starts and t_stops in order to'
                                 ' skip gap in recording session.',
                                 str(w[0].message))
    def test_read_block(self):
        """Read data in a certain time range into one block"""
        t_start, t_stop = 3 * pq.s, 4 * pq.s

        nio = NeuralynxIO(self.sn, use_cache='never')
        block = nio.read_block(t_starts=[t_start], t_stops=[t_stop])
        self.assertEqual(len(nio.parameters_ncs), 5)
        self.assertTrue({
            'event_id': 19,
            'name': 'Starting Recording',
            'nttl': 0
        } in nio.parameters_nev['Events.nev']['event_types'])
        self.assertTrue({
            'event_id': 19,
            'name': 'Stopping Recording',
            'nttl': 0
        } in nio.parameters_nev['Events.nev']['event_types'])

        # Everything put in one segment
        self.assertEqual(len(block.segments), 1)
        seg = block.segments[0]
        self.assertEqual(len(seg.analogsignals), 1)
        self.assertEqual(seg.analogsignals[0].shape[-1], 5)

        self.assertEqual(seg.analogsignals[0].sampling_rate.units,
                         pq.CompoundUnit('32*kHz'))
        self.assertAlmostEqual(seg.analogsignals[0].t_start, t_start, places=4)
        self.assertAlmostEqual(seg.analogsignals[0].t_stop, t_stop, places=4)
        self.assertEqual(len(seg.spiketrains), 0)  # no nse files available

        # Testing different parameter combinations
        block = nio.read_block(lazy=True)
        self.assertEqual(len(block.segments[0].analogsignals[0]), 0)

        block = nio.read_block(cascade=False)
        self.assertEqual(len(block.segments), 0)

        block = nio.read_block(electrode_list=[0])
        self.assertEqual(len(block.segments[0].analogsignals), 1)

        block = nio.read_block(t_starts=None,
                               t_stops=None,
                               events=True,
                               waveforms=True)
        self.assertEqual(len(block.segments[0].analogsignals), 1)
        self.assertEqual(len(block.segments[0].spiketrains), 0)
        self.assertGreater(len(block.segments[0].events), 0)
        self.assertEqual(len(block.channel_indexes), 5)
示例#4
0
    def test_read_block(self):
        """Read data in a certain time range into one block"""
        t_start, t_stop = 3 * pq.s, 4 * pq.s

        nio = NeuralynxIO(self.sn, use_cache='never')
        block = nio.read_block(t_starts=[t_start], t_stops=[t_stop])
        self.assertEqual(len(nio.parameters_ncs), 5)
        self.assertTrue(
                {'event_id': 19, 'name': 'Starting Recording', 'nttl': 0} in
                nio.parameters_nev['Events.nev']['event_types'])
        self.assertTrue(
                {'event_id': 19, 'name': 'Stopping Recording', 'nttl': 0} in
                nio.parameters_nev['Events.nev']['event_types'])

        # Everything put in one segment
        self.assertEqual(len(block.segments), 1)
        seg = block.segments[0]
        self.assertEqual(len(seg.analogsignals), 1)
        self.assertEqual(seg.analogsignals[0].shape[-1], 5)

        self.assertEqual(seg.analogsignals[0].sampling_rate.units,
                         pq.CompoundUnit('32*kHz'))
        self.assertAlmostEqual(seg.analogsignals[0].t_start, t_start, places=4)
        self.assertAlmostEqual(seg.analogsignals[0].t_stop, t_stop, places=4)
        self.assertEqual(len(seg.spiketrains), 0)  # no nse files available

        # Testing different parameter combinations
        block = nio.read_block(lazy=True)
        self.assertEqual(len(block.segments[0].analogsignals[0]), 0)

        block = nio.read_block(cascade=False)
        self.assertEqual(len(block.segments), 0)

        block = nio.read_block(electrode_list=[0])
        self.assertEqual(len(block.segments[0].analogsignals), 1)

        block = nio.read_block(t_starts=None, t_stops=None, events=True,
                               waveforms=True)
        self.assertEqual(len(block.segments[0].analogsignals), 1)
        self.assertEqual(len(block.segments[0].spiketrains), 0)
        self.assertGreater(len(block.segments[0].events), 0)
        self.assertEqual(len(block.channel_indexes), 5)
    def test_gap_handling(self):
        nio = NeuralynxIO(self.sn, use_cache='never')

        block = nio.read_block(t_starts=None, t_stops=None)

        # known gap values
        n_gaps = 1

        self.assertEqual(len(block.segments), n_gaps + 1)
        # one channel index for analogsignals for each of the 3 segments and
        # one for spiketrains
        self.assertEqual(len(block.channel_indexes), len(block.segments) + 1)
        self.assertEqual(len(block.channel_indexes[-1].units), 2)
        for unit in block.channel_indexes[-1].units:
            self.assertEqual(len(unit.spiketrains), n_gaps + 1)

        anasig_channels = [i for i in block.channel_indexes
                           if 'analogsignal' in i.name]
        self.assertEqual(len(anasig_channels), n_gaps + 1)
示例#6
0
    def test_gap_handling(self):
        nio = NeuralynxIO(self.sn, use_cache='never')

        block = nio.read_block(t_starts=None, t_stops=None)

        # known gap values
        n_gaps = 1

        self.assertEqual(len(block.segments), n_gaps + 1)
        # one channel index for analogsignals for each of the 3 segments and
        # one for spiketrains
        self.assertEqual(len(block.channel_indexes), len(block.segments) + 1)
        self.assertEqual(len(block.channel_indexes[-1].units), 2)
        for unit in block.channel_indexes[-1].units:
            self.assertEqual(len(unit.spiketrains), n_gaps + 1)

        anasig_channels = [i for i in block.channel_indexes
                           if 'analogsignal' in i.name]
        self.assertEqual(len(anasig_channels), n_gaps + 1)