4. Baseline Correction#

It is known that baseline correction is usually required for SEC-SAXS data. In this chapter, we will explain how to do it in Molass Library with one of the methods below.

  • linear (default)

  • uvdiff

  • integral

Note

We won’t explain the details of these methods here in this tutorial. See Molass Technical Report if necessary.

4.1. Learning Points#

  • ssd.plot_compact(baseline=True)

  • ssd.set_baseline_method(‘linear’)

  • ssd.set_baseline_method((‘linear’, ‘uvdiff’))

  • ssd.set_baseline_method(‘integral’)

  • ssd.get_baseline_method()

  • ssd.corrected_copy()

4.2. Linear Correction#

By default, linear baseline is assumed. Before correction, you can confirm how it is determined with basseline option as follows.

from molass import get_version
assert get_version() >= '0.2.0', "This tutorial requires molass version 0.2.0 or higher."
from molass_data import SAMPLE2
from molass.DataObjects import SecSaxsData as SSD
ssd = SSD(SAMPLE2)
trimmed_ssd = ssd.trimmed_copy()
trimmed_ssd.plot_compact(baseline=True);
../../_images/221abe0410be31ea142b995c37a00ef1fcad1e6c912df693a8d341fcf93fb883.png

Note that just plotting does not change the data set. Actual correction is performed by making a corrected copy of the object with the corrected_copy as shown below.

corrected_ssd = trimmed_ssd.corrected_copy()
corrected_ssd.plot_compact(baseline=True);
../../_images/d425148c49f640cd8f558be80cd915c24542809a2e42b979f614af2c0795c1be.png

To change the correction method, you can use set_baseline_method with one of the following specifications.

ssd.set_baseline_method('linear')    # default setting
ssd.set_baseline_method(('linear', 'uvdiff'))
ssd.set_baseline_method('integral')

4.3. UV-specific Correction#

From our experience, it is known that baselines for UV data are usually not linear. To address this peculiarity, you can change the method for UV data only as follows.

set_baseline_method interprets the first element of the tuple as the method for X-ray data and the second as the method for UV data.

trimmed_ssd.set_baseline_method(('linear', 'uvdiff'))
trimmed_ssd.plot_compact(baseline=True);
../../_images/52638847f3403867c7518eb291225f26c78fc8bf802e43e881564e0c9cee2ed7.png

This baseline method setting is retained with copies so that the following standard coding sequence works as expected.

corrected_ssd = trimmed_ssd.corrected_copy()
corrected_ssd.plot_compact(baseline=True);
../../_images/0de4b3b656a8f8ed5352c6e2761fa757350646620548b39ddbedf1178acfdc0a.png
corrected_ssd.get_baseline_method()
('linear', 'uvdiff')

4.4. Integral Correction#

There is another established method which deals with the baseline drift due to the accumulation of fouling. The integral method can be activated by specifying integral.

To contrast the difference, compare the following plots resulted from linear and integral methods.

trimmed_ssd.set_baseline_method('integral')
trimmed_ssd.plot_compact(baseline=True);
../../_images/119065fdef93fdcd3a4b700a2d2e16eefbf5c20f3ffa1f42cefe9e7e42df620c.png

The actual stardard correction procedure will be as follows.

corrected_ssd = trimmed_ssd.corrected_copy()
corrected_ssd.plot_compact(baseline=True);
../../_images/a727ae57336154c16cf4d6bb7bc3e455bb27af6d321bb6748193f97c85d4662b.png

Note that the last specified (with ssd2) and retained (in trimmed_ssd2) method has been valid, which can be shown as follows (not default ‘linear’ in this case).

corrected_ssd.get_baseline_method()
'integral'