The arPLS GUI was developed to facilitate baseline correction. It incorporates asymmetrically reweighted Penalized Least Squares (arPLS) method, with Graphical User Interface (GUI) implemented in Mathworks Matlab. The arPLS is a proven method for background correction, even for signals with complicated baseline, including many peaks and noise. The GUI was designed to provide a signal with an approximated baseline in a few clicks, ready to save or export to the Matlab workspace. It includes Genetic Algorithm Optimizer to adjust parameters of the arPLS method.
The arPLS GUI is fully compatible with Matlab 2020a and newer. The GA Optimizer requires brash plot functionality, which was implemented with uifigure since Matlab 2020a. However, there is the possibility to use the arPLS main window alone, without the GA Optimizer. It is compatible with Matlab 2018a and newer. Along with the presented software, also previous version coded in .m file was included, compatible with older versions of Matlab.
The application starts after running the arPLS_gui file. To start the application regardless of the current path in Matlab, use the Set Path option from Home > Environment > Set Path and add path to arPLS_gui file. The interface of the arPLS main window can be divided into 3 columns. The left contains options to import and prepare signals to arPLS. The middle displays selected signals, with fitted background with weights. The right adjusts the arPLS parameters and starts the background calculation. The top left menu File loads data from the file and exports results of arPLS baseline correction.
Signals can be loaded only from files. To import data from the file, select Load file from the File menu. GUI accepts only two types of files: mat and txt. After loading a file, it is necessary to select a matrix, because the mat file may contain many Matlab matrices, but the GUI may operate only on a single matrix (double type). When loading a txt file, the GUI creates one matrix and assigns to it the entire contents of the txt file. Such a matrix may contain single or multiple curves (signals). Curves must be in columns, to be properly loaded and displayed. The GUI also provides two options to Constrain curves points and Exclude curves from further baseline approximation. First of those options, allow to cut off few beginning and ending points of signals. The second helps to exclude unwanted curves from the baseline approximation. It is done by unchecking the checkbox next to the unwanted curve.
Before the calculation of the baseline, it is recommended to adjust the arPLS parameters. It can be done manually or automatically using the implemented GA Optimizer. The most important parameter that affects arPLS is lambda (λ), which adjusts the smoothness of the baseline. Its value can be set between 10e1 and 10e6. The higher the value of λ, the greater the smoothness and straightness of the approximated baseline. Another parameter optimized for arPLS is the ratio (r). It value can be set between 10e-1 and 10e-6. It directly determines how fast arPLS algorithm convergence is. The GUI provides also the wbe parameter, which force arPLS algorithm to assign weights for beginning and ending points of signal to 1, and arPLS cannot change itself. That helps to better approximate the beginning and ending points of signals with the arPLS baseline. Other less important option is the w threshold, which determines how the arPLS algorithm calculates the weights w. Basically, it changes the weight assignment in the 0-1 interval to a binary assignment only between 0 or 1 values. Another parameter is the maximum number of iterations, which should not be described. After the calculations are completed, the GUI presents the results by displaying the signals with an approximated baseline in the main plot and weights at the bottom plot.
In menu File, the GUI provides two options to export results of the baseline approximation: Export fit to .mat file or Export fit to workspace. In both options, exported data contains four matrices: selected signals for whom the baseline was approximated (including constraints and curves exclusions), approximated baseline (or baselines), weights from final iteration and signals with subtracted baseline.
The arPLS method requires at least two parameters (λ and r) to generate a proper baseline. Therefore, an automatic optimization was provided using a genetic algorithm (GA) to facilitate this tusk. Access to GA Optimizer is from the arPLS GUI main window, after loading and selecting signals, by clicking the GA Optimizer button. The optimizer interface contains two key features: first, the options to graphical selection curve and peaks for optimization, and second, the options to adjust, start and observe results of the optimization. Curves and peaks selection is done with the option in the top-right panel, which also enables brushing points in the main plot of the Optimizer. Options of GA can be adjusted by its parameters panel (in the middle right). The optimization results are presented on the GA optimizer mean and best score plot supplemented with text messages from the GA logs.
GA optimization is usually calculationally demanding, especially when the number of curves is significant. Thus, anyone may decide to choose between: longer more precise optimization including all curves or faster, less precise optimization with only one curve. In order to limit curves to one, it is necessary to check use only one curve option. This option is not enabled by default, and all curves are included. Furthermore, the GA Optimizer requires information about the localization of the peaks, not just the peaks maximum, but the localization of the whole peaks. Such information must be provided by the researcher, but in our GUI it is done using a convenient, graphical interface by brushing peak points in the plot. Selection starts by the Brush peak points button. The mouse cursor should change into a cross when hovering over the plot with the curves. Then, peaks selection is done by just drawing rectangle selection by cursor. Multiple peaks selection is possible with the Shift key, and deselection is by selection of already selected points. To deselect all peak just select any free space in the plot. The approval of the peaks selection is done by pressing the Add selection button. Since then, optimization is enabled.
After curve and peaks selection, it is possible to start GA optimization of arPLS parameters. GA has its own parameters which can be adjusted too, but in almost all cases leaving default values should be optimal. It is also recommended to leave the option to include wbe in optimization checked. In most cases, optimizing the wbe parameter with λ and r provides a better arPLS baseline. Tracking optimization progress is possible by observing plots and logs. The plot updates with information on the current state of the population (GA mean score plot) and the best score of the fitness function (GA best score plot). The values of both should gradually decrease. At first, the GA mean score value is usually high, meaning that the population contains many different solutions, mostly suboptimal. With successive generations, the population becomes more uniform, containing only the best solutions, what is expected. The second plot, the GA best score, shows the lowest score for the best chromosome in the population. It also gradually declines with the generation of algorithms. When the GA Optimizer convergences, the best combination of λ, r, wbe is displayed at the bottom of the GA logs. Pressing the Return results to arPLS window button, the best parameters are transferred to the arPLS main window, and the baseline calculation is performed.
arPLS GUI is licensed under GPLv3.
This program is developed by Łukasz Górski [email protected] and Małgorzata Jakubowska [email protected].
- Ł. Górski, M. Jakubowska, A graphical user interface for arPLS baseline correction, Chemometrics and Intelligent Laboratory Systems, Volume 238, 2023, 104848, DOI: https://doi.org/10.1016/j.chemolab.2023.104848.
- S.-J. Baek, A. Park, Y.-J. Ahn, J. Choo, Baseline correction using asymmetrically reweighted penalized least squares smoothing, Analyst, Volume 140, 2015, 250, DOI: https://doi.org/10.1039/C4AN01061B.