NIR Preprocessing Explorer

Domain: Kimia · SQalytics · Pipeline SNV/MSC/Savitzky-Golay untuk preprocessing spektrum NIR sebelum kalibrasi

1 Introduksi

1.1 Latar Belakang

Near-Infrared Spectroscopy (NIR) (780–2500 nm) memberikan fingerprinting cepat non-destruktif untuk identifikasi dan kuantifikasi composition pangan (protein, moisture, lemak, gula) tanpa sample preparation. NIR mengukur overtone dan combination bands dari ikatan C–H, O–H, N–H — sehingga sensitif terhadap matriks pangan. Sayangnya, spektrum NIR mentah penuh noise: baseline drift, scattering effect dari partikel, dan overlapping bands membuat preprocessing wajib sebelum modeling kuantitatif via PLSR atau PCA (Næs, Isaksson, Fearn, & Davies, 2002; Rinnan, van den Berg, & Engelsen, 2009).

Empat teknik preprocessing paling umum: Standard Normal Variate (SNV) untuk koreksi multiplicative scatter, Multiplicative Scatter Correction (MSC) untuk koreksi mean-shift + scaling, Savitzky-Golay derivative (1st atau 2nd order) untuk reduksi baseline + sharpening peak, dan Savitzky-Golay smoothing untuk reduksi noise. Pemilihan kombinasi yang tepat dapat menggandakan $R^2$ kalibrasi dan menurunkan RMSECV 50% (Rinnan et al., 2009; Pasquini, 2003).

1.2 Tujuan Modul

Modul NIR Preprocessing Explorer di SQalytics ditujukan untuk:

1.3 Posisi di Antara Alternatif

Pilih NIR Preprocessing Explorer untuk pre-modeling NIR atau spektrum panjang gelombang banyak (Raman, MIR). Untuk overlay UV-Vis sederhana, pakai UV-Vis Spectra. Untuk identifikasi gugus fungsi FTIR, gunakan FTIR Peak Identification. Untuk modeling kuantitatif setelah preprocessing, lanjut ke PLSR Studio. Untuk eksplorasi unsupervised, gunakan PCA Explorer (akan datang).

2 Metode

2.1 Dasar Teoretis

Standard Normal Variate (SNV) (Barnes, Dhanoa, & Lister, 1989) — koreksi scaling per spektrum:

$$ \boxed{\, x_{ij}^{\text{SNV}} = \frac{x_{ij} - \bar{x}_i}{s_i} \,} $$

dengan $\bar{x}_i$ mean dan $s_i$ SD spektrum sample $i$ across all wavelengths. SNV menghilangkan additive (baseline offset) dan multiplicative (slope) scatter dalam satu langkah.

Multiplicative Scatter Correction (MSC) (Geladi, MacDougall, & Martens, 1985) — regress setiap spektrum terhadap mean spectrum:

$$ x_i = a_i \cdot \bar{x}_{\text{ref}} + b_i + \varepsilon_i $$ $$ x_i^{\text{MSC}} = (x_i - b_i) / a_i $$

MSC mathematically equivalent ke SNV untuk pre-processing tetapi membutuhkan reference spectrum (biasanya mean of calibration set).

Savitzky-Golay derivative (Savitzky & Golay, 1964) — fit polynomial $d$ pada window $w$ titik, ambil derivatif analitis:

$$ \frac{dy_i}{dx} = \sum_{j=-(w-1)/2}^{(w-1)/2} c_j^{(1)} \cdot y_{i+j} $$

dengan $c_j^{(1)}$ koefisien Savitzky-Golay untuk 1st derivative. Untuk 2nd derivative pakai $c_j^{(2)}$. Window $w$ tipikal 11–21 titik, polynomial $d$ = 2 atau 3.

Savitzky-Golay smoothing (zero derivative) — least-squares smoothing tanpa mengubah orde:

$$ \hat{y}_i = \sum_{j=-(w-1)/2}^{(w-1)/2} c_j^{(0)} \cdot y_{i+j} $$

Detrend (Barnes et al., 1989) — fit polynomial ke spectrum lalu subtract:

$$ x_i^{\text{detrend}} = x_i - P_d(\lambda) $$

dengan $P_d$ polynomial fit orde $d$ (biasanya 2).

Pipeline preprocessing — chained operations (Rinnan et al., 2009):

  1. Smooth → Derivative → SNV — rekomendasi default untuk NIR pangan.
  2. MSC → 2nd derivative — untuk dilute samples dengan strong scatter.
  3. SNV → Detrend — untuk powder dengan baseline curvature.

2.2 Persamaan Inti

SNV: $x^{\text{SNV}} = (x - \bar{x}) / s$

MSC: $x^{\text{MSC}} = (x - b) / a$ dari regression $x = a \bar{x}_{\text{ref}} + b$

Savitzky-Golay derivative orde-$n$: $d^n y / dx^n = \sum_j c_j^{(n)} y_{i+j}$

Detrend orde-$d$: $x^{\text{detrend}} = x - P_d(\lambda)$

2.3 Asumsi & Batas Validitas

Asumsi Konsekuensi jika dilanggar Cara cek di SQalytics
Resolusi spektrum cukup (≥ 5 nm) Smoothing/derivative artefact Cek raw spectral resolution
Range wavelength konsisten antar sampel Preprocessing inconsistent Modul require fixed grid
Outlier spectra diidentifikasi sebelum mean (MSC) Mean reference bias Visual pre-scan
Window Savitzky-Golay sesuai (small enough untuk preserve peak, big enough untuk noise) Over-smoothing atau noise persist Tune window 11–21
Tidak ada bad pixel atau saturated regions Artefact derivative Mask region sebelum SG derivative
Replikasi $\geq$ 3 per sample untuk averaging Noise tinggi Average sebelum preprocessing

3 Cara Kerja

3.1 Step-by-Step di SQalytics

  1. Buka NIR Preprocessing Explorer dari domain Kimia.
  2. Muat tabel: kolom Wavelength_nm + multi-kolom sampel spektrum (mis. Sample_001, Sample_002, ...).
  3. Pilih preprocessing pipeline:
    - Raw (no preprocessing, baseline).
    - SNV.
    - MSC.
    - Savitzky-Golay smoothing ($w$, $d$).
    - Savitzky-Golay 1st derivative ($w$, $d$).
    - Savitzky-Golay 2nd derivative.
    - Detrend (polynomial order).
    - Custom pipeline: chain ≤ 3 operasi.
  4. Atur parameter Savitzky-Golay: window $w$ (default 15), polynomial $d$ (default 2).
  5. Klik Run Preprocessing.
  6. Tinjau hasil:
    - Tab Raw Spectra — overlay original.
    - Tab Processed Spectra — setelah preprocessing.
    - Tab Mean ± SD — mean spectrum + SD bands.
    - Tab Effect Comparison — side-by-side raw vs processed (statistik: total variance reduced).
    - Ekspor preprocessed CSV untuk pipeline modeling.

Setelah hasil utama tampil di Step 4, gunakan Step 5 opsional untuk mengirim Raw spectra atau Preprocessed comparison ke Publication Graph Studio (PGS). Di sana Anda bisa lanjut mengatur typography, legend, preview Print, lalu ekspor SVG/PNG/PDF untuk kebutuhan publikasi.

3.2 Template Tabel Input + Contoh Data Sintetis

Skema input minimum:

Kolom Tipe Wajib Catatan
Wavelength_nm numeric Sumbu X (1000–2500 nm tipikal)
Sample_ numeric ✓ (≥1) Spektrum reflectance/absorbance

Contoh data sintetis (3 spektrum NIR biji kopi pada 5 wavelength representatif, 10 baris ringkas):

Wavelength_nm Sample_001 Sample_002 Sample_003
1100 0.245 0.252 0.238
1450 0.380 (water OH 1st overtone) 0.395 0.372
1700 0.298 0.310 0.291
1940 0.520 (water OH combination) 0.535 0.510
2100 0.412 0.425 0.408
2300 (CH 1st overtone, oil/lipid) 0.385 0.400 0.380
Data sintetis — NIR diffuse reflectance biji kopi roasted (3 sampel dengan moisture content 8–12%). Peak 1450 nm (water OH) dan 1940 nm (water combination) sensitif terhadap moisture; peak 2300 nm sensitif terhadap lipid/CH.

3.3 Contoh Luaran

Pipeline yang dipilih: Savitzky-Golay smoothing ($w=15$, $d=2$) → 1st derivative ($w=15$, $d=2$) → SNV.

Summary statistik:

Metric Raw After Smooth After 1st Deriv After SNV
Mean reflectance 0.385 0.385 0.000 0.000
SD across samples 0.012 0.011 0.0024 1.000
Total variance 1.45e-4 1.21e-4 5.76e-6 1.000
Baseline drift High Reduced Removed Removed
Scatter effect High High Reduced Removed
Kesimpulan ringkas: "Pipeline 3-langkah (Smooth → 1st derivative → SNV) berhasil menghilangkan baseline drift dan scatter dari spektrum NIR biji kopi. Smoothing $w=15$ mengurangi noise tanpa menghilangkan peak fine structure (validated by retention of 1940 nm water peak). First derivative menghilangkan baseline offset linear sambil men-sharpen peak. SNV final menormalisasi scale per sampel. Result: spektrum siap untuk PLSR moisture prediction. Lanjut ke PLSR Studio dengan preprocessed spectra (X-matrix) dan measured moisture (Y-vector) untuk kalibrasi rapid moisture NIR — target $R^2$ kalibrasi > 0.95 dan RMSECV < 0.3% moisture."
Pipeline NIR preprocessing 4-panel raw vs smooth vs derivative vs SNV
Gambar 1. Pipeline preprocessing spektrum NIR diffuse reflectance biji kopi roasted (3 sampel sintetis dengan offset baseline dan multiplicative scatter, rentang 1100–2400 nm). (a) Raw spectra menunjukkan peak utama H2O pada 1450 nm (OH 1st overtone) dan 1940 nm (OH combination band) — keduanya sensitif terhadap moisture content. Sampel 2 (merah) memiliki baseline offset positif, Sampel 3 (hijau) negatif — efek scatter spesifik permukaan. (b) Savitzky-Golay smoothing ($w$=15, $d$=2) mereduksi noise high-frequency tanpa menghilangkan struktur peak. (c) 1st derivative menghilangkan baseline offset linear dan men-sharpen peak — divergensi antar sampel berkurang drastis. (d) Standard Normal Variate (SNV) menormalisasi scale per sampel sehingga seluruh spektrum overlap — siap untuk PLSR moisture prediction dengan $R^2$ kalibrasi target > 0.95.

4 Kesimpulan

4.1 Relevansi Real-World

4.2 Where to Go from Here

Troubleshooting Cepat

Spektrum derivative penuh noise. Window $w$ terlalu kecil; tambah ke 19 atau 21. Atau smoothing first.
SNV menghilangkan peak penting. Jangan apply SNV pada region narrow peak; window first.
MSC reference shifted. Pilih reference set yang representatif (mean of calibration, bukan satu sample).
Effect comparison menunjukkan tidak ada improvement. Cek apakah pipeline appropriate untuk problem; coba alternatif (Detrend, EMSC).

i Riwayat Revisi

TanggalRevisiPenulis
2026-05-12Migrasi MD v2 → HTML final dengan figure publikasi + caption Elsevier-style (W1 batch malam 12 Mei)Claude
2026-05-12Draft v2 publikasi (KaTeX SNV/MSC/Savitzky-Golay + APA Næs/Rinnan/Barnes/Geladi)Claude

4 Referensi

  • Næs, T., Isaksson, T., Fearn, T., & Davies, T. (2002). A user-friendly guide to multivariate calibration and classification. NIR Publications.
  • Rinnan, Å., van den Berg, F., & Engelsen, S. B. (2009). Review of the most common pre-processing techniques for near-infrared spectra. TrAC Trends in Analytical Chemistry, 28(10), 1201–1222. https://doi.org/10.1016/j.trac.2009.07.007
  • Barnes, R. J., Dhanoa, M. S., & Lister, S. J. (1989). Standard normal variate transformation and de-trending of near-infrared diffuse reflectance spectra. Applied Spectroscopy, 43(5), 772–777. https://doi.org/10.1366/0003702894202201
  • Geladi, P., MacDougall, D., & Martens, H. (1985). Linearization and scatter-correction for near-infrared reflectance spectra of meat. Applied Spectroscopy, 39(3), 491–500. https://doi.org/10.1366/0003702854248656
  • Savitzky, A., & Golay, M. J. E. (1964). Smoothing and differentiation of data by simplified least squares procedures. Analytical Chemistry, 36(8), 1627–1639. https://doi.org/10.1021/ac60214a047
  • Pasquini, C. (2003). Near infrared spectroscopy: Fundamentals, practical aspects and analytical applications. Journal of the Brazilian Chemical Society, 14(2), 198–219. https://doi.org/10.1590/S0103-50532003000200006