Have a question? E-mail: toh@umd.edu
or join our group on Facebook
This page describes a series of downloadable Matlab
interactive signal processing tools for x,y time-series data.
Technical background, documentation, and examples of application
are provided in "A Pragmatic Introduction to Signal
Processing", available in HTML and
PDF formats.
There are two type of interactive functions
described here: keystroke
operated and Live
Scripts.
The interactive functions listed in this section run in the Figure window and use a simple set of single keystroke commands, rather than on-screen buttons or menus or sliders, in order to reduce screen clutter, minimize overhead, maximize processing speed, and allow you to explore data and try out various approaches easily and quickly. Press K to see the list of keystroke commands within each program. The Figure window can be re-sized as you wish, including maximized to full-screen or stretched over a two-screen setup to see the maximum detail in the signals, and can be Saved in various formats, Copy/Pasted, or Printed, using the standard Matlab menus. My goal is to make these programs very easy to get working, with flexible input syntax, built-in help, extensive online documentation, and many simple examples that you can copy and paste into your Matlab command window. Note: all of the functions described below are written as self-contained Matlab functions (m-files) and require no add-on toolboxes to run, but the scripts often call functions that must be downloaded and placed in the Matlab path. These interactive programs will even work if you run Matlab in a web browser, as shown on the right, (just click on the figure window before using the keypress functions), but unfortunately the interactive features do not work in Matlab Mobile on iPads and iPhones. If you use Octave instead of Matlab, you must use the separate Octave versions of these programs (indicated by "octave" added to the file names).
A complete catalog of over 200 of my signal processing functions and demonstration scripts, both interactive and command-driven, are listed and described on functions.html. These scripts and functions are downloaded 500-1000 times per month on average, both from my web site and from the Mathworks File Exchange, and they have been used by thousands of scientists, engineers, researchers, instructors, and students working in industry, environmental, medical, engineering, earth science, space, military, financial, agriculture, communications, and even music and linguistics. They have been applied in many areas of investigation and have been cited in over 360 published papers, theses, and patents. Don't miss the amazing unsolicited user comments below from actual users of these programs. User comments and suggestions have often resulted in changes and new features being added to the latest versions (see Matlab File Exchange "Pick of the Week"); keep those emails and messages coming.
Peak Finding and MeasurementMatlab routines for locating and measuring the peaks (or valleys) in noisy time-series data sets. It detects peaks by looking for downward zero-crossings (or upward zero-crossings for valleys) in the smoothed first derivative then determines the position, height, and width of each peak by least-squares curve-fitting of the raw data near the detected peaks. (This is useful primarily for signals that have several data points in each peak, not for spikes that have only one or two points).There are both command-line and interactive versions: (1) a set of command-line functions for Matlab and Octave,
for finding peaks in signals and measuring
their positions, heights, widths, and areas
by least-squares curve-fitting, especially
useful as modules to use in your own custom
scripts and functions to automate data
processing. These are listed here, each
linked to its description:
findpeaksx,
findpeaksG,
findvalleys,
findpeaksL,
measurepeaks,
findpeaksG2d,
findpeaksb,
findpeaksb3,
findpeaksplot,
findpeaksplotL,
peakstats,
findpeaksE, findpeaksGSS,
findpeaksLSS,
findpeaksT,
findpeaksfit,
autofindpeaks
and autopeaks.
These can be used as
components in creating your own custom
scripts and functions. Don't
confuse with the "findpeaks"
function in the Signal
Processing Toolbox.
These tools are the ones to use
when (a) the quantities of greatest interest are the
peak positions and amplitudes of the positive peaks in
your signal, (b) the peaks have distinct (even if noisy)
maxima, and (c) when you want all the
peaks numbered and quantified in one operation. You
can use the interactive iPeak function
to determine the ideal input arguments for the various findpeaks command-line
functions. Note: the latest version of iPeak
can perform iterative non-linear curve fitting on the
peaks that it finds, using the built-in peakfit.m
function (described below); this is useful for highly
overlapped or non-Gaussian peaks. For some demos,
download idemos.zip.
(2) The interactive keypress-operated function iPeak, or the Octave version, illustrated on the right displaying signals from a variety of sources. Using iPeak, you can pan and zoom, adjust each of the peak detection parameters individually and interactively to optimize peak detection and measurement, and much more. For Matlab only. There is an animated demonstration. |
iPeak
|
|
Interactive smoothing and differentiation Frequency spectrum mode |
Peak Fitters
Peak fitting programs for time-series
signals, which use a non-linear
optimization algorithm to decompose
a complex overlapping-peak signal into its component
parts. The objective is to determine whether your signal
can be represented as the sum of fundamental underlying
peaks shapes. Accepts signals of any length, including
those with non-integer and non-uniform x-values. Fits
groups of peaks of many different shapes).
There two different
versions: |
|
|
|
Hyperlinear quantitative absorption spectroscopyMatlab implementation of a computational method for quantitative analysis by multiwavelength absorption spectroscopy, called the transmission-fitting or "TFit" method, based on measuring the underlying absorbance by fitting a model of the instrumentally-broadened transmission spectrum to the observed transmission data, rather than by direct calculation of absorbance as simply log10(Izero/I).Advantages of the TFit method compared to conventional
methods are: (a) wider dynamic range; (b) greatly
improved calibration linearity;
(c) ability to operate under conditions that are
optimized for signal-to-noise
ratio ratio
rather than for optical ideality. With a linear
response, absorbance can be converted to concentration
simply by multiplying by a constant factor. Just like the multilinear regression
(classical least squares) methods
conventionally used in absorption spectroscopy, the Tfit
method (a) requires an accurate reference spectrum of
each analyte, (b) utilizes multiwavelength data such as
would be acquired on diode-array, Fourier transform, or
automated scanning spectrometers, and (c) applies both
to single-component and multi-component mixture analysis. tfit.m is a command-line demo function for Matlab or Octave. TFitDemo.m is an interactive demo m-file that works in recent versions of Matlab. Version 2.1, November 2011. |
|
iPower: Interactive Power Spectrum DemoMatlab keyboard-controlled interactive power spectrum demonstrator, useful for teaching and learning about the power spectra of different types of signals and the effect of signal duration and sampling rate. Single keystrokes allow you to select the type of signal (12 different preset signals included), the total duration of the signal, the sampling rate, and the global variables f1 and f2 which are used in different ways in the different signals. If you know some basic Matlab programming, you can even add your own custom signal functions to this program. When the Enter key is pressed, the signal (y) is sent to the Windows WAVE audio device. Press K to see a list of all the keyboard commands.Click here to view or download. You can also download it from the Matlab File Exchange. Version 2, October 2011 |
|
Diffraction
Grating Demos
A set of
keyboard-controlled interactive demonstration modules,
written as self-contained Matlab functions, that are
useful for learning
and teaching the principles of diffraction gratings. Shows a working cross
section
of the geometry of a diffraction grating (a common
illustration in textbooks of optics, spectroscopy, and
analytical chemistry). Single keystrokes allow you to
control such variables as the angle of incidence, grating
ruling density, wavelength, and diffraction order. One module
shows how the operation of a
diffraction grating emerges naturally just by adding up
a bunch of sine waves, without any higher math at all.
|
(a) Make sure you don't click on the "Show Plot Tools" button in the toolbar above the figure; that will disable normal program functioning. If you do; close the Figure window and start again.
(b) To facilitate transfer of settings from one of these functions to another or to a command-line version,all these functions use the W key to print out the syntax of other related functions, with the pan and zoom settings and other numerical input arguments specified, ready for you to Copy, Paste and edit into your own scripts or back into the command window. For example, you can convert an iSignal.m operation onto a command-line ProcessSignal.m call, or a curve fit in ipf.m into the command-line peakfit.m function, or a peak finding operation from ipeak.m into the command-line findpeaksG.m or findpeaksb.m or findpeaksb3.m functions. This provides a way to deal with signals that require different signal processing in different regions of their x-axis ranges, by allowing you to create a series of command-line functions for each local region that, when executed in sequence, quickly process each segment of the signal appropriately.
(c) Recent versions of these three programs use the Shift-Ctrl-S, Shift-Ctrl-F, and Shift-Ctrl-P keys to transfer the current signal between iSignal.m, ipf.m, and iPeak.m
The script has several interactive controls. The two sliders in lines 9 and 10 allow you to select which portion of the data range to process, from 0% to 100% of the total range of the data file. The SmoothType drop-down menu in line 13 selects the smoothing algorithm; each has one or more controls specific to that type in lines 16 to 30. The first choice is the recursive sliding average (fastsmooth.m) algorithm explained above. The smooth width and number of passes are controlled by the sliders in lines 16 and 17. Each The other controls are explained in the accompanying comment lines (in green). Fourier filtering, Savitsky-Golay and wavelet denoising are topics that will be explained in other sections. The PlotBeforeAndAfter checkbox in line 3 gives you the option of plotting the original signal (in black) along with the processed signal (in red). The FrequencySpectra checkbox in line 4 allows you to show the frequency spectrum of the original and/or processed signals (see HarmonicAnalysis.html). Note: to view the graphic plots to the right of the code, as shown above, right-click on the empty space on the right and select "Disable synchronous scrolling".
DeconvoluteData.mlx can
perform Fourier self-deconvolution on you own data stored in
disk. Clicking the Open data file button in line 1
opens a file browser, allowing you to navigate to your data
file in .csv or .xlsx format. (The script assumes that your
x,y data are in the first two columns; you can change that in
lines 13 and 14). In the case shown here, the data file is a
portion of the IR spectrum of Heptene, 'HepteneTestData.csv',
shown as the 'file' variable in the workspace. The The startpc and endpc sliders
in lines 9 and 10 allow you to select which portion of the
data range to process, from 0% to 100% of the total range of
the data file.
The PeakShape drop-down menu in line 17 selects the convolution function shape (in this case, a Gaussian-Lorentzian blend) and the PCGaussian slider in the next line allows selection of the percent Gaussian of that shape. The dw slider in line 21 controls the deconvolution half-width, the DA slider in line 23 controls the percent denominator addition. Smoothing, by Fourier filtering, is controlled by the FrequencyCutoff and CutOffRate in lines 25 and 27. All variables are accessible in the Matlab workspace; the final signal is 'syDA'.
Click the FrequencySpectra
check box in line 4 to view the frequency spectra. Click
the PlotAllSteps check box in line 5 to
view all the steps leading up the the final result.
To view the figures to the right as shown below,
right-click on the right-hand panel and select
"Disable synchronous scrolling".
Like the
other Live Scripts described above, PeakFittingTool.mlx
has a file browser button in line 1 and a pair of sliders in lines 4
and 5 for setting the desired segment to work on.
But before opening a file, it's a good idea to temporarily
de-select the "FitPeaks" check-box in line 14, then
when you have set all the other controls, click it back on.
That way you will avoid waiting for unnecessary curve fit
operations until the appropriate settings are complete.
(Sometimes curve fitting operations can be slow and can take
several seconds in difficult cases). With FitPeaks switched off,
the program simply displays a plot of the
selected data file.
"Your Interactive Peak Fitter ... is very helpful."
"Your peak finding and fitting scripts ... turned out handy in analyzing my research
data."
"I found your peakfit.m program and it is great - thank you very much for sharing it!"
"...the codes for finding peaks and mathematical fits to
noisy data...were very helpful
for my experimental work."
"I appreciate all the work that must have gone into the PeakFit matlab coding. I've been using it ... and it is becoming extremely useful."
",,,your Matlab function findpeaks()...is quite literally EXACTLY what I was looking for and far better than I could have hoped."
"...MATLAB code for scientists! It's such a great resource to have.... I really appreciate your efforts."
"Thank you for making available your absolutely superb Peakfinder software. It is a snap to use...." "Wonderful program."
Copyright (c) 2014, 2021 Thomas C. O'Haver
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sub-license, and/or
sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.