# Bounding Box Regression Prediction

> Use when when you have a trained CNN binary classifier for peak detection on rt×mz LC-HRMS images and need to additionally output precise bounding-box coordinates (left, right, top, bottom) and peak-center pixel positions for each detected peak to enable accurate feature quantitation or visual.

- Skill: `holobiomicslab/bounding-box-regression-prediction` (Agent Skill)
- Install (CLI): `npx skillmds@latest add holobiomicslab/bounding-box-regression-prediction`
- Raw SKILL.md: https://api.skillmd.com/api/skills/holobiomicslab/bounding-box-regression-prediction/raw
- Safety review: PASS (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- License: CC-BY-4.0
- Author: HolobiomicsLab (https://skillmd.com/u/holobiomicslab)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/holobiomicslab/bounding-box-regression-prediction

---


# bounding-box-regression-prediction

> **License: noncommercial** — confirm your use is a permitted (noncommercial) purpose before applying; commercial use requires a separate license (see `metadata.tool_license`). <!-- asb-license-banner -->
## Summary

Train and deploy a CNN regression head to predict spatial bounding-box coordinates and peak-center locations for chromatographic peaks in standardized rt×mz two-dimensional LC-HRMS image patches. This skill complements peak/background classification by localizing the exact boundaries and centroid of detected peaks for downstream feature extraction.

## When to use

When you have a trained CNN binary classifier for peak detection on rt×mz LC-HRMS images and need to additionally output precise bounding-box coordinates (left, right, top, bottom) and peak-center pixel positions for each detected peak to enable accurate feature quantitation or visual verification against reference chromatograms.

## When NOT to use

- Input is already a feature table or quantified peaks — this skill is for localization of peak boundaries in raw rt×mz images, not for downstream statistics.
- Peaks have been manually annotated with bounding-boxes and centers and no further localization is required.
- The CNN model has not been trained on the target LC-HRMS instrument or chromatographic method, as regression performance is method- and background-dependent.

## Inputs

- Standardized two-dimensional rt×mz image patches corresponding to local maxima from LC-HRMS profile-mode data
- Labeled training set with ground-truth bounding-box coordinates and peak-center locations for chromatographic peaks
- Reference feature list (isolated single chromatographic peaks) with matching annotations

## Outputs

- CNN model with regression heads for bounding-box coordinates (e.g., [x_min, x_max, y_min, y_max])
- Peak-center coordinate predictions (pixel row, column or rt, mz offset)
- Regression error metrics (coordinate prediction accuracy on test set)
- Predicted bounding-box and peak-center values for new rt×mz image patches

## How to apply

Augment the CNN architecture with auxiliary regression heads that output continuous coordinates for bounding-box and peak-center in parallel with the primary peak/background classification head. Train all heads jointly on labeled training instances generated by iteratively combining reference features matched to ground-truth chromatograms, where each training instance includes the true bounding-box and peak-center coordinates. Use mean squared error or similar smooth loss for coordinate regression. During validation, evaluate regression accuracy by computing prediction error (e.g., Euclidean distance or L2 norm) between predicted and ground-truth coordinates on a held-out test set of rt×mz image patches. Ensure training instances include varying background types and distraction peaks to generalize coordinate prediction across different signal-to-noise scenarios.

## Related tools

- **TensorFlow** (Deep learning framework for implementing CNN architecture with multi-task regression and classification heads) — https://www.tensorflow.org/
- **PeakBot** (Python package that implements the complete peak detection and bounding-box regression pipeline for LC-HRMS, including training instance generation, CNN training, and coordinate output export) — https://github.com/christophuv/PeakBot
- **CUDA/cuDNN** (GPU acceleration libraries for training large CNN models and generating training instances efficiently) — https://developer.nvidia.com/cuda-downloads
- **OpenMS/TOPPView** (Visualization tool for inspecting predicted bounding-boxes and peak-centers exported as featureML files) — https://pubmed.ncbi.nlm.nih.gov/19425593/

## Examples

```
from peakbot import train_cnn_model; model = train_cnn_model(training_patches, training_labels, bounding_boxes, peak_centers, epochs=50, batch_size=32, validation_split=0.2); predictions = model.predict(test_patches); print(f'Bounding-box MAE: {mean_absolute_error(predictions['bbox'], test_bboxes)}')
```

## Evaluation signals

- Mean absolute error (MAE) or root mean squared error (RMSE) of predicted bounding-box coordinates versus ground-truth on held-out test set should be <5% of image patch dimensions
- Peak-center predictions should fall within the manual ground-truth bounding-box at least 95% of the time on validation data
- Visual inspection: exported example images should show predicted bounding-boxes and peak-centers overlaid correctly on chromatographic peaks, not on background noise or distraction peaks
- Coordinate predictions should be spatially stable across augmented versions of the same training instance (e.g., slight rotations or brightness variations)
- No systematic bias in predictions across different background types (e.g., walls vs. noise) — residuals should be centered near zero

## Limitations

- Regression accuracy is highly dependent on the quality and diversity of the training set; underrepresented peak morphologies or background types will produce poor coordinate predictions.
- The CNN model requires substantial GPU memory (e.g., 4 GB for batch size 2048); memory constraints may force smaller batch sizes that reduce training stability.
- Bounding-box regression assumes peaks are axis-aligned in rt×mz space; highly tilted or irregular peak shapes may be poorly localized.
- The model's generalization to new LC-HRMS instruments, chromatographic methods, or sample matrices depends on overlap with training data; transfer learning may be necessary for out-of-distribution peaks.
- Coordinate predictions are relative to the extracted rt×mz patch; mapping back to absolute chromatogram coordinates requires careful bookkeeping of patch origin and scaling.

## Evidence

- [other] outputs: (1) classification of whether each local-maximum is a chromatographic peak with left/right isomeric compounds or background signal, and (2) for peaks, a suggested bounding-box and peak-center.: "outputs: (1) classification of whether each local-maximum is a chromatographic peak with left/right isomeric compounds or background signal, and (2) for peaks, a suggested bounding-box and"
- [other] Construct a CNN architecture to perform binary classification (peak vs. background) with auxiliary regression heads for bounding-box coordinates and peak-center location.: "Construct a CNN architecture to perform binary classification (peak vs. background) with auxiliary regression heads for bounding-box coordinates and peak-center location."
- [other] Train the CNN on labeled training instances generated by iteratively combining reference features matched to ground-truth chromatograms.: "Train the CNN on labeled training instances generated by iteratively combining reference features matched to ground-truth chromatograms."
- [other] Validate the model on a held-out test set, evaluating classification accuracy and bounding-box / peak-center coordinate prediction error.: "Validate the model on a held-out test set, evaluating classification accuracy and bounding-box / peak-center coordinate prediction error."
- [readme] The CNN model is implemented in the TensorFlow package. It consists of several convolutional and pooling-layers and outputs a peak-type, -center, and -bounding-box.: "The CNN model is implemented in the TensorFlow package. It consists of several convolutional and pooling-layers and outputs a peak-type, -center, and -bounding-box."
- [readme] uses local-maxima in the LC-HRMS dataset each of which is then exported as a standarized two-dimensional area (rt x mz), which is used as the input for a machine-learning CNN model: "uses local-maxima in the LC-HRMS dataset each of which is then exported as a standarized two-dimensional area (rt x mz), which is used as the input for a machine-learning CNN model"

