[Introduction]  [Signal arithmetic]  [Signals and noise]   [Smoothing]   [Differentiation]  [Peak Sharpening]  [Harmonic analysis]   [Fourier convolution]  [Fourier deconvolution]  [Fourier filter]   [Peak area measurement]  [Linear Least Squares]  [Multicomponent Spectroscopy]  [Iterative Curve Fitting]  [Hyperlinear quantitative absorption spectrophotometry] [Appendix and Case Studies]  [Peak Finding and Measurement]  [iPeak]   [iSignal]  [Peak Fitters]   [iFilter]  [iPower]  [List of downloadable software]  [Interactive tools]

index previous next

Interactive Differentiation

Interactive Differentiation using the iSignal function
iSignal is a Matlab function, written as a single self-contained m-file, for performing smoothing, differentiation and other useful  functions on time-series data. Using simple keystrokes, you can adjust the signal processing parameters continuously while observing the effect on your signal dynamically.  Click here to download a ZIP file that also includes some sample data for testing. You can also download it from the Matlab File Exchange.

To use it, just place isignal.m in the Matlab path and type

             >> isignal(DataMatrix); or
>> isignal(x,y); or
>> isignal(y);

where DataMatrix is a matrix with x values in the first row or column and y values in the second.  Press K to see all the keyboard commands.  Use the cursor arrow keys to pan and zoom. To compute a derivative, press the D key, which cycles through the derivative orders 0, 1, 2, 3, 4, and then back to 0.

Careful optimization of smoothing of derivatives is critical for acceptable signal-to-noise ratio. To smooth, press the S key to cycle through four smoothing modes: "None" (he signal is not smoothed), "Rect." (sliding-average or boxcar), "Tri." (triangle or 2 passes of sliding-average), "Gauss." (3 passes of sliding-average). The A and Z keys control the SmoothWidth, w.

Press K to see all the keyboard commands.

Interactive Derivative for older versions of Matlab.
A Matlab routine for interactive differentiation of time-series signals, with sliders that allow you to adjust the derivative order, smooth width, and scale expansion continuously while observing the effect on your signal dynamically. Requires Matlab 6.5; does not work in more recent versisons of Matlab. Run InteractiveDerivativeTest to see how it works. Click here to download the ZIP file "InteractiveDerivative.zip" that also includes supporting functions, self-contained demos to show how it works. You can also download it from the Matlab File Exchange.


Click to view
                enlarged figure
Click to view enlarged figure
Interactive differentiation script for your own data, with sliders to control derivative order, smooth width, and scale expansion. Requires Matlab 6.5. To use it, place your signal in the global variables "x" and "signal" and then execute this m-file. Use the Order and Smooth sliders to change the derivative order and smooth width. Use the Scale slider to expand or contract the y-axis scale. The smoothed derivative is placed in global variable "derivative". The actual differentiation is performed by the function InteractiveDerivativeRedraw, which is called when the sliders are moved. If you wish, you can change the maximum range of the smooth width slider (MaxSmoothwidth in line 14) and the maximum range of the derivative order slider (MaxDerivativeOrder in line 15). You can also change the smoothing function by replacing "fastsbmooth" in InteractiveDerivativeRedraw with any other smoothing function. InteractiveDerivativeTest is a simple test of InteractiveDerivative; it generates a synthetic signal assigned to "signal", then calls InteractiveDerivative.


Click to view
                enlarged figure
Click to view enlarged figure
Demonstration of the application of differentiation to the detection of peaks superimposed on a strong, variable background. Requires Matlab 6.5. Generates a signal peak, adds random noise and a variable background, then differentiates and smooths it, and measures the signal range and signal-to-noise ratio (SNR). Interactive sliders allow you to control the following variables:
Amp: The amplitude (peak height) of the signal peak.  
Default range: 0-3
Back1: The amplitude of the background.
Default range: 0 to 20
Back2: The position of the background.
Default range: -800 to +800
Noise: Random white noise added to the signal.
Default range: 0 - 0.5
Order: Derivative order. Default range: 0-4
Scale: Scale expansion of the y-axis.
Default range: 0.1 - 10.
Smooth: Width of the smoothing function, in data points.
Default range: 0 - 100
Resamp: Applies different random noise samples, to demonstrate
the low-frequency noise that remains after smoothing.

Video Demonstrations of DerivativeDemo.m

The first 13-second, 1.5 MByte video (SmoothDerivative2.wmv ) demonstrates the huge signal-to-noise ratio improvements that are possible when smoothing derivative signals, in this case a 4th derivative.

The second video, 17-second, 1.1 MByte, (DerivativeBackground2.wmv ) demonstrates the measurement of a weak peak buried in a strong sloping background. The amplitude (Amp) of the peak is varied between 0 and 0.14, but the background is so strong that the peak, located at x = 500, is hardly visible. Then the 4th derivative (Order=4) is computed and the scale expansion (Scale) is increased, with a smooth width (Smooth) of 88. Finally, the amplitude (Amp) of the peak is varied again, but now the changes in the signal are now quite noticable and easily measured.

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

This page is part of "A Pragmatic Introduction to Signal Processing", created and maintained by Prof. Tom O'Haver , Department of Chemistry and Biochemistry, The University of Maryland at College Park. Comments, suggestions and questions should be directed to Prof. O'Haver at toh@umd.edu.

index previous next

Number of unique visits since May 17, 2008:

counter create hit