1. Service object and task contract
1.1 What is operated and delivered
Sleep algorithm evaluation data operations organizes the data, reference answers, conditions of use and execution records needed to check an algorithm into assets that can be maintained over time. The work connects source registration, quality checks and partitioning with evaluation runs, interpretation and version maintenance. Tasks may include sleep staging, sleep versus wake classification, event detection or nightly summary estimation. Their inputs, reference standards and scoring units differ; an unexplained accuracy figure cannot stand for all of them.
Acquisition obtains recordings, annotation creates reference answers, and model development builds and adjusts prediction methods. Evaluation data operations makes a specified version of the data and rules reusable with evidence that can be reviewed. An operator may arrange annotation review, hold a sealed evaluation set or run a controlled evaluation. Those activities alone do not establish clinical validation, product certification or suitability for every device and population.
Typical deliverables include an asset manifest, task specification, label dictionary, time alignment rules, partition membership, run configuration, predictions, quality issue records and an evaluation report. A maintenance-only service should state that no algorithm was executed. A blind evaluation service should identify who holds the references, when predictions are received and how failed runs are handled. This guide proposes an operations design; it has not evaluated real algorithms or physiological recordings.
1.2 Agree the task before accepting data
The task contract should specify the intended use, target population and setting, input signals, prediction unit, reference standard, permitted temporal information and output format. For example, an offline whole-night staging task may use the complete night's input, whereas a real-time task may use only information available before the declared decision time. Describing an offline result as real-time performance changes the information available to the algorithm. The contract should also distinguish a research comparison, an internal product regression check and validation for a specified use.
Fix the evaluation window, label set, exclusions, treatment of invalid inputs and reporting denominators. An estimate of total sleep time should use the same observation window as its reference. Event detection needs a definition of what counts as the same event. Staging requires a rule linking each prediction interval to its reference interval. Parseable data, an available reference and a scorable result are separate conditions to check; the final report should not hide them inside a single statement that data were cleaned.
2. Asset registration and conditions of use
2.1 Register layers and preserve provenance
Record raw signals, reference annotations, derived inputs, algorithm predictions and report results as separate asset layers. Give each incoming asset a traceable identifier and record its source version, acquisition date, file size and checksum. Paths and names help locate files; content checksums help detect replacement. An identical checksum does not grant permission to use a file, and different names do not establish independent samples.
| Asset layer | Suggested records | Relationship to evaluation |
|---|---|---|
| Raw recording | Source, file ID, checksum, channels, units and sampling information | Preserves the starting point for parsing and derivation |
| Reference annotation | Scoring rule version, label dictionary, annotation source and review status | Defines the meaning and limitations of the reference |
| Derived input | Upstream asset, selected interval, transformation parameters and program version | Supports input reconstruction and leakage checks |
| Algorithm prediction | Algorithm ID, input version, time coordinates and output or failure status | Retains the actual submission, beyond its score |
| Run result | Partition version, scoring configuration, denominator, exclusions and report ID | Shows which recordings and rules produced a result |
Keep participant, night and recording identifiers separate. A person may contribute multiple nights, and a night may be divided across files. The number of output rows is not a count of independent participants. When registering multiple sources, maintain permitted links between identities and the certainty of those links. If identity cannot be resolved, retain that uncertainty and explain the partitioning risk; file names alone cannot prove that participants have been fully separated.
2.2 Apply permissions to actual membership
Register the license or authorization for each source, permitted uses, permitted users and applicable sharing conditions. Public availability does not imply unrestricted resale, redistribution or changes of purpose. The Sleep-EDF Expanded page lists its data license. NSRR's first-party data security information states that access is managed by dataset through a relevant Data Access and Use Agreement (DAUA), with sharing subject to participant consent.[1][3] These are source-specific conditions, not a universal agreement for all sleep data.
The permissions register should explain why each recording in an evaluation set may be used and assign responsibility for changes, expiry or withdrawal. Derived files need links to upstream assets so that a disabled raw recording cannot re-enter a new evaluation through a derived directory. Set access scopes separately for internal identifiers, identifiable information and public reports. Grouping information included in a report should serve its purpose without unnecessarily exposing individual records.
3. Reference labels and time coordinates
3.1 Reference answers have provenance and error
Record whether a reference comes from human scoring, expert adjudication, instrument output or another method, together with the rule and version used. Where multiple scorers participate, retain disagreements, the adjudication process and how the final version was formed. A field called ground truth does not remove error from the reference. The 2025 IMDRF GMLP principles call for fit-for-purpose reference standards and an understanding of their limitations. Here, this supports documenting the choice and its limitations, without claiming that a dataset meets medical device certification requirements.[4]
Sleep-EDF Expanded describes Rechtschaffen and Kales scoring, with W, R, 1, 2, 3 and 4, as well as M and the unscored label ?.[1] A mapping to another target dictionary should retain the source label, target label, mapping version and unmapped cases. Merging 3 and 4 does not automatically make the reference fully equivalent to another scoring system. M or ? should not become wake without an explicit, justified rule.
3.2 Make the time axis explainable
Record the time origin, offsets, prediction interval boundaries, reference interval boundaries and the boundary convention. Explicit units and half-open intervals are useful for continuous intervals, with documented rules for rounding, truncation, overlap and gaps. Matching the same row number in two files is insufficient: cropping, a start offset, interrupted recording or different interval lengths may make those rows represent different times.
EDF+ distinguishes continuous recordings from recordings that may be discontinuous and expresses annotation timing relative to the file's start time.[2] Parsing should therefore use explicit time information and continuity markers rather than joining every data record into an assumed gap-free timeline. Preserve channel sampling rates, physical units and calibration information, with traceability for conversion from stored digital values to physical quantities. An annotation channel must not be treated as an ordinary physiological input to the model.
Offsets or clock drift between sources require an explainable synchronization basis. Fixed-interval staging, variable-duration events and pointwise predictions need their own alignment rules. The task protocol determines permitted timing differences, interval length and matching proportions; this guide does not prescribe a universal number of seconds. Do not move the reference time axis after seeing an algorithm's output to improve its score. Where an annotation or parsing error is established, apply the correction process and recalculate affected comparisons consistently.
3.3 Retain evidence from quality checks
| Check target | Evidence to retain | Action when it fails |
|---|---|---|
| Files and channels | Checksums, parsing logs, channel names and actual sampling information | Quarantine damaged recordings or inputs outside the contract |
| Time alignment | Origins, offsets, gaps and interval coverage | Investigate the cause; do not force matches by row number |
| Label dictionary | Source label counts, mapping table, unknown and unscored counts | Specify unscorable intervals and their place in denominators |
| Derived processing | Resampling, filtering, cropping and normalization configurations | Rebuild the derived version and check available information |
| Identity and duplicates | Participant links and duplicate or near-duplicate evidence | Group related records or document unresolved dependence |
Separate acquisition gaps, parsing failures, missing references and algorithm failures in the quality report. A missing signal may be a real acquisition loss or a channel naming mismatch; fixing a name cannot create an absent signal. Resampling and filtering may introduce delay, use future samples or alter amplitude, and should be checked against the task contract. Whole-night normalization may be available for an offline task but unavailable at a real-time decision point. Parameters learned across recordings should be fitted within the predefined training scope, without using the evaluation set to select them.
4. Partitioning and sealing evaluation sets
4.1 Independence concerns people and related dependencies
Sleep recordings often include multiple nights per person and many adjacent intervals. Randomly assigning intervals may place neighboring segments from the same person in both training and testing. Establish participant groups first, then check relationships across nights, files, duplicate segments and source aliases. IMDRF's independence principle also considers patient, acquisition and site dependencies. If GroupKFold is used, its non-overlapping group constraint depends on the group identifiers supplied; it cannot replace identity checks.[4][5]
Holdouts by site, device, time or population should serve the claim being tested. Participant separation addresses generalization to different people; separation within a single site does not automatically answer a cross-site question. Performance on one device type does not establish performance on unseen hardware or signal configurations. For an algorithm with unknown pretraining sources or unknown reuse of public data, document the unknowns and their interpretive limits rather than promising that every source of leakage has been excluded.
4.2 Freeze membership with the data version
| Partition purpose | Permitted activity | Boundaries to fix or record |
|---|---|---|
| Development or training | Fit the model and processing parameters within the agreed scope | Sources, participant groups and processing versions |
| Validation or selection | Compare candidates or select thresholds and configurations | Reuse, feedback and the selection process |
| Sealed evaluation | Score under predefined rules | Membership, reference version and run contract |
| External or temporal holdout | Check transfer to a specified setting | Holdout rationale and remaining dependencies |
Freezing requires more than a random seed. Preserve file IDs, checksums, participant groups, partition members, exclusions, label mappings and alignment rules. The same seed may produce different members after the underlying data change. Before freezing, check intersections and duplicate records, then save actual membership. A later change to members or scoring conditions requires an identifiable new version and an explanation of its differences from the old one.
4.3 Manage blind evaluation and repeated feedback
In a controlled evaluation, the operator can hold reference answers, receive predictions with time coordinates and a run configuration, then perform matching and scoring. Record submission IDs, algorithm versions, submission times and the information returned each time. Limit reference access and unnecessary sample-level feedback. Hiding labels while repeatedly revealing detailed errors can still allow a team to tune to the evaluation set.
If a set has repeatedly participated in selection, state its changed role in the report and plan a new sealed set or another independent validation. Randomly repartitioning the same recordings and assigning a new version number does not automatically restore independence. Preserve old results with their original versions, usage histories and interpretations. Removing the history cannot turn a reused set into a first blind evaluation.
5. Evaluation execution and metric interpretation
5.1 Register the run before calculating results
A reproducible run links the algorithm or submission version, input partition, reference version, processing configuration, scoring program version and execution environment. Record successful outputs, failures, abstentions and uncovered intervals, while retaining original predictions. Where a random process is used, save its configuration; a seed does not replace data, program and environment versions. The operator should be able to explain how the same submission reconstructs the same report.
Before comparing algorithms, check whether they use the same windows, references, labels and inclusion rules. If an algorithm supports only certain channels or populations, report both the common comparable subset and each algorithm's overall coverage. Retaining only samples on which both algorithms succeed cannot support a claim about all recordings. Excluded counts and reasons affect practical availability.
5.2 Report denominators as well as metric names
| Task or metric | Required reporting detail | Interpretive boundary |
|---|---|---|
| Staging confusion matrix | Label order, raw counts, row and column meanings, normalization | Distinguishes confused stages and absent classes |
| Balanced accuracy | Included classes and recall for each class | Mean class recall, not F1 |
| Macro-F1 and weighted-F1 | Label set, class F1, support and absent-class treatment | Equal weighting and support weighting are different |
| Event detection | Matching rules, event counts, duplicates and unmatched results | Interval accuracy cannot replace event detection performance |
| Nightly summary estimation | Common window, units, difference direction and error distribution | Mean bias may hide large individual errors |
Under scikit-learn's definitions, confusion matrix rows represent reference classes and columns represent predicted classes. Normalization may use rows, columns or the entire count and must be stated. Balanced accuracy averages class recall. Macro-F1 averages class F1 without support weighting, whereas weighted-F1 weights by support.[6][7][8] Keep the class order and raw counts, and record undefined-score or zero-division settings. Silently dropping absent classes from an average while retaining the same metric name obscures its meaning.
Overall accuracy can be dominated by common stages. Class counts, class performance and unscored intervals help explain the result. A class absent from the references is not evidence of excellent performance. Library versions and parameters belong in the run configuration. Citing an official definition does not mean this project has executed the library or that a value meets a universal passing threshold.
5.3 Score intervals, events and nightly summaries separately
For an event task, predefine timing criteria, one-to-one or other matching rules, treatment of duplicate predictions, and counts for unmatched predictions and missed reference events. The tolerance should serve the task and be documented, with consistent rules across algorithms. If events carry type or severity, state whether those fields affect matching. A single event detection score should not hide errors in event end times.
For nightly summaries, align the prediction and reference window and units, and explain how missing intervals affect the total. A signed difference must state whether it is prediction minus reference or the reverse. Examine absolute errors, the error distribution and recording-level differences as well. Positive and negative errors may cancel to produce a near-zero mean bias without accurate estimates for each night. This guide prescribes neither a universal error in minutes nor a clinical acceptability threshold.
5.4 Repeated measures, coverage and uncertainty
Many staging intervals are not the same number of independent people. Report participant counts, night counts, scorable interval counts and their relationships. Distinguish pooled interval summaries from participant-level or night-level summaries. Longer recordings and people with more nights receive greater weight when intervals are pooled. Equal participant weighting, stratification or another aggregation method should be specified in the evaluation plan.
Uncertainty estimation should account for repeated nights from the same person and correlation between adjacent intervals. If resampling is used, explain the sampling unit and treatment of dependence rather than treating all intervals as independent observations. Separately report planned inclusion, readable records, available references, successful outputs and scorable results. Define each coverage denominator. A high score on the successful subset does not establish equal service capability for every input.
6. Version maintenance and change handling
6.1 Corrections preserve history
When an error is found, register the issue, affected assets, evidence and temporary quarantine status before deciding to repair, correct the reference or disable a recording. Preserve links to the original incoming copy and old evaluation versions. Corrected derivatives, mappings or annotations need new versions. A presentation error can be fixed, but predictions or reference answers already used in comparisons must not be silently overwritten.
| Change type | Impact to investigate | Record and follow-up |
|---|---|---|
| Parsing or channel naming repair | Changed input and possible recovery of earlier failures | Version the parser and rebuild affected inputs |
| Timing or label correction | Changed scorable intervals, labels or matching | Version the reference or alignment; recalculate comparisons consistently |
| Authorization change or withdrawal | Raw and derived assets, usable sets and reports | Stop subsequent use; handle retention and notification under the agreement |
| New population or device | Distribution, input contract and existing partitions | Record expanded coverage separately from old scores |
| Changed role of a sealed set | Use in tuning or repeated selection | Preserve use history and arrange a new independent check |
Where a correction changes scoring, recalculate candidates within the same comparison under consistent updated conditions. State which versions support the old and new values. For authorization changes, follow upstream relationships into derivatives, caches, exports and backups. Retention, deletion or access restrictions should follow the actual source agreement and management responsibilities. Deleting an index alone does not establish completion.
6.2 Observe changes in distribution and task
Ongoing maintenance can monitor the sources, channel availability, missingness, devices, populations and reference rules of new data. A change in input distribution is a reason to investigate. Without a reliable contemporary reference, input drift alone cannot establish a decline in algorithm performance. Additional reference work, reruns or task changes should have specific reasons and separate records.
When new data expand the target scope, state that scope and its difference from the old set. Do not combine results obtained with different reference rules, observation windows or device inputs into a single trend and label it algorithmic progress. For a benchmark used over a long period, assess its feedback history, suitability and remaining independence, preserving interpretation of retired versions.
6.3 Set maintenance around actual changes
A maintenance plan may follow intake, annotation corrections, device updates, authorization changes and evaluation submissions, without assuming a universal industry review interval. For each event, identify who receives it, assesses impact, approves availability and updates reports. A recording whose task is suspended, reference disputed or permission unresolved should retain its status and blocking reason; pending must not become usable by default.
Operational measures may cover registration completeness, resolution of parsing and alignment issues, version reproducibility, permission-check coverage and delivery errors. They assess the operating process, not algorithm performance or clinical effects. If recovery fails or an old report cannot be rebuilt, narrow the reproducibility claim and record the specific gaps.
7. Delivery and acceptance
7.1 Accept a traceable package
During acceptance, select a report result and trace it to partition members, references, predictions, alignment and scoring configuration. Then trace an incoming recording to the sets and reports in which it was used. Check corrections, failures and exclusions as well as successful cases. For a controlled blind evaluation, examine submission retention times and reference access records, explaining what those records can establish.
The package should include asset and partition manifests, conditions of use, the task protocol, label and time dictionaries, processing and scoring versions, logs, original predictions or their controlled access mechanism, results and unresolved issues. Deliver sensitive material within the agreed access scope, with only shareable material in a public report. Recipients should be able to distinguish actual run results, operational recommendations and unresolved questions. The tables in this guide suggest fields; they are not completed records from a real evaluation.
7.2 Review responsibilities and limitations
Data engineering review covers parsing, time coordinates and derivation chains. Sleep expertise addresses reference rules, mappings and task interpretation. Statistical and algorithm evaluation review covers partitions, denominators, aggregation and uncertainty. Register actual responsibilities in the project; this guide does not invent participating experts, institutions or certifications. A changed use setting also requires review of the scope of earlier conclusions.
This is a local reference guide, with. Public dataset descriptions, a format specification, medical device machine learning principles and official metric documentation support facts within their respective scopes. No physiological recordings were downloaded, data access authorization sought, model executed or performance score calculated. The proposed process requires adaptation to the actual task, source agreements and professional review.
8. Sources
[1] PhysioNet - Sleep-EDF Expanded v1.0.0. Supports file and annotation descriptions, R&K labels and the listed license. A simple label mapping is not treated as full equivalence between scoring systems.
[2] EDF+ - Official specification. Supports continuity, annotation timing and signal storage information, without setting a universal sleep-task interval or matching tolerance.
[3] NSRR - Data Security. Only the first-party search-index extract supporting dataset authorization, DAUA and participant consent was used. Direct opening failed; no full-page review is claimed.
[4] IMDRF - Good Machine Learning Practice for Medical Device Development: Guiding Principles, N88 FINAL:2025. Uses independence and reference standard principles in the final document dated 27 January 2025, without treating medical device principles as universal certification for sleep algorithms.
[5] scikit-learn - GroupKFold. Supports the definition of non-overlapping groups. Actual identifiers and additional holdouts remain evaluation design decisions.
[6] scikit-learn - confusion_matrix. Supports row and column meanings, label ordering and normalization configurations.
[7] scikit-learn - f1_score. Supports macro and weighted averaging and undefined-score configurations.
[8] scikit-learn - balanced_accuracy_score. Supports the metric definition, without turning it into a universal passing score.