You can construct, customize, and reuse preprocessing protocols by creating a ramanspy.preprocessing.Pipeline object. This object accepts a list of preprocessing steps (such as cropping, despiking, denoising, baseline correction, and normalization) and applies them sequentially to your spectra using the .apply() method.
Common preprocessing components include:
- Cropping:
ramanspy.preprocessing.misc.Cropper(region=(min, max)) - Despiking:
ramanspy.preprocessing.despike.WhitakerHayes() - Denoising:
ramanspy.preprocessing.denoise.Gaussian() or ramanspy.preprocessing.denoise.SavGol(window_length=n, polyorder=m) - Baseline Correction:
ramanspy.preprocessing.baseline.ASLS(), ramanspy.preprocessing.baseline.ASPLS(), or ramanspy.preprocessing.baseline.Poly(poly_order=n) - Normalization:
ramanspy.preprocessing.normalise.AUC(pixelwise=True), ramanspy.preprocessing.normalise.MinMax(pixelwise=True), or ramanspy.preprocessing.normalise.Vector(pixelwise=True)
import ramanspy
# Define the pipeline steps
pipe = ramanspy.preprocessing.Pipeline([
ramanspy.preprocessing.misc.Cropper(region=(700, 1800)),
ramanspy.preprocessing.despike.WhitakerHayes(),
ramanspy.preprocessing.denoise.Gaussian(),
ramanspy.preprocessing.baseline.ASLS(),
ramanspy.preprocessing.normalise.AUC(pixelwise=True),
])
# Apply the pipeline to your spectra
preprocessed_spectra = pipe.apply(random_spectra)