Skip to content

Savitzky Golay filtering

Guillaume Erny edited this page Dec 19, 2017 · 1 revision

Introduction

While optional, this step can significantly improve the reliability of the baseline correction and improve the computational speed. The example presented here followed the steps made previously( see Scans alignment) The general command for this function is:

myFinnee = myFinnee.filterDataset(Id, 'SGolay:m:n');

where Id is the index to the dataset to filter, m is the frame length of the Savitzky-Golay filtering, and n defined the number of point to record. With n = 1, every data points will be recorded, with n = 2 one data point every two will be recorded and so forth.

Testing the filter

This command will use the sgolayfilt Matlab function with an order 1. Before using the filterDataset command, parameters can easily be tested. For example, from the TIP (myFinnee.Datasets{2}.TIP.plot) TIP the command of the second most intense peak can be determined, and the mean spectrum across the peak is obtained using (myFinnee.Datasets{2}.getSpectra([6.31 6.46]).plot).

Spectra

The profile corresponding to the most intense peak in this spectra is

EIP = myFinnee.Datasets{2}.getProfile(194.9463);
EIP.plot

EIP

The filter can be tested using sgolayfilt, for example, to test the effect of the frame length,

EIP.plot
hold on
plot(EIP.Data(:,1), sgolayfilt(EIP.Data(:,2),1,3))
plot(EIP.Data(:,1), sgolayfilt(EIP.Data(:,2),1,5))
plot(EIP.Data(:,1), sgolayfilt(EIP.Data(:,2),1,7))
hold off

sgolayfilt

Using the filter

myFinnee = myFinnee.filterDataset(2, 'SGolay:5:2');

will create the dataset three from the dataset 2, data will be filtered with the sgolayfilt function of order 1 and framelen 5, and only one data over two will be recorded, allowing a drastic reduction of the noise as well as decreasing by a factor ~2 the data size.


Up          :Correcting a Dataset
Next       : Baseline correction
Previous: Scans-alignment