Test-versus-CAE correlation¶
Module: crashmetrics.correlation.
How well does the simulation match the test? Overlaying curves and judging by eye is subjective and does not scale to hundreds of channels. This module rates a CAE signal against a test signal with one number between 0 (no match) and 1 (identical), using:
- ISO/TS 18571:2024: the ISO objective rating for vehicle safety signals (corridor, phase, magnitude, slope), with a grade from excellent to poor.
- CC rating: corridor plus cross-correlation (phase, size, shape), the method of Gehre et al. (2009) that is widely used for dummy and human body model validation.
- Classic error measures: peak and peak-time errors, RMSE, the correlation coefficient, Sprague & Geers and Russell errors.
All three take the same inputs, and compare runs them together.
Step 1: prepare the two signals¶
from crashmetrics.signals import cfc_filter
test = cfc_filter(t_test, head_ax_test, cfc=180)
cae = cfc_filter(t_cae, head_ax_cae, cfc=180)
- Same quantity, unit, sign convention and filter class for both signals: the rating cannot tell a filter or sign mistake from a model error.
- Same time zero (T0). The time bases may differ: test data at 20 kHz and CAE output at 10 kHz is fine. Both are resampled to a common 0.1 ms grid (the 10 kHz the standard assumes) over the interval they share.
- The reference is the signal you trust (the test), the comparison the one being rated. The ratings are not symmetric: corridors are sized from the reference.
Step 2: choose the interval of evaluation¶
from crashmetrics.correlation import iso18571
r = iso18571(t_test, test, cae, comparison_time=t_cae, t_start=0.0, t_end=0.13)
Without t_start and t_end, the whole common interval is used. Choose
the interval to cover the event and little else: a long quiet tail
where both signals are near zero inflates the corridor score. Use the
same interval for every model version you compare.
Step 3: read the ISO/TS 18571 rating¶
r.rating, r.grade # 0.897, 'good'
r.corridor, r.phase, r.magnitude, r.slope
r.time_shift_ms # +1.8: the CAE is 1.8 ms late
| Score | Weight | What it measures |
|---|---|---|
| Corridor Z | 0.4 | Share of the curve inside corridors around the test: inner ±5 %, outer ±50 % of the test's absolute maximum (quadratic in between) |
| Phase E_P | 0.2 | Time shift with the best correlation; 1 for no shift, 0 at 20 % of the interval |
| Magnitude E_M | 0.2 | Amplitude error after removing the shift and aligning the curves with dynamic time warping; 0 at 50 % error |
| Slope E_S | 0.2 | Error of the smoothed derivative (shape and rise rates); 0 at 200 % error |
| Grade | Overall rating R |
|---|---|
| excellent | R > 0.94 |
| good | 0.80 < R ≤ 0.94 |
| fair | 0.58 < R ≤ 0.80 |
| poor | R ≤ 0.58 |
The sub-scores tell you what to fix: a low phase score with a high magnitude score points to timing (contact, belt slack, airbag deployment); a low magnitude score to stiffness or mass; a low slope score to the shape of the loading.
Verified against an independent implementation
The ISO/TS 18571 rating reproduces the open-source
objective-rating-metrics package of the Vehicle Safety Institute,
TU Graz, to machine precision on 40 crash-like signal pairs,
including time-warping ties on flat signals. The test suite checks
five of these cases.
Step 4: the CC rating and the error measures¶
from crashmetrics.correlation import cc_rating, error_measures
c = cc_rating(t_test, test, cae, comparison_time=t_cae, t_end=0.13)
c.rating, c.corridor, c.phase, c.size, c.shape
e = error_measures(t_test, test, cae, comparison_time=t_cae, t_end=0.13)
e.peak_error, e.peak_time_error_ms, e.nrmse, e.sprague_geers_comprehensive
CC rating = 0.5 × corridor + 0.5 × cross-correlation, where the cross-correlation rating combines:
- phase: 1 for a shift up to 1 % of the interval, 0 from 12 %;
- size: ratio of the smaller to the larger signal energy (∑x²);
- shape: the normalised cross-correlation at the best shift.
Check the settings against the tool your project uses
The method is published (Gehre, Gades and Wernicke, ESV 2009) and is
best known from PDB's CORA tool. cc_rating is an independent
implementation, not affiliated with PDB. Settings of this method
differ between tools and versions and are often customised; the
defaults in CCParameters are the commonly cited values and have
not been checked against PDB's manual. If your project compares
with another tool, rate a few channels with both, set
CCParameters to match, and report the settings with the scores.
Automatic intervals and standard-deviation corridors (offered by
some tools) are not implemented.
Error measures (0 is perfect for the errors, 1 for the correlation):
| Measure | Meaning |
|---|---|
peak_error |
(|peak CAE| − |peak test|) / |peak test|: +0.10 means the CAE peak is 10 % high |
peak_time_error_ms |
CAE peak time minus test peak time |
rmse, nrmse, mae, max_error |
Point-by-point differences; nrmse is the RMSE divided by the test's absolute maximum |
correlation, r_squared |
Pearson correlation and coefficient of determination, without a time shift |
sprague_geers_* |
Magnitude M, phase P and comprehensive C = √(M² + P²) (Sprague & Geers 2004) |
russell_* |
Magnitude, phase and comprehensive error (Russell 1997) |
Step 5: all at once, many channels, many model versions¶
from crashmetrics.correlation import compare
c = compare(t_test, test, cae, comparison_time=t_cae, t_end=0.13, channel="head (v1)")
print(c.summary())
head (v1): ISO 18571 0.897 (good; corridor 0.901, phase 0.930, magnitude 0.951, slope 0.800, shift +1.8 ms)
head (v1): CC rating 0.922 (corridor 0.901, phase 0.963, size 0.870, shape 0.996)
head (v1): Errors: peak +11.8% at +0.9 ms, NRMSE 0.075, Sprague & Geers C 0.084
For a model version with many channels, rate each channel and report the mean (and the worst channel). ISO/TS 18571 rates one signal pair; it does not prescribe how to combine channels, so state your weighting.
Correlation as features for ML¶
The ratings are numbers like any other criterion, so they fit straight into a feature table, for example to track model quality across versions or to learn which design changes move the model away from the test:
from crashmetrics.features import feature_table, flatten
def extract(cae):
return [flatten(compare(t_test, test[ch], cae[ch], comparison_time=t_cae),
prefix=f"{ch}.") for ch in test]
rows = feature_table(model_versions, extract, id_column="model")
# columns: head.iso.rating, head.iso.phase, head.cc.size, head.errors.peak_error, ...
Complete example¶
A sled test with head, chest and pelvis accelerations against three model versions, with different time bases:
"""Example 12: test-versus-CAE correlation with ISO/TS 18571 and the CC rating.
A sled test measured head, chest and pelvis accelerations at 20 kHz.
Three CAE model versions wrote the same channels at 10 kHz, starting
2 ms later. Each channel is rated with ISO/TS 18571, the corridor and
cross-correlation (CC) rating and classic error measures, the model
versions are ranked, and the ratings go into a feature table (synthetic
data).
"""
import numpy as np
from crashmetrics.correlation import compare
from crashmetrics.features import feature_table, flatten
from crashmetrics.signals import cfc_filter
rng = np.random.default_rng(12)
t_test = np.arange(0.0, 0.15, 5e-5) # test: 20 kHz
t_cae = np.arange(0.002, 0.15, 1e-4) # CAE: 10 kHz
def pulse(t, amp, start, width):
phase = (t - start) / width
return np.where((phase > 0) & (phase < 1), amp * np.sin(np.pi * phase), 0.0)
def channels(t, scale=1.0, delay=0.0, width=1.0, rebound=1.0):
"""Head, chest and pelvis x-acceleration in g."""
return {
"head": pulse(t, 55 * scale, 0.030 + delay, 0.060 * width)
- pulse(t, 12 * rebound, 0.090 + delay, 0.030),
"chest": pulse(t, 42 * scale, 0.025 + delay, 0.065 * width),
"pelvis": pulse(t, 38 * scale, 0.020 + delay, 0.055 * width)
+ pulse(t, 10 * scale, 0.072 + delay, 0.020),
}
# --- 1. Test (with sensor noise) and three model versions --------------------
test = {name: cfc_filter(t_test, x + rng.normal(0, 1.0, t_test.size), cfc=180)
for name, x in channels(t_test).items()}
models = {
"v1 baseline": channels(t_cae, scale=1.12, delay=0.004, width=0.92),
"v2 belt": channels(t_cae, scale=1.04, delay=0.002, width=0.97),
"v3 belt+seat": channels(t_cae, scale=1.01, delay=0.0005, width=1.0,
rebound=0.85),
}
models = {v: {n: cfc_filter(t_cae, x, cfc=180) for n, x in ch.items()}
for v, ch in models.items()}
# --- 2. One channel in detail -------------------------------------------------
# Different time bases are fine: both signals are resampled to 10 kHz over
# the interval they share (here 2 to 150 ms), or over t_start..t_end.
c = compare(t_test, test["head"], models["v1 baseline"]["head"],
comparison_time=t_cae, t_end=0.13, channel="head (v1)")
print(c.summary())
# --- 3. Every channel and model version --------------------------------------
print(f"\n{'model':13} {'channel':7} {'ISO':>6} {'grade':10} {'Z':>5} {'E_P':>5} "
f"{'E_M':>5} {'E_S':>5} {'shift':>6} {'CC':>6} {'peak':>7}")
for version, cae in models.items():
ratings = []
for name in ("head", "chest", "pelvis"):
r = compare(t_test, test[name], cae[name], comparison_time=t_cae, t_end=0.13)
i = r.iso
ratings.append(i.rating)
print(f"{version:13} {name:7} {i.rating:6.3f} {i.grade:10} {i.corridor:5.2f} "
f"{i.phase:5.2f} {i.magnitude:5.2f} {i.slope:5.2f} "
f"{i.time_shift_ms:+5.1f}ms {r.cc.rating:6.3f} "
f"{r.errors.peak_error:+7.1%}")
print(f"{version:13} {'mean':7} {np.mean(ratings):6.3f}\n")
# --- 4. Ratings as features: one row per model version ----------------------
def extract(cae):
return [flatten(compare(t_test, test[n], cae[n], comparison_time=t_cae,
t_end=0.13), prefix=f"{n}.") for n in test]
rows = feature_table(models, extract, id_column="model")
ratings = [k for k in rows[0] if k.endswith(("iso.rating", "cc.rating"))]
print(f"Feature table: {len(rows)} rows x {len(rows[0])} columns, e.g.",
", ".join(ratings[:3]), "...")
best = max(rows, key=lambda r: r["head.iso.rating"] + r["chest.iso.rating"]
+ r["pelvis.iso.rating"])
print("Best correlated model version:", best["model"])
Output:
head (v1): ISO 18571 0.897 (good; corridor 0.901, phase 0.930, magnitude 0.951, slope 0.800, shift +1.8 ms)
head (v1): CC rating 0.922 (corridor 0.901, phase 0.963, size 0.870, shape 0.996)
head (v1): Errors: peak +11.8% at +0.9 ms, NRMSE 0.075, Sprague & Geers C 0.084
model channel ISO grade Z E_P E_M E_S shift CC peak
v1 baseline head 0.897 good 0.90 0.93 0.95 0.80 +1.8ms 0.922 +11.8%
v1 baseline chest 0.900 good 0.92 0.95 0.94 0.77 +1.4ms 0.935 +11.8%
v1 baseline pelvis 0.869 good 0.87 0.92 0.92 0.75 +2.1ms 0.904 +11.9%
v1 baseline mean 0.889
v2 belt head 0.962 excellent 0.99 0.95 0.99 0.90 +1.2ms 0.986 +3.8%
v2 belt chest 0.956 excellent 0.99 0.96 0.98 0.86 +1.0ms 0.987 +3.9%
v2 belt pelvis 0.944 excellent 0.98 0.95 0.97 0.84 +1.3ms 0.981 +3.9%
v2 belt mean 0.954
v3 belt+seat head 0.979 excellent 1.00 0.98 0.98 0.93 +0.5ms 0.998 +0.8%
v3 belt+seat chest 0.970 excellent 1.00 0.98 0.99 0.88 +0.5ms 0.996 +0.9%
v3 belt+seat pelvis 0.970 excellent 1.00 0.98 0.99 0.88 +0.5ms 0.997 +0.9%
v3 belt+seat mean 0.973
Feature table: 3 rows x 121 columns, e.g. head.iso.rating, head.cc.rating, chest.iso.rating ...
Best correlated model version: v3 belt+seat
References¶
- ISO/TS 18571:2024, Road vehicles — Objective rating metric for non-ambiguous signals (and the 2014 first edition).
- C. Gehre, H. Gades, P. Wernicke: Objective rating of signals using test and simulation responses, ESV 2009, paper 09-0407 (the corridor and cross-correlation method).
- L. E. Schwer: Validation metrics for response histories: perspectives and case studies, Engineering with Computers 23 (2007), covering the Sprague & Geers and Russell measures.