Code covered by the BSD License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

### Highlights from Baseline Fit

5.0
5.0 | 5 ratings Rate this file 58 Downloads (last 30 days) File Size: 2.98 KB File ID: #24916 Version: 1.0

# Baseline Fit

### Mirko Hrovat (view profile)

A baseline fit is interpolated from selected points and then applied to the data.

File Information
Description

Baseline Fit each column in "x".

There did not seem to be a similar function in th file exchange. This routine is simply a wrapper for two Matlab routines, interp1 and ginput.

Syntax:
[ycorr,yfit] = bf(y,pts,avgpts,method,confirm);
ycorr = bf(y); ycorr = bf(y,method);

A baseline fit is interpolated from selected points and then applied to the data. The selected points are indices into the column and may be specified explicitly ("pts") or interactively.

Arguments following "y" may be in any order.

To provide some noise immunity, "avgpts" determines the width in points for the calculation of the mean y(pts).

The "method" controls the algorithm applied for the baseline fit, see Matlab's interp1. (Default is 'spline').

"confirm", if specified as the string 'confirm', will allow the user to see the result and to confirm it is acceptable. If not the user can reslect "pts".

Examples:
[y,yfit] = bf(y,'confirm','linear');
"y" will be plotted and the user is instructed to select points for the fit. A baseline will be linearly interpolated from the selected points and will be plotted together with "y". The user is prompted as to whether to redo the baseline selection. Upon completion, the corrected data "y" and the fitted baseline "yfit" are output.

ycorr = bf(y,5);
"y" is plotted and the user is instructed to select points for the fit. The baseline fit is based on the mean value of "y" over 5 points centered on the selected points. Cubic spline interpolation is used for the baseline fit. The corrected data "ycorr" is output.

ycorr = bf(y,[5,10,15,30,35,40],'pchip');
Points with the specified indices are used to calculate a baseline fit using the piecewise cubic Hermite interpolation method. No data is plotted. The baseline fit is based on the mean value of "y" over 3 points centered on the selected points. The corrected data "ycorr" is output.

Acknowledgements
MATLAB release MATLAB 7.5 (R2007b)
Other requirements None
Tags for This File   Please login to tag files.
Comments and Ratings (5)
29 Feb 2016 marcogiordani

### marcogiordani (view profile)

It perfectly works. Where did you find the theoretical references to implement such an algorithm?

26 Jan 2015 Céline B

### Céline B (view profile)

Thanks !! Works perfectly for me, thank you very much :-)

15 Nov 2012 Michael Krause

### Michael Krause (view profile)

Exactly what I needed. Well done.

26 Apr 2011 Sindhu Kaimal

### Sindhu Kaimal (view profile)

11 Feb 2010 Brad Ridder

### Brad Ridder (view profile)

Absolutely awesome.

Saved me a lot of time. Thanks!