Online peak detection

128 views
Skip to first unread message

Jon Brown

unread,
Jun 6, 2019, 2:57:28 AM6/6/19
to WaveSurfer
Hi all,

Before I start reinventing the wheel, has anyone made a user class for online peak detection/plotting which they would be willing to share?

Essentially I want to measure the peak of my recorded waveform every sweep and plot the amplitude online.

Thanks
Jon

Gyorgy Lur

unread,
Oct 14, 2019, 11:25:05 AM10/14/19
to WaveSurfer
Hi, 

We are also hoping to implement something similar. We are working on user functions that will allow us to display an average of the sweeps in a session, update this average as the recording goes on and potentially measure amplitudes etc. to follow effects of drug application etc. online.

If this has already been developed please let us know!

All the best!
Gyuri

David Nauen

unread,
Oct 14, 2019, 12:36:52 PM10/14/19
to Gyorgy Lur, WaveSurfer

Hello, Here's some simple code for detecting peaks within threshold-crossing regions, if helpful.

Best,

David


-----------------

function event_peaks=find_peaks_within_threshold_crossing_regions(threshold,event_jitter,data_that_crosses_threshold)
%description:  finds segments of a vector that exceed a threshold, finds the index of the maximum value within each segment (the peak), and removes peaks that occur within event_jitter of the previous peak

%find suprathreshold segments
above_threshold=data_that_crosses_threshold>threshold;
beginnings_iftrue=~above_threshold(1:end-1)&above_threshold(2:end);
endings_iftrue=above_threshold(1:end-1)&~above_threshold(2:end);
event_start_indices=1+find(beginnings_iftrue);
event_end_indices=find(endings_iftrue);

%remove suprathreshold segments not fully captured in the recording
if length(event_start_indices)>length(event_end_indices),event_start_indices=event_start_indices(1:end-1);  %when data_that_crosses_threshold ends "high," the last event has a beginning but no ending
elseif length(event_end_indices)>length(event_start_indices),event_end_indices=event_end_indices(2:end);      %when d_t_c_t ends "low," the first event has an ending but no beinning
end

%find the index of the (first) max value within each suprathreshold segment
event_peaks=[];
for ttt=1:length(event_start_indices)
    suprathresh_max=find(data_that_crosses_threshold(event_start_indices(ttt):event_end_indices(ttt))==max(data_that_crosses_threshold(event_start_indices(ttt):event_end_indices(ttt))));
    event_peaks(ttt)=suprathresh_max(1)+event_start_indices(ttt)-1;
end

%remove any peaks within event_jitter of a previous peak
z=length(event_peaks);
if length(event_peaks)>1
    for bleb=2:length(event_peaks)
        if event_peaks(z)-event_peaks(z-1)<event_jitter
            event_peaks(z)=[];
        end
        z=z-1;
    end



From: waves...@googlegroups.com <waves...@googlegroups.com> on behalf of Gyorgy Lur <gyorg...@gmail.com>
Sent: Monday, October 14, 2019 11:25:05 AM
To: WaveSurfer
Subject: Re: Online peak detection
 
--
You received this message because you are subscribed to the Google Groups "WaveSurfer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wavesurfer+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wavesurfer/803d8a3d-85d6-4d8d-9d5d-808ae4123680%40googlegroups.com.

David Nauen

unread,
Oct 28, 2019, 8:36:42 PM10/28/19
to WaveSurfer

Hello,


I am having a drift-type problem which can be summarized as follows: If I am using the model cell in bath configuration and put the amplifier (200B) on seal test, if I look at the output using the National Instruments test panel, I see a very stable, normal appearing square wave, but if I look at this input using Wavesurfer, after correctly configuring electrodes, the square pulse is present but the baseline is drifting rapidly, and I can find no way to stop this.


Any thoughts appreciated, thanks,


David Nauen

Adam Taylor

unread,
Oct 28, 2019, 9:00:18 PM10/28/19
to David Nauen, WaveSurfer
Is sounds like you're looking at the signal in WaveSurfer in the Test
Pulse window? If you do that at the same time as you do the Seal Test
in Multiclamp Commander, each will inject a square wave, and those
square waves will generally be out-of-sync. Could that explain what
you're seeing?

Adam

David Nauen

unread,
Oct 28, 2019, 9:14:39 PM10/28/19
to Adam Taylor, WaveSurfer

Thanks Adam -- no this would be with WaveSurfer using the function '0' and continuous acquisition.  When I did do Test Pulse in WaveSurfer with the 200B (no multi-clamp commander) on external input rather than seal test, in voltage clamp, I could see a single, very noisy, square wave, but the baseline was constantly drifting and reached a threshold where it couldn't be corrected any further, so the square wave got smaller and smaller, then disappeared.


This is essentially a newly set up rig, so I thought it could be some drift in the amplifier baseline, but the fact that seal test baseline is totally stable and normal when viewed using the National Instruments test panel seems to rule that out.


Could it be that WaveSurfer is not setting some pin on the card to zero, or using an unreferenced pin for ground, something along those lines?  I assume WaveSurfer expects referenced single ended inputs from the BNC block correct?  Thanks again


From: Adam Taylor <tay...@hhmi.org>
Sent: Monday, October 28, 2019 9:00:15 PM
To: David Nauen
Cc: WaveSurfer
Subject: Re: drift-like problem
 

Adam Taylor

unread,
Oct 29, 2019, 1:27:26 AM10/29/19
to David Nauen, WaveSurfer
WaveSurfer acquires all analog signals in differential mode, so things
should be terminated appropriate to this:

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019QRZSA2

Could you tell me what NI card you're using? This is all very strange...

Adam
> --
> You received this message because you are subscribed to the Google Groups "WaveSurfer" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to wavesurfer+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/wavesurfer/2adb02c958d74e8f9bc75acd3d9f2397%40jhmi.edu.

dhe...@ucsd.edu

unread,
Mar 16, 2021, 7:36:44 PM3/16/21
to WaveSurfer
Hi,
I'm having a very similar problem. I am using PCIe 6353 and a BNC-2090 breakout box. Using a model cell, when I look at the values in my multiclamp commander they are close to 0 and are not drifting. When I view the voltage or current (depending on mode) in either the WS test pulse window or sweep window, there is a constant downward drift. After seeing this, I did a deep dive into DIFF mode and have mostly ended up more confused that I began. On the bright side, I think I have much more knowledge about what I don't know that when I started... but I have not figured out how to wire the system to work in DIFF. I am about 70% sure that my issue is that I have no reference to calculate the differential against, but I'm not sure how to set that up. Does anyone have a picture of how a Multiclamp 700B should be wired to a BNC 2090 breakout box for use with Wavesurfer? 

Thanks in advance, and sorry from my ignorance.  

Adam Taylor

unread,
Mar 16, 2021, 9:14:37 PM3/16/21
to dhe...@ucsd.edu, WaveSurfer
So... all the switches on the front of the BNC-2090 should be set to DIFF, and you shouldn't connect anything to ACH8 through ACH15.  Is that the case?  (That's about all there is to using DIFF mode correctly, at least when connecting to typical (grounded) outputs from an amplifier.)

Could you say a bit more about your setup?  You're using a model cell, I guess with the switch in the "ground" setting?  And you're not delivering any stimulus, is that right?  If you connect the monitor channel to an oscilloscope instead of the BNC-2090, do you get drift in that case?

Adam


Reply all
Reply to author
Forward
0 new messages