Open mdenker opened 9 years ago
bug (error) found. To get 'l.analogsignals', parameter channel_indexes must be given when creating instance of Unit. unit = Unit(name='Unit #%s' % ind, channel_indexes=ind)
Subsequently, there are some lines in file segment.py must be replaced by using function append, not extend. Otherwise, I got error 'int object is not iterable'
error is still there. seg0.analogsignals return correct list but seg1 = seg0.construct_subsegment_by_unit(unit_list=[k]) seg1.analogsignals still return empty list
Following code will return list of analogsignals (not empty). Some lines in segments.py must be changed.
from neo.core import (Segment, Block, Unit, SpikeTrain,
RecordingChannelGroup, AnalogSignal)
import quantities as pq
blk = Block()
rcg = RecordingChannelGroup(name='group0')
blk.recordingchannelgroups = [rcg]
for ind in range(5):
unit = Unit(name='Unit #%s' % ind, channel_indexes=ind)
rcg.units.append(unit)
for ind in range(3):
seg = Segment(name='Simulation #%s' % ind)
blk.segments.append(seg)
for unit in rcg.units:
train = SpikeTrain([1, 2, 3], units='ms', t_start=0.,
t_stop=10)
train.unit = unit
unit.spiketrains.append(train)
seg.spiketrains.append(train)
ana = AnalogSignal(signal=[.01, 3.3, 9.3], units='uV',
sampling_rate=1*pq.Hz, channel_index=1)
seg.analogsignals.append(ana)
seg0 = blk.segments[-1]
unit_list = rcg.units[:2]
print "---------------------------------------------------"
seg1 = seg0.construct_subsegment_by_unit(unit_list)
print "Len seg0 spiketrains = ", len(seg0.spiketrains)
print "len seg0 analogsignals = ", len(seg0.analogsignals)
print "----> seg0.analogsignals = ", seg0.analogsignals
print "seg0.analogsignals[0] = ", seg0.analogsignals[0]
print
print "Len seg1 spiketrains = ", len(seg1.spiketrains)
print "Len seg1 analogsignals = ", len(seg1.analogsignals)
print "----> seg1.analogsignals = ", seg1.analogsignals
print "seg1.analogsignals[1] = ", seg1.analogsignals[1]
AnalogSignals are not carried over.