GC-MS · self-supervised learning · food authentication

Telling fish apart by the shape of their lipids

A whole GC-MS run is a 200 × 1000 matrix: a mass spectrum for every slice of retention time. ChromaDCNN reads that matrix bin by bin with a dilated 1D CNN and names one of four New Zealand fish species. It learns how chromatograms behave from synthetic runs built from public reference spectra before it ever sees a fish.

Reading a Snapper run, bin by bin
Hover the heatmap to scrub. Retention time runs left to right, m/z bottom to top; the right panel is the spectrum under the playhead.
0.867
balanced accuracy, pretrained ChromaDCNN (± 0.104 over 50 folds)
+16.9pp
over the best classical baseline (SVM on chroma-PCA, 0.698)
+24.5pp
from synthetic pretraining (same network from scratch: 0.622)
9,908
public reference spectra behind pretraining. No fish data involved.
01 — DATA

103 chromatograms, four species, six body parts

Lipids were extracted from six body parts of Snapper, Gurnard, Tarakihi and Blue Cod and run on coupled gas chromatography–mass spectrometry. Each run becomes a 200 × 1000 matrix: 200 retention-time bins from 5 to 45 minutes, each holding a mass spectrum. Every bin is square-root transformed and scaled to unit length, so the model sees the shape of each spectrum along the run, not its absolute intensity.

Where the samples come from

Four species, one trace each

Summed √intensity across m/z for the first sample of each species. Hover to read all four at one retention time. The same lipid classes elute everywhere; what differs is the relative pattern.

02 — METHOD

Pretrain on synthetic chemistry, fine-tune on fish

Labelled GC-MS data is scarce, so ChromaDCNN first learns from chromatograms that do not exist. None of the fish data is used for pretraining, so nothing leaks into the cross-validation folds.

Synthesise

9,908 electron-ionisation spectra from MoNA and MassBank are mixed into synthetic chromatograms: 5–30 compounds per run, each eluting as a Gaussian peak of random position and width.

Pretrain

The network predicts the next bin's spectrum from the bins before it (next-frame prediction, 20,000 iterations), learning how co-eluting compounds and peak shapes behave.

Fine-tune & evaluate

The pretrained encoder gets a 4-way head and is fine-tuned on the fish data under 10 seeds × 5-fold stratified cross-validation, with a nested validation split for early stopping.

Architecture, stage by stage

Click a stage. Bar width is its share of the 819,717 parameters.

Show the paper's architecture figure
ChromaDCNN architecture: per-bin linear embedding of each 1000-channel spectrum into 128 features, three dilated residual blocks with kernel 7 and dilations 1, 2 and 4, dual max and attention pooling, and a linear classifier.

How far can one output bin see?

Six dilated convolutions widen the receptive field from 7 bins to 85, about 17 minutes of run time.

Output bin120

A synthetic run, and the next-frame game

The pretraining task: given every bin so far, predict the next one.

Compounds12
Peak width6

03 — RESULTS

Pretrained ChromaDCNN beats every classical baseline

Fourteen methods, each scored on the same 50 held-out folds (10 seeds × 5 folds). Classical baselines (PLS-DA, random forest, RBF-SVM, MLP) are tuned by inner cross-validation on three representations of the chromatogram: the summed spectrum, the per-m/z maximum, and 50 principal components of the full 2D matrix. Every dot is one fold.

Box: median and quartiles over 50 folds; the large marker is the mean. Vertical rule: chance (0.25). Hover a dot for its fold.

Full table

Mann–Whitney U against the best method, Bonferroni-corrected over 13 comparisons; |r| is rank-biserial effect size. Click a header to sort.

04 — PRETRAINING

Synthetic pretraining adds 24 points

The same network trained from random initialisation reaches only 0.622. Both conditions use identical seeds and folds, so every fold can be compared directly.

Fold by fold

Distribution over 50 folds

From scratch is also far less stable: SD 0.162 against 0.104 pretrained.

05 — ABLATION

Does the model need retention time?

Replace every chromatogram with its summed spectrum, copied into all 200 bins. The model, hyperparameters and training code are unchanged, but there is no retention-time structure left to use.

Collapse the RT axis

Watch the input the model receives, and what happens to its accuracy.

Retention time →
m/z 50450
0.593
balanced accuracy, 2D input (from scratch)
—
change when RT is removed

50 folds each, same seeds

Without RT, ChromaDCNN falls to the level of classical models on the summed spectrum (PLS-DA: 0.429, dashed). Its advantage comes from when compounds elute, not just which ions appear. Mann–Whitney p = 4.8 × 10−8, |r| = 0.63.

06 — SALIENCY

Where in the chromatogram is the evidence?

Gradient saliency |∂logitc/∂X| for the true class, computed only on held-out samples: one pretrained model per fold (seed 0, mean fold balanced accuracy ), averaged per species.

Retention time (min)
m/z 50150250350450
low
high

Retention-time profile

m/z profile

Share of RT saliency by window

40–44 min dominates for every species; Tarakihi is the most concentrated.

07 — CAVEATS

What these results do and don't show

Few individuals

The 103 samples come from six fish: one each of Snapper, Gurnard and Tarakihi, and three Blue Cod. Cross-validation is stratified by species, so body parts of the same fish fall on both sides of a split. The accuracies measure generalisation across body parts and replicates, not to new individuals.

Approximately causal pretraining

The convolutions only look backwards in retention time, but batch-normalisation statistics are computed over the whole sequence during training, so the next-frame objective is approximately rather than strictly autoregressive.

Saliency is one seed

The saliency maps use seed 0 only and show where the gradient is large, which is not the same as a causal attribution to specific compounds.

Class imbalance

Blue Cod makes up 57 of 103 samples. All results are balanced accuracy, and training uses a class-weighted loss.

Not a universal win

On public urine (MTBLS71) and rice (MTBLS288) datasets, classical sum-spectrum baselines beat the 2D CNN. There the retention-time axis is dominated by a nuisance variable rather than the target class. The advantage shown here needs chromatographic structure that is informative for the label.

One instrument, one lab

All runs come from a single GC-MS method. Transfer across instruments, columns or acquisition batches is untested.

08 — REPRODUCE

Run it yourself

The preprocessed fish oil data and the pretrained checkpoint are in the repository. Every number on this page is read from results/fish_oil/ by scripts/13_build_site_data.py.

# clone, install
git clone https://github.com/woodRock/chroma-dcnn.git
cd chroma-dcnn
pip install -e ".[dev]"

# ~10 min on a GPU for the CNN; baselines are CPU-only
python scripts/04_finetune_evaluate.py   # ChromaDCNN, 10 seeds × 5 folds
python scripts/05_run_baselines.py       # PLS-DA, RF, SVM, MLP
python scripts/12_results_table.py      # ranking + statistics
python scripts/09_ablation_1d_vs_2d.py   # RT-collapse ablation
python scripts/11_saliency.py            # saliency maps
python scripts/13_build_site_data.py     # refresh this page
@misc{wood2026chromadcnn,
  author = {Wood, Jesse},
  title  = {chroma-dcnn: GC-MS Fish Species
            Identification with Self-Supervised
            Pretraining},
  year   = {2026},
  url    = {https://github.com/woodRock/chroma-dcnn}
}