Skip to content

Remove sampling_rate from SpikeTrain #62

Closed

Description

@apdavison

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

Activity

  1. apdavison commented on Dec 16, 2013

    @apdavison
    MemberAuthor

    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.

  2. apdavison commented on Dec 16, 2013

    @apdavison
    MemberAuthor

    apdavison wrote on 2011-09-26 18:00:28:

    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?

  3. apdavison commented on Dec 16, 2013

    @apdavison
    MemberAuthor

    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.

  4. apdavison commented on Dec 16, 2013

    @apdavison
    MemberAuthor

    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:

    • If SpikeTrains.waveforms is now a list of AnalogSignalArray it is basically a new on_to_many relationship that put the confusion a very high level.
    • It is a lot of changes for IOs.
    • I really prefer a 3D arrays for efficiency reasons.
    • I promise Andrey no more change in neo2 schema. They can't support fast change in neo at G-Node. I understand them.

    I propose to post pone this ticket to neo3.

  5. apdavison commented on Dec 16, 2013

    @apdavison
    MemberAuthor

    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.

  6. apdavison commented on Dec 16, 2013

    @apdavison
    MemberAuthor

    sgarcia wrote on 2011-11-02 17:44:35:

    Yes. In description, I put Quantity.

  7. apdavison commented on Dec 16, 2013

    @apdavison
    MemberAuthor

    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.

  8. apdavison commented on Dec 16, 2013

    @apdavison
    MemberAuthor

    jaillet wrote on 2012-02-01 11:05:23:

    And I also agree with other Samuel's points.

  9. apdavison commented on Dec 16, 2013

    @apdavison
    MemberAuthor

    apdavison wrote on 2012-02-01 11:10:59:

    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.

    In any case, let's postpone this to neo 0.3.

  10. toddrjen commented on Dec 16, 2013

    @toddrjen
    Contributor

    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".

  11. samuelgarcia commented on Dec 16, 2013

    @samuelgarcia
    Contributor

    Agre for actual neo.
    maybe consider it again for neo 0.4 when AnalogSignal and AnalogSignalArray would merge.

  12. toddrjen commented on Dec 17, 2013

    @toddrjen
    Contributor

    I have split the part about using AnalogSignalArray for waveform as a separate issue, #105 . Please continue the discussion there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions