LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

PolyFit functions - should it return up to order + 1 actual values?

I have been using the PolyFit function in CVI 2010 (version 10.0.0 (360)) and I am trying to figure out if I am implementing incorrectly, there is a bug for higher order or if I am getting the exepected behavior.

 

The function always return zero for coefficients above 26 (order equals between 45 to 90 ). I could understand this if the fit were always good but in cases where the fit is obviously less than optimum the first twenty seven coefficients (o through 26) are populated but the remainder never are. Is this an expected behavior?

 

The application is the removal of baseline roll / drift from mass spectrometry data. The file sizes are large (4 MPoint and up) which must be tackled in smaller chunks (at least currently). One may can correct misfit data by limiting the chunk size manaually but the end goal is routine,  robust automation across multiple blind spectra.

0 Kudos
Message 1 of 8
(4,197 Views)

Hi,

 

I have tried the sample polyfit1 provided by NI, and it shows a similar behavior, i.e. no fit curve for order > 25. Looks like an insect 😉

0 Kudos
Message 2 of 8
(4,194 Views)

Thanks for the quick verify, Wolfgang

0 Kudos
Message 3 of 8
(4,191 Views)

Hi Blakney,

 

I did some testing and was able to see the same behavior that you have reported.  I have filed a bug report ( # 293898) in order to have R&D further investigate the issue.  

Regards,

Hassan Atassi
Senior Group Manager, Digital Support
0 Kudos
Message 4 of 8
(4,173 Views)

Hi blakney,

 

PloyFit function has the limitation for order of 25.  So what you see is the expected behavior.

 

This is because a very small numeric inaccuray (which always exists in floating point arithmetic) in high order coefficient will result in significant diverge for the fitting curve.  

 

If order 25 does not give good fit, probably higher order does not work as well.    

 

My understanding of baseline is that it is normally quite flat or varying slowly.  So the poly order should be small.    Correct me if I am wrong.

 

Best Regards,

Michael

 

 

0 Kudos
Message 5 of 8
(4,168 Views)

Hi Michael,

 

while I would second your opinion that such high orders are 'problematic', the functional behavior simply is in disagreement with its documentation (this is what I would consider a bug). So if the function is ok, it means the documentation is wrong...

 

from the CVI2010 doc:

 

order int Order of the polynomial used in the polynomial fit operation. This value must be greater than 0 and less than 90.

Default Value: 1.

 

Wolfgang

Message 6 of 8
(4,164 Views)

Hi Wolfgang,

 

I check the document.   You are right.   I think this is a documentation bug in PolyFit function.     Thank you!

 

We will fix this in future release.

 

Thanks,

Michael

0 Kudos
Message 7 of 8
(4,160 Views)

In our case the baseline roll is relatively slow compared with the real signals. However, the correction using the current polyfit has an effective  limit of 500 to 1500 Hz (chi by eye). This requires several regions to be fit and then the  "joints" to be smoothed to cover the approxiamtely 1 MHz bandpass that we are looking for. Such  a piecewise fit is doable but it requires a lot more knowledge of the system if the analysis is to be performed in batch mode (no human intervention.) 

 

The main question of what should the return values be suggest that the function should be upward bounded to a value less than 90 (the current limit as described in the  documentation and reported by the debugger ).

 

 

0 Kudos
Message 8 of 8
(4,131 Views)