SpikeTrain waveform as AnalogSignalArray
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.
Is this idea still up to date? Looking at the current order of dimensions in the AnalogSignal, the proposed change would also imply a reordering of dimensions for the spiketrain waveforms from (n_spike X channel_index X time) [see Issue #62] to (time X channel_id X n_spike). This would imply not only changes for all the IOs, but basically at any point where waveforms are used.
See issue #343
There seemed to be a strong feeling in #62 that waveforms should be a 3D array for efficiency reasons. However, I still feel that many attributes that should belong to waveforms have been added to SpikeTrain, and I think we should clean this up before releasing Neo 1.0.
We have been considering adding support in Neo for optical imaging signals (e.g. calcium imaging). This would require an image-sequence class based on a 3D array. Perhaps we could have a base 3D array class, then subclass for image sequence and for waveforms.
In each case, the first dimension should be time, for consistency with AnalogSignal.