Description
Originally from #62 Remove sampling_rate
from SpikeTrain
crodger wrote on 2011-09-28 01:15:59:
Actually it has not been clarified exactly what waveforms
should be yet. Let me propose this:
* `waveforms` is a list of AnalogSignalArray
* len(sptr.waveforms) = len(sptr)
* sptr.waveforms[n].shape = (N_channels, spike_duration_in_channels)
* sptr.waveforms[n].t_start = sptr[n] - left_sweep
* sptr.waveforms[n].sampling_rate = sampling_rate
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.