LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Detect and subtract Baseline

Hi,

 

I have some data that looks like this

 

Capture.PNG 

 

In the first part, (Indicated by the blue lines), I want to set it as baseline and set that to zero. But I want to do it automatically. Meaning, I don't want to click at two points and set that average value as baseline. I want the program to detect the baseline, find an average and then subtract it.

Also, it is not always the same amount of length that is there to detect as baseline. It might have smaller length than this example.

 

Can anyone help me with this please. I am using LV-2010.

 

 I am also attaching this data in case somebody wants to play with it.

Download All
0 Kudos
Message 1 of 4
(3,178 Views)

the attached VI thresholds your data and looks for the first point >2.  It takes the index of that data point and multiplies it by 10% and 80% to arrive at the start and end point of the "should be zero" portion of the curve (what you identified with blue lines in your picture).  It takes the mean of this portion of the curve and subtracts it from all of the Y values. 

 

Caveats: the method is not robust to widely varying slopes in the region of interest (e.g. if you have a case where it is much slower to pass through "2")  or if your DC offset is such that "2" is much later in your data than your intended "should be zero" portion.

 

Another way to do this is to threshold the derivitive of the data to look for the start of the "real" data.  That takes the DC offset issue out of it, at least.

 

Note: there is a reverse 1D array operation in the VI 'cause the data was presented in time-descending order.

0 Kudos
Message 2 of 4
(3,155 Views)

Hi Zwired1,

 

Can you please post your vi in LV-2010 or older version. I can not open your vi.

 

Thanks for your reply. 

0 Kudos
Message 3 of 4
(3,139 Views)

Good thing you couldn't open it -- there was a silly bug (I subtracted the mean from the x values,  not Y).

 

Corrected and re-saved attached.

0 Kudos
Message 4 of 4
(3,129 Views)