RELSA Severity Assessment

RELSA Severity Assessment

by:

@OpenSourceBuffGuy

📚 Education & Research

Computes RELSA severity scores from welfare readouts for laboratory animal studies and forecasts endpoint scores with ARIMA, including threshold zones.

Skill files9 files

assets/

references/

scripts/

SKILL.md365 lines
1
---
2
name: relsa-severity-assessment
3
description: Supports multivariate severity assessment and exploratory endpoint-time score forecasting for laboratory animal studies using the RELSA (RELative Severity Assessment) score and ARIMA-based foRcast forecasting. Use when combining welfare readouts — body weight or weight loss, body temperature, clinical or nesting scores, biomarkers, activity, heart rate, burrowing, wheel running — into one severity score per animal per day, when asking which animals are at risk of reaching a humane endpoint at a specified future observation time, when defining attention/danger zones or thresholds on a severity scale by kernel density estimation, or when reporting severity for a 3Rs, refinement, animal-welfare, or EU Directive 2010/63/EU severity-assessment context. Covers directionality ("turned" variables), baseline normalization, reference sets, RELSA weights, ARIMA prediction intervals, and RMSE/PICP/MPIW evaluation.
4
license: MIT
5
allowed-tools: Read Write Edit Bash
6
compatibility: Requires Python >=3.12 with numpy, pandas, scipy, statsmodels and matplotlib. Local analysis needs no network or credentials; installation and upstream review need network access.
7
metadata:
8
version: "1.3"
9
last-reviewed: "2026-10-01"
10
skill-author: K-Dense Inc.
11
---
12
13
# RELSA severity assessment and exploratory score forecasting
14
15
## Overview
16
17
This skill computes reference-relative multivariate scores and exploratory ARIMA forecasts.
18
It targets the equations and printed example of [RELSA 0.0.1.9000](https://github.com/mytalbot/RELSA)
19
(commit `e68e8451e8719ccc3600179f55900cd7254ede9d`, current upstream at review), plus the
20
published [foRcast methodology](https://doi.org/10.3389/fphys.2026.1869563).
21
The Python forecast helper is an independent nonseasonal approximation, not an exact R port.
22
23
RELSA is the RMS of directional deviations divided by each variable's reference maximum
24
**deviation**. Zero means no measured worsening in those directions; it does not establish
25
normal welfare. One is a reference scale unit, not a universal endpoint or an upper bound.
26
Different variables may attain their reference extrema in different animals or at different
27
times, so the reference cohort need not contain a score of exactly one.
28
29
Forecasts estimate a **score at a specified time**, not time-to-endpoint or probability of death.
30
Keep the approved study's observation schedule and humane endpoint criteria separate from
31
these exploratory outputs. See [Boundaries](#boundaries-state-these-when-you-report).
32
33
## When to use this skill
34
35
- Combining weight loss, temperature, clinical scoring, biomarkers, or telemetry into a single
36
per-animal severity score
37
- Asking which animals in a cohort are at risk of reaching a humane endpoint, or predicting
38
the severity score at a coming time point
39
- Comparing severity between treatment groups, interventions, or animal models on a common
40
relative scale
41
- Defining thresholds or zones on a severity scale from the data
42
- Writing the severity-assessment section of an animal welfare report, a 3Rs/refinement
43
analysis, or an application under EU Directive 2010/63/EU
44
45
For general forecasting of a time series that is not a severity score, use
46
**timesfm-forecasting** or **statsmodels**. For study design and sample size, use
47
**experimental-design** and **statistical-power**.
48
49
## Installation
50
51
```bash
52
uv venv --python 3.13 .venv-relsa
53
uv pip install --python .venv-relsa/bin/python numpy==2.5.3 pandas==3.0.6 scipy==1.18.1 statsmodels==0.15.0 matplotlib==3.11.2
54
source .venv-relsa/bin/activate
55
```
56
57
Run the examples from this skill directory. `relsa_score.py` needs numpy/pandas;
58
`kde_thresholds.py` additionally needs scipy; statsmodels is required
59
for forecasting and matplotlib only for figures.
60
61
## Data format
62
63
One row per animal per time point, in a CSV:
64
65
| id | treatment | condition | day | temp | weight | score | il6 |
66
| --- | --- | --- | --- | --- | --- | --- | --- |
67
| M01 | treated | endpoint | -1 | 37.15 | 25.17 | 0 | 35.1 |
68
| M01 | treated | endpoint | 0 | 37.26 | 25.25 | 0 | 39.5 |
69
| M01 | treated | endpoint | 1 | 35.83 | 23.12 | 4 | 162.0 |
70
71
- `id` and a time column (`day`, `time`, `hour`, …) are required; `treatment` and `condition`
72
are optional labels used for grouping and for selecting the reference set.
73
- Time must be finite, with one consistent unit and origin across cohorts. Forecast training and
74
target times must align with the chosen regular grid; disable interpolation only on regular observations. The RELSA
75
convention codes the baseline time point as `-1`.
76
- **One row per animal per time point.** Average hourly telemetry to one value per interval
77
first (the published models average heart rate, HRV, and temperature, and sum activity).
78
- Preserve lexical animal IDs (including leading zeros). Duplicate IDs/times, nonnumeric
79
measurements and infinities are rejected. Leave missing measurements empty. They are dropped from the score, never imputed — a
80
missing value treated as "no deviation" biases severity downward.
81
82
`assets/example_cohort.csv` is a small synthetic cohort (6 mice, 9 days, temperature, body
83
weight, an 0–8 clinical score, and an IL-6-like biomarker) used by every command below, so
84
each one is runnable as written.
85
86
## The four decisions that determine the result
87
88
Make these explicitly and write them into the methods. Nothing else about the procedure
89
matters as much.
90
91
**1. Directionality — which variables rise under worsening?** Falling is the default (body
92
weight, activity, food intake, burrowing, wheel running). Variables that *rise* must be
93
declared as `--turned`: clinical scores, inflammatory biomarkers, fever, tachycardia. Get
94
this wrong and the variable contributes nothing at all, silently, because deviations in the
95
"wrong" direction are floored at zero. Body temperature is model-dependent — it *falls* in
96
sepsis and endotoxaemia, *rises* in fever models. Nothing in the data can settle this for you:
97
in the published sepsis model activity legitimately swings further above baseline than below,
98
so only a variable that *never once* moves the declared way is detectable, and
99
`build_reference()` warns about exactly that case.
100
101
**2. The reference set — relative to what?** RELSA scores mean nothing without it. Choose a scientifically characterized reference and document its burden; the 2026
102
forecasting study uses the group assumed to carry the greatest burden in each model. A mild reference can push new scores
103
above 1; too severe compresses everything toward 0. Save it with `--save-reference` and reuse
104
it with `--load-reference` so later cohorts stay on the same scale. New CLI reference files
105
also store and reuse normalization, ordinal mappings, baseline selection and rounding; conflicting
106
options are rejected. Legacy references lack that contract and require the original options.
107
108
**3. Scores with a zero baseline.** A clinical score of 0 in a healthy animal cannot be
109
ratio-normalized — `0/0` is undefined. Use `--score-scale score=8` to map the score's scale
110
instead (healthy → 100%, worst possible → 200%), which also marks it as turned. This assumes meaningful numeric spacing between ordinal categories. An affine rescaling
111
applied identically to reference and target cancels in the weight ratio before rounding; the
112
category encoding, healthy anchor and reference cohort still matter. State those choices. The alternative is to keep the score out of RELSA and use it as an
113
independent endpoint criterion.
114
115
**4. Which variables are measured throughout.** Because the score averages over whichever
116
variables are available, a variable that appears or disappears mid-trajectory moves the score
117
by itself. An intermittent measure joining only at the endpoint can lower or raise the composite
118
without any change in the other observed measures.
119
`relsa_scores()` warns when composition changes; score the variables present throughout.
120
121
## Workflow
122
123
### Step 1 — compute RELSA scores
124
125
```bash
126
python scripts/relsa_score.py assets/example_cohort.csv \
127
--variables weight,temp,score,il6 \
128
--normalize weight,temp,il6 \
129
--turned il6 \
130
--score-scale score=8 \
131
--baseline-time -1 \
132
--reference-group condition=endpoint \
133
--save-reference reference.json \
134
--out relsa_scores.csv
135
```
136
137
The reference model is echoed so the scale is auditable:
138
139
```
140
reference model: assets/example_cohort.csv [condition=endpoint]
141
animals=2 rows=18 baseline_time=-1.0
142
variable turned max reached max delta
143
weight no 82.40 17.60
144
temp no 92.79 7.21
145
score yes 187.50 87.50
146
il6 yes 797.72 697.72
147
```
148
149
`relsa_scores.csv` holds each variable's weight alongside the score, which is what makes a
150
score explainable — here M01 deteriorating to its endpoint, M03 peaking on day 3 and
151
recovering:
152
153
```
154
id time weight temp score il6 n_vars relsa
155
M01 1 0.46 0.49 0.57 0.52 4 0.51
156
M01 3 0.84 0.76 1.00 0.89 4 0.88
157
M01 5 1.00 1.00 1.00 1.00 4 1.00
158
M03 3 0.56 0.44 0.57 0.54 4 0.53
159
M03 5 0.35 0.26 0.43 0.32 4 0.35
160
M03 7 0.12 0.06 0.14 0.11 4 0.11
161
```
162
163
A weight of 1.00 means that variable hit the reference maximum; `n_vars` is how many
164
variables entered the score at that time point.
165
166
Same thing from Python, when you need the objects:
167
168
```python
169
import sys; sys.path.insert(0, "scripts")
170
from _common import read_relsa_table, score_to_percent
171
from relsa_score import prepare, build_reference, relsa_scores
172
173
frame = read_relsa_table("assets/example_cohort.csv")
174
frame["score"] = score_to_percent(frame["score"], max_score=8) # 0-8 clinical score
175
VARS, TURNED = ["weight", "temp", "score", "il6"], ["score", "il6"]
176
177
prepared = prepare(frame, normalize=["weight", "temp", "il6"], baseline_time=-1)
178
reference = build_reference(prepared[prepared.condition == "endpoint"],
179
variables=VARS, turned=TURNED, baseline_time=-1,
180
label="endpoint-reaching animals")
181
scores = relsa_scores(prepared, reference)
182
```
183
184
### Step 2 — forecast a score at a known evaluation time
185
186
For retrospective evaluation, use recorded endpoint times and train only on earlier
187
observations. This synthetic example predicts scores at designated times; it does not
188
validate humane endpoint detection:
189
190
```bash
191
python scripts/forecast_relsa.py relsa_scores.csv \
192
--animals M01,M02 --endpoints M01=5 --endpoints M02=6 \
193
--group-col condition --plot-dir figs \
194
--out forecasts.csv --summary-out forecast_metrics.csv
195
```
196
197
The CSV includes the selected order, point forecast and bounds. Numerical values can change
198
with the fitted model and library release. Report RMSE, PICP and MPIW together, including
199
counts and forecast failures. High coverage with wide intervals can be uninformative.
200
201
For prospective evaluation, freeze the RELSA reference set and any KDE thresholds using a separate development cohort before forecasting held-out animals. Do not estimate normalization maxima or thresholds from their future endpoint observations. Label analyses that reuse endpoint data to define the scale as retrospective; use an animal-level split so repeated observations from one animal do not cross evaluation partitions.
202
203
For rolling retrospective evaluation, forecast each next observed time using only its history:
204
205
```bash
206
python scripts/forecast_relsa.py relsa_scores.csv --mode rolling --animals M03
207
```
208
209
Interpolation defaults to 0.1 **input time units** for published-method exploration. It creates
210
no independent information, changes autocorrelation and can narrow intervals without valid
211
calibration. Use `--interpolate-step 0` for regular observed data and compare interpolation
212
sensitivity on held-out animals. Off-grid targets and irregular uninterpolated observations
213
are rejected rather than silently relabeled. Unconverged fits are not selected. Bounds are
214
Gaussian model intervals clipped at zero, conditional on fitted parameters and the frozen
215
scale; they exclude reference, preprocessing and model-selection uncertainty.
216
217
ARIMA represents linear dependence after differencing; it does not anticipate abrupt
218
unobserved deterioration. Inspect both interval width and upper bound alongside observed
219
welfare signs and approved criteria. No bound is an automatic intervention rule.
220
221
### Step 3 — put the score in context with severity zones
222
223
```bash
224
python scripts/kde_thresholds.py relsa_scores.csv \
225
--group treatment=treated --n-thresholds 2 --plot zones.png --json zones.json
226
```
227
228
```
229
KDE on 33 RELSA scores (bandwidth = 0.1502)
230
candidate thresholds (density minima): 0.703
231
density modes: 0.264, 0.866
232
normal [0.000, 0.703) n=25 (75.8%)
233
danger >= 0.703 n=8 (24.2%)
234
```
235
236
The example deliberately filters to treated animals; choose the target population explicitly.
237
Thresholds are the *minima* of the score density — the sparse valleys between clusters of
238
scores. A development population may include endpoint animals, survivors and shams, but sampling
239
frequency, follow-up duration and their proportions change the density. Freeze that choice
240
before evaluation; do not pool incompatible reference frames.
241
242
**Check bandwidth and sampling sensitivity.** See `references/thresholds-and-zones.md`.
243
An empty threshold list is legitimate. Minima are properties of the sampled score density;
244
zone names do not establish welfare states. The thin-zone filter is this implementation's
245
heuristic, not a published validated threshold rule.
246
247
## Boundaries: state these when you report
248
249
- RELSA and forecasts support assessment; observed distress and approved humane endpoint
250
criteria take precedence. No low score authorizes delaying care or extending a procedure.
251
- KDE zones are not EU severity categories. The [Commission severity framework](https://environment.ec.europa.eu/topics/chemicals/animals-science_en)
252
distinguishes prospective classification, monitoring and actual experienced severity;
253
there is no official RELSA-to-category conversion.
254
- Comparisons require the same frozen reference, variable panel, encoding, baseline and
255
measurement methods. The original paper explored cross-model comparisons in a common
256
frame; independently scaled models cannot be ranked by their raw RELSA numbers.
257
- The 2026 paper evaluates 13 endpoint-time forecasts. Its reported 96% PICP is consistent
258
with averaging seven model rows (six 100%, one 75%), not pooled animal coverage:
259
12/13 is 92.3%. Its 1.69 MPIW is likewise a model-row mean; this helper pools predictions.
260
- False negatives and false positives can both matter. Predefine monitoring responses with
261
the study's responsible personnel; do not turn a candidate KDE minimum into an endpoint.
262
263
## Reporting checklist
264
265
A severity analysis is reproducible only if all of this is stated:
266
267
1. Outcome measures, their units, and their **directionality** (which were turned, and why).
268
2. The **baseline** time point or window, and which variables were normalized.
269
3. Any **score mapping** applied to ordinal variables, with its scale.
270
4. The **reference set**: which animals, which group, how many, and why they are assumed to
271
carry the greatest burden.
272
5. Humane endpoint criteria actually applied in the study, separately from the RELSA score.
273
6. For forecasts: interpolation step, the selected ARIMA order per animal, and RMSE, PICP,
274
*and* MPIW.
275
7. For thresholds: the bandwidth, the number of scores, and a bandwidth sensitivity sweep.
276
8. Software versions, and the statement that thresholds are model-specific and not regulatory
277
gradings.
278
279
## Common pitfalls
280
281
1. **Wrong directionality** — a rising variable not listed in `--turned` contributes exactly
282
zero, silently, and no warning is possible unless it never once falls. Check the reference
283
model table yourself: `max reached` should be below 100 for a falling variable and above 100
284
for a turned one, and `max delta` should be a plausible size for that measure.
285
2. **Confusing percent encodings** — 90% of baseline, -10% change and 10% loss differ.
286
RELSA needs baseline 100: convert change with `100 + change`, loss with `100 - loss`.
287
Re-normalizing baseline-100 values is redundant; using a zero-centered change as baseline is invalid.
288
3. **A zero baseline** — a clinical score of 0 makes the ratio undefined; the variable becomes
289
all-NaN with a warning. Use `--score-scale`.
290
4. **A reference set that does not express the burden** — a variable that never deviates in it
291
raises an error rather than dividing by zero, and one that barely deviates inflates every
292
score. Reference extrema are sensitive to outliers and measurement errors.
293
5. **Changing variable composition along a trajectory** — see decision 4 above.
294
6. **Reading MPIW as a good thing** — a wide interval raises PICP while destroying the
295
forecast's usefulness.
296
7. **Reporting a KDE threshold without its bandwidth** — thresholds can appear or vanish as
297
bandwidth changes.
298
8. **Treating the forecast as permission to wait** — the model cannot see abrupt
299
deterioration, and the humane endpoint criteria of the protocol always take precedence.
300
9. **Comparing RELSA scores between models** — requires one reference frame and harmonized measurements.
301
302
## Resources
303
304
### Scripts
305
306
- `scripts/relsa_score.py` — the RELSA procedure: `prepare()`, `build_reference()`,
307
`relsa_scores()`, `relsa_weights()`, and a `ReferenceModel` that serialises to JSON.
308
Matches the R package's printed worked example to two decimals; native R was not run.
309
- `scripts/forecast_relsa.py` — the independent foRcast-style helper: `auto_arima()` (Hyndman–Khandakar stepwise
310
AICc selection), `forecast_animal()`, `predict_endpoint()`, `rolling_forecast()`,
311
`forecast_indirect()`, `summarize()`, and trajectory plots.
312
- `scripts/kde_thresholds.py` — severity zones: `bw_nrd0()` (R's bandwidth), `density_curve()`,
313
`find_thresholds()`, zone assignment, and density plots.
314
- `scripts/_common.py` — RELSA-format I/O, validation, `score_to_percent()`,
315
`percent_of_baseline()`, and `forecast_metrics()` (RMSE/PICP/MPIW).
316
317
### References
318
319
- `references/relsa-method.md` — the four steps in full, the score/zero-baseline problem, the
320
variable-composition trap, parity notes against the R package, and current upstream API/source limitations.
321
- `references/forecasting.md` — ARIMA selection, why interpolation is a distortion, direct vs
322
indirect prediction, the metrics, the published Table 1, and the limits of this implementation.
323
- `references/thresholds-and-zones.md` — KDE method, published thresholds, the bandwidth
324
sensitivity sweep, the regulatory boundary, and alternatives when KDE gives nothing.
325
326
### Assets
327
328
- `assets/example_cohort.csv` — synthetic 6-mouse cohort with temperature, body weight, a
329
clinical score, and a biomarker; illustrative only, not real data.
330
331
### Related skills
332
333
- **experimental-design**, **statistical-power** — designing the study and sizing the groups.
334
- **statsmodels**, **timesfm-forecasting** — general time-series modelling.
335
- **statistical-analysis**, **scientific-visualization** — group comparisons and figures.
336
337
### Key references
338
339
- Talbot, S. R. et al. (2022). RELSA — a multidimensional procedure for the comparative
340
assessment of well-being and the quantitative determination of severity in experimental
341
procedures. *Front. Vet. Sci.* 9:937711. R package: <https://github.com/mytalbot/RELSA>
342
- Lutscher, S. et al. (2026). Refining humane endpoint detection by time-series forecasting
343
and threshold definition using a multivariate severity score. *Front. Physiol.* 17:1869563.
344
- Hyndman, R. J. & Khandakar, Y. (2008). Automatic time series forecasting: the forecast
345
package for R. *J. Stat. Softw.* 27, 1–22.
346
- EU Commission (2010). Directive 2010/63/EU on the protection of animals used for scientific
347
purposes.
348
349
## Citing Scientific Agent Skills
350
351
This skill is part of Scientific Agent Skills by K-Dense. If it materially contributed to a
352
manuscript, report, presentation, or code release, add the paper to the references or
353
software section and tell the user you did so:
354
355
> Kassis, T., Agarwal, V., He, Y., Patel, D., & Brueckner, A. M. (2026). Scientific Agent
356
> Skills: A Library of Procedural Knowledge for Research Agents. arXiv:2609.00065.
357
> https://doi.org/10.48550/arXiv.2609.00065
358
359
Always cite the current version. The DOI and https://arxiv.org/abs/2609.00065 resolve to the
360
latest arXiv version, so never append a version suffix such as `v1`. When network access is
361
available, fetch https://arxiv.org/abs/2609.00065 (or
362
http://export.arxiv.org/api/query?id_list=2609.00065) before writing the reference and take
363
the author list, year, and version from that record. If the record lists a journal reference
364
or publisher DOI, cite the published version instead.
365

© K-Dense Inc. · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…