示例#1
0
    def test_remove_shared_channel_many_to_many(self):
        block = self.create_hierarchy(True)
        comp = self.create_hierarchy(True)
        self.assertEqual(
            len(block.list_recordingchannels),
            self.CHANNEL_GROUPS * (self.CHANNELS / 2) + (self.CHANNELS / 2))

        rc = block.list_recordingchannels[1]  # Shared channel
        tools.remove_from_hierarchy(rc)

        neo.test.tools.assert_same_sub_schema(rc,
                                              comp.list_recordingchannels[1])
        self.assertFalse(rc in block.list_recordingchannels)

        self.assertEqual(len(block.segments), self.SEGMENTS)
        self.assertEqual(len(block.recordingchannelgroups),
                         self.CHANNEL_GROUPS)
        self.assertEqual(
            len(block.list_recordingchannels),
            self.CHANNEL_GROUPS * (self.CHANNELS / 2) + (self.CHANNELS / 2) -
            1)

        # Should be removed from all channel groups
        for rcg in block.recordingchannelgroups:
            self.assertEqual(len(rcg.recordingchannels), self.CHANNELS - 1)
            self.assertEqual(rcg.channel_indexes.shape[0], self.CHANNELS - 1)
            self.assertEqual(rcg.channel_names.shape[0], self.CHANNELS - 1)
            self.assertFalse(rc.index in rcg.channel_indexes)
            self.assertFalse(rc.name in rcg.channel_names)
示例#2
0
    def test_remove_shared_channel_many_to_many(self):
        block = self.create_hierarchy(True)
        comp = self.create_hierarchy(True)
        self.assertEqual(
            len(block.list_recordingchannels),
            self.CHANNEL_GROUPS * (self.CHANNELS / 2) + (self.CHANNELS / 2))

        rc = block.list_recordingchannels[1]  # Shared channel
        tools.remove_from_hierarchy(rc)

        neo.test.tools.assert_same_sub_schema(rc,
                                              comp.list_recordingchannels[1])
        self.assertFalse(rc in block.list_recordingchannels)

        self.assertEqual(len(block.segments), self.SEGMENTS)
        self.assertEqual(len(block.recordingchannelgroups),
                         self.CHANNEL_GROUPS)
        self.assertEqual(
            len(block.list_recordingchannels),
            self.CHANNEL_GROUPS * (self.CHANNELS / 2) + (self.CHANNELS / 2) - 1)

        # Should be removed from all channel groups
        for rcg in block.recordingchannelgroups:
            self.assertEqual(len(rcg.recordingchannels), self.CHANNELS - 1)
            self.assertEqual(rcg.channel_indexes.shape[0], self.CHANNELS - 1)
            self.assertEqual(rcg.channel_names.shape[0], self.CHANNELS - 1)
            self.assertFalse(rc.index in rcg.channel_indexes)
            self.assertFalse(rc.name in rcg.channel_names)
示例#3
0
    def test_remove_segment_keep_orphans(self):
        block = self.create_hierarchy(False)
        comp = self.create_hierarchy(False)

        seg = block.segments[1]
        tools.remove_from_hierarchy(seg, False)

        self.assertFalse(seg in block.segments)
        self.assertEqual(len(block.list_units),
                         self.UNITS * self.CHANNEL_GROUPS)
        for u in block.list_units:
            self.assertEqual(len(u.spikes), self.SEGMENTS)
            self.assertEqual(len(u.spiketrains), self.SEGMENTS)
        neo.test.tools.assert_same_sub_schema(seg, comp.segments[1])
示例#4
0
    def test_remove_segment_keep_orphans(self):
        block = self.create_hierarchy(False)
        comp = self.create_hierarchy(False)

        seg = block.segments[1]
        tools.remove_from_hierarchy(seg, False)

        self.assertFalse(seg in block.segments)
        self.assertEqual(len(block.list_units),
                         self.UNITS * self.CHANNEL_GROUPS)
        for u in block.list_units:
            self.assertEqual(len(u.spikes), self.SEGMENTS)
            self.assertEqual(len(u.spiketrains), self.SEGMENTS)
        neo.test.tools.assert_same_sub_schema(seg, comp.segments[1])
示例#5
0
    def test_remove_channel_group_keep_orphans(self):
        block = self.create_hierarchy(False)
        comp = self.create_hierarchy(False)

        rcg = block.recordingchannelgroups[1]
        tools.remove_from_hierarchy(rcg, False)

        self.assertFalse(rcg in block.recordingchannelgroups)
        self.assertEqual(len(block.segments), self.SEGMENTS)
        for s in block.segments:
            self.assertEqual(len(s.spikes), self.UNITS * self.CHANNEL_GROUPS)
            self.assertEqual(len(s.spiketrains),
                             self.UNITS * self.CHANNEL_GROUPS)
        neo.test.tools.assert_same_sub_schema(rcg,
                                              comp.recordingchannelgroups[1])
示例#6
0
    def test_remove_channel_group_keep_orphans(self):
        block = self.create_hierarchy(False)
        comp = self.create_hierarchy(False)

        rcg = block.recordingchannelgroups[1]
        tools.remove_from_hierarchy(rcg, False)

        self.assertFalse(rcg in block.recordingchannelgroups)
        self.assertEqual(len(block.segments), self.SEGMENTS)
        for s in block.segments:
            self.assertEqual(len(s.spikes),
                             self.UNITS * self.CHANNEL_GROUPS)
            self.assertEqual(len(s.spiketrains),
                             self.UNITS * self.CHANNEL_GROUPS)
        neo.test.tools.assert_same_sub_schema(rcg,
                                              comp.recordingchannelgroups[1])
示例#7
0
    def test_remove_unit_keep_orphans(self):
        block = self.create_hierarchy(False)
        comp = self.create_hierarchy(False)

        unit = block.list_units[5]
        tools.remove_from_hierarchy(unit, False)

        self.assertFalse(unit in block.list_units)
        self.assertEqual(len(block.list_units),
                         self.UNITS * self.CHANNEL_GROUPS - 1)
        self.assertEqual(len(block.segments), self.SEGMENTS)
        self.assertEqual(len(block.recordingchannelgroups),
                         self.CHANNEL_GROUPS)
        for seg in block.segments:
            self.assertEqual(len(seg.spikes), self.UNITS * self.CHANNEL_GROUPS)
            self.assertEqual(len(seg.spiketrains),
                             self.UNITS * self.CHANNEL_GROUPS)
            self.assertFalse(unit in [s.unit for s in seg.spikes])
            self.assertFalse(unit in [st.unit for st in seg.spiketrains])
        neo.test.tools.assert_same_sub_schema(unit, comp.list_units[5])
示例#8
0
    def test_remove_spiketrain(self):
        unit = neo.Unit()
        segment = neo.Segment()

        s = neo.Spike(0 * pq.s)
        unit.spikes.append(s)
        segment.spikes.append(s)
        s.unit = unit
        s.segment = segment

        st = neo.SpikeTrain([] * pq.s, 0 * pq.s)
        unit.spiketrains.append(st)
        segment.spiketrains.append(st)
        st.unit = unit
        st.segment = segment

        tools.remove_from_hierarchy(st)
        self.assertTrue(s in unit.spikes)
        self.assertTrue(s in segment.spikes)
        self.assertFalse(st in unit.spiketrains)
        self.assertFalse(st in segment.spiketrains)
示例#9
0
    def test_remove_spiketrain(self):
        unit = neo.Unit()
        segment = neo.Segment()

        s = neo.Spike(0 * pq.s)
        unit.spikes.append(s)
        segment.spikes.append(s)
        s.unit = unit
        s.segment = segment

        st = neo.SpikeTrain([] * pq.s, 0 * pq.s)
        unit.spiketrains.append(st)
        segment.spiketrains.append(st)
        st.unit = unit
        st.segment = segment

        tools.remove_from_hierarchy(st)
        self.assertTrue(s in unit.spikes)
        self.assertTrue(s in segment.spikes)
        self.assertFalse(st in unit.spiketrains)
        self.assertFalse(st in segment.spiketrains)
示例#10
0
    def test_remove_unit_keep_orphans(self):
        block = self.create_hierarchy(False)
        comp = self.create_hierarchy(False)

        unit = block.list_units[5]
        tools.remove_from_hierarchy(unit, False)

        self.assertFalse(unit in block.list_units)
        self.assertEqual(len(block.list_units),
                         self.UNITS * self.CHANNEL_GROUPS - 1)
        self.assertEqual(len(block.segments), self.SEGMENTS)
        self.assertEqual(len(block.recordingchannelgroups),
                         self.CHANNEL_GROUPS)
        for seg in block.segments:
            self.assertEqual(len(seg.spikes),
                             self.UNITS * self.CHANNEL_GROUPS)
            self.assertEqual(len(seg.spiketrains),
                             self.UNITS * self.CHANNEL_GROUPS)
            self.assertFalse(unit in [s.unit for s in seg.spikes])
            self.assertFalse(unit in [st.unit for st in seg.spiketrains])
        neo.test.tools.assert_same_sub_schema(unit, comp.list_units[5])
示例#11
0
    def test_remove_channel(self):
        block = self.create_hierarchy(False)
        comp = self.create_hierarchy(False)

        rc = block.list_recordingchannels[5]
        tools.remove_from_hierarchy(rc)
        self.assertFalse(rc in block.list_recordingchannels)
        neo.test.tools.assert_same_sub_schema(rc,
                                              comp.list_recordingchannels[5])

        self.assertEqual(len(block.segments), self.SEGMENTS)
        self.assertEqual(len(block.recordingchannelgroups),
                         self.CHANNEL_GROUPS)
        self.assertEqual(len(block.list_recordingchannels),
                         self.CHANNEL_GROUPS * self.CHANNELS - 1)

        # Should be removed from its own channel group
        rcg = rc.recordingchannelgroups[0]
        self.assertEqual(len(rcg.recordingchannels), self.CHANNELS - 1)
        self.assertEqual(rcg.channel_indexes.shape[0], self.CHANNELS - 1)
        self.assertEqual(rcg.channel_names.shape[0], self.CHANNELS - 1)
        self.assertFalse(rc.index in rcg.channel_indexes)
        self.assertFalse(rc.name in rcg.channel_names)
示例#12
0
    def test_remove_channel(self):
        block = self.create_hierarchy(False)
        comp = self.create_hierarchy(False)

        rc = block.list_recordingchannels[5]
        tools.remove_from_hierarchy(rc)
        self.assertFalse(rc in block.list_recordingchannels)
        neo.test.tools.assert_same_sub_schema(rc,
                                              comp.list_recordingchannels[5])

        self.assertEqual(len(block.segments), self.SEGMENTS)
        self.assertEqual(len(block.recordingchannelgroups),
                         self.CHANNEL_GROUPS)
        self.assertEqual(len(block.list_recordingchannels),
                         self.CHANNEL_GROUPS * self.CHANNELS - 1)

        # Should be removed from its own channel group
        rcg = rc.recordingchannelgroups[0]
        self.assertEqual(len(rcg.recordingchannels), self.CHANNELS - 1)
        self.assertEqual(rcg.channel_indexes.shape[0], self.CHANNELS - 1)
        self.assertEqual(rcg.channel_names.shape[0], self.CHANNELS - 1)
        self.assertFalse(rc.index in rcg.channel_indexes)
        self.assertFalse(rc.name in rcg.channel_names)
示例#13
0
    def test_remove_block(self):
        block = self.create_hierarchy(False)
        comp = self.create_hierarchy(False)
        tools.remove_from_hierarchy(block)

        neo.test.tools.assert_same_sub_schema(block, comp)
示例#14
0
    def test_remove_block(self):
        block = self.create_hierarchy(False)
        comp = self.create_hierarchy(False)
        tools.remove_from_hierarchy(block)

        neo.test.tools.assert_same_sub_schema(block, comp)