Headcode / How it works

Understanding Your Fatigue Score

Headcode uses the HSE Fatigue Risk Index — a biomathematical model developed for the Health & Safety Executive by sleep researchers at Loughborough University. Here is what the numbers mean and how they are calculated.

The Fatigue Index (FI)

The Fatigue Index is a number from 0 to 100 representing the estimated probability (%) that a worker would feel “very fatigued” during a shift. It is based on how the human sleep-wake system responds to different working patterns.

In practice, realistic scores for train drivers sit between about 15 and 65. A score of 100 would mean fatigued on every shift — it is a theoretical ceiling.

15–24
Low
Below all thresholds
25–34
Moderate
Approaching daytime flag
35–44
High
Above daytime flag (>35)
45+
Very High
Above nighttime flag (>45)
Flag thresholds come from HSL’s 2008 evaluation of the FRI. They are the points at which research shows meaningful increases in fatigue-related risk. “Daytime” means shifts starting after 07:00; “nighttime” means shifts starting in the early morning or finishing past midnight.

How the Score is Built

Every FI score is the sum of three components. Each contributes a value roughly between 0 and 0.20, and together they add up to the final index.

A — Cumulative Component

This is the dominant factor. It models the build-up of sleep debt across consecutive shifts using the RKFit biomathematical model (Kronauer & Czeisler) averaged with an empirical aircrew fatigue model.

The model tracks a “Psychomotor Vigilance Test” (PVT) score night by night — a validated proxy for cognitive performance. It degrades with sleep loss and recovers with rest. Critically, it has memory: the fatigue from Monday’s early start affects Tuesday’s score even if Tuesday is a later shift.

B — Circadian Component

This captures the time-of-day effect using a cosine function applied at the midpoint of the shift. The human circadian rhythm has a performance nadir (lowest point) between approximately 02:00 and 05:00 — the same window when most serious rail incidents occur. A 04:00 start scores significantly higher on this component than a 09:00 start of identical length.

C — Job Type Component

This reflects workload, attention demand, and break quality. Train driving is classified as safety-critical with continuous attention required. In estimated mode, break durations are derived from your T&Cs (30–45 minutes PNB by shift length). In enhanced mode, actual PNB times, additional breaks, and longest continuous driving blocks from your harvested job detail are used.

How Bedtime is Estimated

The cumulative model needs to know how much sleep a driver gets between shifts. Since it cannot access your actual sleep data, it estimates your likely bedtime using a formula from empirical research on shift worker sleep patterns:

Bedtime estimation formula (RKFit model)
Formula
bedtime = 16.3 + (0.367 × shift end hour)
Finish 07:30
16.3 + (0.367 × 7.5) = ~19:05
Finish 15:30
16.3 + (0.367 × 15.5) = ~22:00
Finish 23:30
16.3 + (0.367 × 23.5) = ~00:55
Night finish (>00:15)
bedtime = shift end + 1h (recovery buffer)

The formula reflects the real-world pattern that shift workers do not go straight to bed when they get home — there is a wind-down period that scales with time of day. An afternoon finish produces a bedtime around 22:00 because people follow their normal evening routine. A late finish compresses the sleep window from both ends: bedtime is pushed later, and the next alarm is fixed.

Once bedtime is estimated, the model calculates how much sleep is possible before the next sign-on, then compares that against the population target of 8.07 hours. The shortfall becomes the sleep loss value that drives PVT degradation.

Commute assumption: The model adds 40 minutes each way for commuting — shifting effective finish time forward and effective start time back when calculating available sleep. This is the default in the original HSE workbook. If your commute is significantly longer, your actual sleep loss will be higher than the model estimates.

Worked Example

Two shifts from the same imaginary week. Monday is a straightforward afternoon turn after a rest day. Tuesday starts at 04:52 following Monday’s finish at 15:30 — giving a compliant 13h 22m rest gap, but the early start and accumulated sleep debt still push the score up sharply.

Monday — SS 34 — 07:12 – 15:30 — 8.3h — after two rest days
A) Cumulative (sleep debt)
Well-rested after two days off. PVT close to baseline (3.85). Sleep loss minimal.
0.031
B) Circadian (time of day)
Midpoint ~11:21 — mid-morning, comfortably clear of the nadir window.
0.057
C) Job type (breaks)
30 min PNB, standard train driving workload and attention level.
0.195
Fatigue Index
0.031 + 0.057 + 0.195 = 0.283 × 100
28
Tuesday — SS 1 — 04:52 – 12:52 — 8.0h — 13h 22m rest after Monday
A) Cumulative (sleep debt)
Monday finished at 15:30. The RKFit model estimates bedtime as 16.3 + (0.367 × 15.5) = ~22:00, reflecting typical wind-down time after an afternoon shift. Waking for a 04:52 sign-on means roughly 5.5h sleep — well below the 8h norm. PVT has dropped to 3.61.
0.158
B) Circadian (time of day)
Midpoint ~08:52 — shift starts inside the circadian nadir window (02:00–06:00).
0.097
C) Job type (breaks)
30 min PNB, standard train driving workload.
0.195
Fatigue Index
0.158 + 0.097 + 0.195 = 0.450 × 100
45

The same driver goes from FI 28 on Monday to FI 45 on Tuesday — right at the nighttime flag threshold — with a fully compliant 13h 22m rest gap between the two shifts. The rest gap is legal. The score is high anyway. This is the core insight of the FRI: compliance with minimum rest rules does not guarantee low fatigue, particularly when an afternoon finish is followed by an early morning start the next day.

The Risk Index (RI)

The Risk Index expresses your cumulative fatigue component relative to a standard reference roster. An RI of 1.0 means your schedule carries the same cumulative fatigue risk as the reference. An RI of 2.0 means twice the reference risk.

The reference roster used in the original HSE research is a standard shift pattern common in industries like healthcare and emergency services:

DayShiftHours
Day 1Day shift07:00 – 19:00 (12h)
Day 2Day shift07:00 – 19:00 (12h)
Day 3Night shift19:00 – 07:00 (12h)
Day 4Night shift19:00 – 07:00 (12h)
Days 5–8Rest
RI above 1.6 is considered elevated in the research literature. This means 60% more cumulative fatigue risk than the reference. Headcode flags this in the Key Fatigue Drivers section.

Two Ways to Upload

Standard

CSV Only

Export your work plan from TRACS and upload it directly. Headcode derives break times from your T&C agreement (PNB by shift length). Good for a quick overview.

  • Works on any device
  • No script required
  • PNB and breaks are estimated
  • Continuous driving not checked

Running the Harvester — Step by Step

01

Log in to TRACS Enterprise on a desktop browser

The harvester works in Chrome, Firefox, Edge, and Safari. It does not work on mobile. Make sure you are already logged in to TRACS before continuing.

02

Navigate to your Work Plan and set your date range

Open the Work Plan section in TRACS. Set the date range you want to analyse — this should match the period you want to export. The harvester will only capture shifts visible on screen.

03

Open the browser console

This is a built-in developer tool in every desktop browser. It sounds technical but it is just a text input where you paste a single line.

  • Chrome (Windows/Mac): Press F12, then click the Console tab
  • Firefox (Windows): Press F12, then click Console
  • Firefox (Mac): Press Cmd + Option + K, then click Console
  • Safari (Mac): First enable developer tools in Safari → Settings → Advanced → “Show Develop menu”, then press Cmd + Option + C
  • Edge: Press F12, then click Console

You should see a flashing cursor at the bottom of the console panel. If you see a warning about pasting, type allow pasting and press Enter first, then continue.

04

Paste and run the harvester script

Copy the line below, paste it into the console, and press Enter. Do not close the browser tab while it runs.

var s=document.createElement('script');s.src='https://headcode.uk/harvester.js?bust='+Date.now();document.body.appendChild(s);

You will see log messages appearing in the console as it works through each shift. For a full year this typically takes 2–4 minutes.

05

Two files will download automatically

When the harvester finishes it downloads headcode-harvest.json and then automatically triggers the CSV export from TRACS. Both files will appear in your downloads folder. If the CSV does not download automatically, click Export to CSV on the TRACS page manually.

06

Upload both files to Headcode

Go to the Fatigue Analyser and drop both files onto the upload zone at the same time, or use the two file inputs to select them separately. The analyser will detect both files and run in enhanced mode.

Privacy: The harvester runs entirely within your existing browser session on the TRACS page. It uses your login to fetch job detail pages you already have access to — the same pages you can view manually. No data is sent to Headcode or any third party. The two files download directly to your device and all analysis happens locally in your browser.

Source & Limitations

The FRI algorithm is a faithful JavaScript translation of the VBA spreadsheet published by the Health & Safety Executive (Crown Copyright 2005, Version 2.3), based on research by Folkard, Lombardi & Tucker published as HSE Research Report RR446 (2006). The biomathematical constants are taken directly from the published workbook.

Headcode applies the model to train driving using fixed parameters for safety-critical, continuous-attention roles. In enhanced mode, actual job data replaces these defaults where available.

Limitations to be aware of:

This is not an official FRI assessment. Headcode is an independent tool for informational purposes. It does not constitute medical or legal advice. If you have concerns about your fatigue levels or your employer’s rostering practices, speak to your union representative, occupational health, or the ORR’s confidential reporting line.