Closed Christian-B closed 2 years ago
A much UGLIER and I hope temporary hack we have had to do is segment = neo.Segment(... segment.spiketrains = []
if anyone know of a better fix either permanent or even temporary I am open to better suggestions.
Correction: A much better fix in Plotting is to replace the line https://github.com/NeuralEnsemble/PyNN/blob/435adeda83e4b082a61acbb24953263aca52837f/pyNN/utility/plotting.py#L257
elif isinstance(datum, list) and len(datum) > 0 and isinstance(datum[0], SpikeTrain):
with
elif isinstance(datum, SpikeTrainList) and len(datum) > 0 and isinstance(datum[0], SpikeTrain):
again with from neo.core.spiketrainlist import SpikeTrainList
In previous neo versions segment.spiketrains was a list of Spiketrain objects Now segment.spiketrains is a SpikeTrainsList
The SpikeTrainsList implements the list functions so all should work the same
The one exception is in plotting. https://github.com/NeuralEnsemble/PyNN/blob/master/pyNN/utility/plotting.py
The panel init https://github.com/NeuralEnsemble/PyNN/blob/435adeda83e4b082a61acbb24953263aca52837f/pyNN/utility/plotting.py#L239 has an args/star variable *data so is passed in a tuple
Therefor the line self.data = list(data) results in self.data being a list of SpikeTrainsList objects and not as expected a list of SpikeTrain Objects
The Plot method can not handle Objects of type SpikeTrainList
An ugly but working fix is to replace in Panel.init
self.data = list(data[0])
with
if len(data) == 0 and isinstance(data[0], SpikeTrainList): self.data = list(data[0]) else: self.data = list(data)
(needs an import of SpikeTrainList of course)