04-13-2011 12:08 PM
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.
04-13-2011 01:02 PM
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 😉
04-13-2011 01:11 PM
Thanks for the quick verify, Wolfgang
04-14-2011 04:04 PM
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.
04-14-2011 09:02 PM
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
04-15-2011 12:41 AM
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
04-15-2011 12:55 AM
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
04-19-2011 01:19 PM
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 ).