You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think we should remove the sampling_rate attribute from SpikeTrain.
As a SpikeTrain is a list of spike times with, in theory, arbitrary precision, sampling_rate is not necessary for the object to function. If anything, it is metadata, and so could be put in annotations, if it is too cumbersome to navigate to the associated AnalogSignal via a Unit. For simulations in particular, there may not even be a fixed sampling period (e.g. with adaptive time step methods).
Imported from Trac ticket:29
Opened: 2011-09-26 09:53:09 Last modified: 2012-02-01 11:10:59 Component: core Priority: minor Owner: somebody Reporter: apdavison
I think the bundle waveform+left_sweep+sampling_rate is really important for spike sorting.
Many studies do not record AnalogSignal because it is is too big. So only waveform for each spike is reacorded. In that case sampling_rate of this waveform is important otherwise you can't reconstruct the story.
Many IOs render waveform of spikes. sampling_arte is related to waveform and not times of spikes!
I really vote for keeping this attributes in recommended otherwise it make no sens to keep left_sweep and waveforms.
But waveforms is an AnalogSignalArray or a list of AnalogSignal objects, no? And these already have their own sampling_rate attribute, so why repeat the attribute on the SpikeTrain?
Then we do not need sampling rate or left sweep in sptr. It makes sense because these are properties of the waveforms, not the spike times. We also allow flexibility: each spike can be sliced differently.
Also, since t_start and sampling_rate are required (or highly recommended) for AnalogSignalArray, we will have to specify these attributes for each entry in sptr.waveforms anyway.
We can even define a property of SpikeTrain for left_sweep and sampling rate.
@property
def left_sweep(self):
x = np.unique([self - wf.t_start for wf in self.waveforms])
if len(x) == 1:
return x[0]
else:
raise ValueError("sampling rates are not consistent")
If the user knows that left_sweep should be consistent, this property confirms it. If left_sweep is not supposed to be consistent, the user should not be accessing the property anyway, so it appropriate to raise an exception. We can add another property without error checking if desired.
Actually it will need to be slightly more complicated because these values are floats, but you get the idea.
Sam, waveforms should be 3d Quantity, correct? We should update documentation in spiketrain to specify this and also the order of the dimensions. I can do it, but first I want to find out if it is Quantity or Array.
As Samuel, I think it's really better to keep this data in a 3D array because you often want to get the mean over the different spikes of all the waveform. If the data are in separate AnalogSignals computing this mean would be very inefficient.
I agree with having the data in a 3D array, but then sampling_rate should be an attribute of that array, not of the SpikeTrain. I suggest allowing AnalogSignalArrays to be 3D.
I think making waveforms an AnalogSignalArray would needlessly complicate the code, and break the separation we have been data objects and container objects. So I support closing this as "WontFix".
Activity
apdavison commentedon Dec 16, 2013
sgarcia wrote on 2011-09-26 17:42:55:
I think the bundle waveform+left_sweep+sampling_rate is really important for spike sorting.
Many studies do not record AnalogSignal because it is is too big. So only waveform for each spike is reacorded. In that case sampling_rate of this waveform is important otherwise you can't reconstruct the story.
Many IOs render waveform of spikes. sampling_arte is related to waveform and not times of spikes!
I really vote for keeping this attributes in recommended otherwise it make no sens to keep left_sweep and waveforms.
apdavison commentedon Dec 16, 2013
apdavison wrote on 2011-09-26 18:00:28:
But
waveformsis anAnalogSignalArrayor a list ofAnalogSignalobjects, no? And these already have their ownsampling_rateattribute, so why repeat the attribute on theSpikeTrain?apdavison commentedon Dec 16, 2013
crodger wrote on 2011-09-28 01:15:59:
Actually it has not been clarified exactly what
waveformsshould be yet. Let me propose this:waveformsis a list of AnalogSignalArraylen(sptr.waveforms) = len(sptr)sptr.waveforms[n].shape = (N_channels, spike_duration_in_channels)sptr.waveforms[n].t_start = sptr[n] - left_sweepsptr.waveforms[n].sampling_rate = sampling_rateThen we do not need sampling rate or left sweep in
sptr. It makes sense because these are properties of the waveforms, not the spike times. We also allow flexibility: each spike can be sliced differently.Also, since
t_startandsampling_rateare required (or highly recommended) forAnalogSignalArray, we will have to specify these attributes for each entry insptr.waveformsanyway.We can even define a property of
SpikeTrainfor left_sweep and sampling rate.If the user knows that left_sweep should be consistent, this property confirms it. If left_sweep is not supposed to be consistent, the user should not be accessing the property anyway, so it appropriate to raise an exception. We can add another property without error checking if desired.
Actually it will need to be slightly more complicated because these values are floats, but you get the idea.
apdavison commentedon Dec 16, 2013
sgarcia wrote on 2011-10-03 17:47:14:
Andrew, actually waveforms is 3D : n_spike X channel_index X time.
We need this to cover all spikesorting cases.
So a list of AnalogSignalArray could make sens, like proposed by Chris.
But I am not really happy to make this big change now:
I propose to post pone this ticket to neo3.
apdavison commentedon Dec 16, 2013
crodger wrote on 2011-10-04 22:27:50:
Sam, waveforms should be 3d Quantity, correct? We should update documentation in spiketrain to specify this and also the order of the dimensions. I can do it, but first I want to find out if it is Quantity or Array.
apdavison commentedon Dec 16, 2013
sgarcia wrote on 2011-11-02 17:44:35:
Yes. In description, I put Quantity.
apdavison commentedon Dec 16, 2013
jaillet wrote on 2012-02-01 10:51:37:
As Samuel, I think it's really better to keep this data in a 3D array because you often want to get the mean over the different spikes of all the waveform. If the data are in separate AnalogSignals computing this mean would be very inefficient.
apdavison commentedon Dec 16, 2013
jaillet wrote on 2012-02-01 11:05:23:
And I also agree with other Samuel's points.
apdavison commentedon Dec 16, 2013
apdavison wrote on 2012-02-01 11:10:59:
I agree with having the data in a 3D array, but then
sampling_rateshould be an attribute of that array, not of theSpikeTrain. I suggest allowing AnalogSignalArrays to be 3D.In any case, let's postpone this to neo 0.3.
toddrjen commentedon Dec 16, 2013
I think making waveforms an AnalogSignalArray would needlessly complicate the code, and break the separation we have been data objects and container objects. So I support closing this as "WontFix".
samuelgarcia commentedon Dec 16, 2013
Agre for actual neo.
maybe consider it again for neo 0.4 when AnalogSignal and AnalogSignalArray would merge.
toddrjen commentedon Dec 17, 2013
I have split the part about using AnalogSignalArray for waveform as a separate issue, #105 . Please continue the discussion there.