Skip to content

Handling of missing values in waveforms #343

Closed

Description

@JuliaSprenger

Currently SpikeTrain waveforms are defined as a 3D quantity (array). This makes sense if all waveform have the same length, which in most cases is true. However, in rare cases (eg. with a spike close to the end of the recording signal (AnalogSignal) or very long extraction time windows for waveforms) some waveforms may be lacking a few samples at the beginning or end.
When using quantities objects it is not possible to use 'None' as for simple numpy arrays to indicate missing values as this results in "TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'". It is also not possible to leave incomplete waveforms out and only store complete ones, as the number of spikes has to match the number of waveforms for a given SpikeTrain.
I would be happy about suggestions on how to handle this and still use quantities.

Activity

  1. samuelgarcia commented on Jun 21, 2017

    @samuelgarcia
    Contributor

    Hi Julia,
    Historically, I was the guy that introduced all that waveforms stuuf for SpikeTrain.

    Today I am a bit more expert in spike sorting technics, I known that storing waveforms on the fly is something bad:

    • bad for memory
    • bad because the are not finely aligned (and this is important)
    • sometimes for large channel number the waveform is bigger than the original AnalogSignal itself when high rate discharge.

    So today, I don't use anymore these SpikeTrains.waveforms.

    So, I would vote for removing theses SpikeTrains.waveforms instead of improving it.

    But, this is not possible because some formats still store this, so we need an object for this.

    For this specific problem, I would put np.NaN for padding this spikes near the border.

    For the problem of swapping axes for waveforms, I am OK but it is a piece of work.

    Best

    Samuel

  2. apdavison commented on Jun 21, 2017

    @apdavison
    Member

    👍 for np.NaN

  3. JuliaSprenger commented on Jun 21, 2017

    @JuliaSprenger
    MemberAuthor

    Hi Samuel,
    thanks for the hint of using np.NaN, this works indeed also with quantities. However one still needs to keep in mind that it does not work with arrays of dtype int.
    If you are not using spiketrain waveforms any more, can you go a bit more into detail how you are dealing with waveforms instead?

  4. samuelgarcia commented on Jun 21, 2017

    @samuelgarcia
    Contributor

    What I do in tridesclous (https://github.com/samuelgarcia/tridesclous):

    • Store somewhere the indexes of the peak of the waveform.
    • Never try to get all thewaveform at the same time in memory
    • Sample some indexes (10000) among all indexes of peak (some million !).
    • Construct on the fly the waveform 3D corresponding to thoses index directly from the signal
    • Do some stuff with it.
    • Get some other indexes.

    I also do:

    • on the fly locally oversample the signal chunk for a better waveform alignement on peak.

    For the spike sorting, we need to estimate the density probality of the amplitude of the waveform.
    For this no need to get all the waveforms at the same time.

    Samuel

  5. added this to the future milestone on Sep 9, 2017
  6. samuelgarcia commented on Jun 14, 2023

    @samuelgarcia
    Contributor

    outdated debate and corner case.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions