[Table of Contents] [Previous section] [Next section]

Interactive Smoothing

A Matlab routine for interactive smoothing for time-series signals, with sliders that allow you to adjust the smoothing parameters continuously while observing the effect on your signal dynamically. Run SmoothSliderTest to see how it works. Can be used with any smoothing function, but two fast smooth functions are included. Click here to download the ZIP file "InteractiveSmoothing.zip" that also includes supporting functions, self-contained demos to show how it works. You can also download it from the Matlab File Exchange.

SmoothSlider


Click to view enlarged figure
Interactive smoothing for your own data, with sliders to control smooth width and the number of passes of the smoothing function through the signal. Requires Matlab 6.5. To use it, place the signal to be smoothed in the global variables X,Y (X = independent variable, Y = dependent variable) and define MaxSmoothwidth as the maximum range of the smooth width slider. Then execute this m-file. Use the Smooth and Passes sliders to change the smooth width and number of passes interactively. The smoothed signal is left in global variable SmoothY. The actual smoothing is performed by the function SmoothSliderRedraw, which is called when the sliders are moved. You can change the smoothing function by replacing "fastsmooth" in line 8 of SmoothSliderRedraw with any other smoothing function.

DemoSmoothSlider


Click to view enlarged figure
A self-contained interactive demo of the effect of smoothing on peak height, width, and signal-to-noise ratio. Requires Matlab 6.5. Generates a Gaussian peak (peak height = 1.0, peak width = 200), adds random noise, smooths it, and measures the signal- to-noise ratio (SNR), peak height, and peak width of the smoothed data. Use the Smooth and Passes sliders to change the smooth width and number of passes interactively. The Resample slider applies different random noise samples, to demonstrate the low-frequency noise that remains. The smooth width and smooth ratio are displayed at the top, and the computed signal maximum, peak width, and signal-to-noise ratio (SNR) are displayed at the bottom of the graph. You can change the peak shape in line 26, and the peak height, width, and noise in lines 21-24. To change the smoothing function, replace "fastsmooth" in the function DemoSmoothRedraw with another smoothing function.

function SmoothY=fastbsmooth(Y,smoothwidth)
Smooths vector Y by unweighted sliding-average (boxcar) smooth of width = smoothwidth. Faster than convolution-based smooths for large smooth widths.

function SmoothY=fastsmooth(Y,smoothwidth)
Smooths vector Y by triangular smooth of width = smoothwidth. Faster than convolution-based smooths for large smooth widths.

ZIP file containing all of the above Interactive Smoothing functions and demos.

Video Demonstration of Interactive Smoothing

This 18-second, 3 MByte video (Smooth3.wmv) of DemoSmoothSlider.m demonstrates the effect of triangular smoothing on a single gaussian peak with a peak height of 1.0 and peak width of 200. The initial white noise amplitude is 0.3, giving an initial signal-to-noise ratio of about 3.3. An attempt to measure the peak amplitude and peak width of the noisy signal, shown at the bottom of the video, are initially seriously inaccurate because of the noise. As the smooth width is increased, however, the signal-to-noise ratio improves and the accuracy of the measurements of peak amplitude and peak width are improved. However, above a smooth width of about 40 (smooth ratio 0.2), the smoothing causes the peak to be shorter than 1.0 and wider than 200, even though the signal-to-noise ratio continues to improve as the smooth width is increased.

Tom O'Haver
Professor Emeritus
Department of Chemistry and Biochemistry
The University of Maryland at College Park
toh@umd.edu
http://www.wam.umd.edu/~toh


[Table of Contents] [Previous section] [Next section]