本文整理汇总了Python中neo.core.SpikeTrain.unit方法的典型用法代码示例。如果您正苦于以下问题:Python SpikeTrain.unit方法的具体用法?Python SpikeTrain.unit怎么用?Python SpikeTrain.unit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类neo.core.SpikeTrain
的用法示例。
在下文中一共展示了SpikeTrain.unit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test__construct_subsegment_by_unit
# 需要导入模块: from neo.core import SpikeTrain [as 别名]
# 或者: from neo.core.SpikeTrain import unit [as 别名]
def test__construct_subsegment_by_unit(self):
nb_seg = 3
nb_unit = 7
unit_with_sig = [0, 2, 5]
signal_types = ['Vm', 'Conductances']
sig_len = 100
#recordingchannelgroups
rcgs = [ RecordingChannelGroup(name = 'Vm', channel_indexes = unit_with_sig),
RecordingChannelGroup(name = 'Conductance', channel_indexes = unit_with_sig), ]
# Unit
all_unit = [ ]
for u in range(nb_unit):
un = Unit(name = 'Unit #%d' % u, channel_indexes = [u])
all_unit.append(un)
bl = Block()
for s in range(nb_seg):
seg = Segment(name = 'Simulation %s' % s)
for j in range(nb_unit):
st = SpikeTrain([1, 2, 3], units = 'ms', t_start = 0., t_stop = 10)
st.unit = all_unit[j]
for t in signal_types:
anasigarr = AnalogSignalArray( np.zeros((sig_len, len(unit_with_sig)) ), units = 'nA',
sampling_rate = 1000.*pq.Hz, channel_indexes = unit_with_sig )
seg.analogsignalarrays.append(anasigarr)
# what you want
subseg = seg.construct_subsegment_by_unit(all_unit[:4])
示例2: test__construct_subsegment_by_unit
# 需要导入模块: from neo.core import SpikeTrain [as 别名]
# 或者: from neo.core.SpikeTrain import unit [as 别名]
def test__construct_subsegment_by_unit(self):
nb_seg = 3
nb_unit = 7
unit_with_sig = np.array([0, 2, 5])
signal_types = ['Vm', 'Conductances']
sig_len = 100
# channelindexes
chxs = [ChannelIndex(name='Vm',
index=unit_with_sig),
ChannelIndex(name='Conductance',
index=unit_with_sig)]
# Unit
all_unit = []
for u in range(nb_unit):
un = Unit(name='Unit #%d' % u, channel_indexes=np.array([u]))
assert_neo_object_is_compliant(un)
all_unit.append(un)
blk = Block()
blk.channel_indexes = chxs
for s in range(nb_seg):
seg = Segment(name='Simulation %s' % s)
for j in range(nb_unit):
st = SpikeTrain([1, 2], units='ms',
t_start=0., t_stop=10)
st.unit = all_unit[j]
for t in signal_types:
anasigarr = AnalogSignal(np.zeros((sig_len,
len(unit_with_sig))),
units='nA',
sampling_rate=1000.*pq.Hz,
channel_indexes=unit_with_sig)
seg.analogsignals.append(anasigarr)
blk.create_many_to_one_relationship()
for unit in all_unit:
assert_neo_object_is_compliant(unit)
for chx in chxs:
assert_neo_object_is_compliant(chx)
assert_neo_object_is_compliant(blk)
# what you want
newseg = seg.construct_subsegment_by_unit(all_unit[:4])
assert_neo_object_is_compliant(newseg)
示例3: test__issue_285
# 需要导入模块: from neo.core import SpikeTrain [as 别名]
# 或者: from neo.core.SpikeTrain import unit [as 别名]
def test__issue_285(self):
##Spiketrain
train = SpikeTrain([3, 4, 5] * pq.s, t_stop=10.0)
unit = Unit()
train.unit = unit
unit.spiketrains.append(train)
epoch = Epoch([0, 10, 20], [2, 2, 2], ["a", "b", "c"], units="ms")
blk = Block()
seg = Segment()
seg.spiketrains.append(train)
seg.epochs.append(epoch)
epoch.segment = seg
blk.segments.append(seg)
reader = PickleIO(filename="blk.pkl")
reader.write(blk)
reader = PickleIO(filename="blk.pkl")
r_blk = reader.read_block()
r_seg = r_blk.segments[0]
self.assertIsInstance(r_seg.spiketrains[0].unit, Unit)
self.assertIsInstance(r_seg.epochs[0], Epoch)
os.remove('blk.pkl')
##Epoch
train = Epoch(times=np.arange(0, 30, 10)*pq.s,durations=[10, 5, 7]*pq.ms,labels=np.array(['btn0', 'btn1', 'btn2'], dtype='S'))
train.segment = Segment()
unit = Unit()
unit.spiketrains.append(train)
blk = Block()
seg = Segment()
seg.spiketrains.append(train)
blk.segments.append(seg)
reader = PickleIO(filename="blk.pkl")
reader.write(blk)
reader = PickleIO(filename="blk.pkl")
r_blk = reader.read_block()
r_seg = r_blk.segments[0]
self.assertIsInstance(r_seg.spiketrains[0].segment, Segment)
os.remove('blk.pkl')
##Event
train = Event(np.arange(0, 30, 10)*pq.s,labels=np.array(['trig0', 'trig1', 'trig2'],dtype='S'))
train.segment = Segment()
unit = Unit()
unit.spiketrains.append(train)
blk = Block()
seg = Segment()
seg.spiketrains.append(train)
blk.segments.append(seg)
reader = PickleIO(filename="blk.pkl")
reader.write(blk)
reader = PickleIO(filename="blk.pkl")
r_blk = reader.read_block()
r_seg = r_blk.segments[0]
self.assertIsInstance(r_seg.spiketrains[0].segment, Segment)
os.remove('blk.pkl')
##IrregularlySampledSignal
train = IrregularlySampledSignal([0.0, 1.23, 6.78], [1, 2, 3],units='mV', time_units='ms')
train.segment = Segment()
unit = Unit()
train.channel_index = ChannelIndex(1)
unit.spiketrains.append(train)
blk = Block()
seg = Segment()
seg.spiketrains.append(train)
blk.segments.append(seg)
blk.segments[0].block = blk
reader = PickleIO(filename="blk.pkl")
reader.write(blk)
reader = PickleIO(filename="blk.pkl")
r_blk = reader.read_block()
r_seg = r_blk.segments[0]
self.assertIsInstance(r_seg.spiketrains[0].segment, Segment)
self.assertIsInstance(r_seg.spiketrains[0].channel_index, ChannelIndex)
os.remove('blk.pkl')