AllenInstitute / MIES

Multichannel Igor Electrophysiology Suite
https://alleninstitute.github.io/MIES/user.html
Other
23 stars 7 forks source link

Investigate zero pulses issue with test data #705

Closed t-b closed 3 years ago

t-b commented 4 years ago

@MichaelHuth provided test data in #704

Originally posted by @MichaelHuth in https://github.com/AllenInstitute/MIES/pull/704#issuecomment-721425207

MichaelHuth commented 4 years ago

A simpler and much faster way would be:

variable offset = wv[0]
wv -= offset

It also does not have the side effect of Differentiate dropping points.

t-b commented 4 years ago

@timjarsky What do you think about changing ZeroWave as @MichaelHuth pointed out? This would also be much faster.

timjarsky commented 4 years ago

@t-b Is that method more sensitive to errors/variability in the value of the first point?

t-b commented 4 years ago

@timjarsky From a theoretical point no. But of course numerical differentiation and integration work a bit different than math.

Function/WAVE GetData()

    Make/FREE wv = {100, -100, 1000, -1000}

    return wv
End

Function ZeroOld(WAVE wv)

    Differentiate/DIM=0/EP=1 wv
    Integrate/DIM=0 wv
End

Function ZeroNew(WAVE wv)

    variable offset = wv[0]
    wv[] = wv[p] - offset
End

Function Dostuff()

    WAVE wv = GetData()
    ZeroOld(wv)
    print wv

    WAVE wv = GetData()

    ZeroNew(wv)
    print wv
End

gives

•dostuff()
  '_free_'[0]= {450,0}
  '_free_'[0]= {0,-200,900,-1100}

First line is the existing algo, second just subtracting the first value. So even the new algo does not do any averaging or similiar it is not way wrong compared to the old method.

t-b commented 4 years ago

Switch to new method.