diff --git a/src/modality-specific-files/task-events.md b/src/modality-specific-files/task-events.md index 0fb6ec2a52..9b0ffa69f3 100644 --- a/src/modality-specific-files/task-events.md +++ b/src/modality-specific-files/task-events.md @@ -42,6 +42,8 @@ and a guide for using macros can be found at --> {{ MACROS___make_columns_table("task.TaskEvents") }} +The content of `events.tsv` files SHOULD be sorted by values in the `onset` column. + Note for MRI data: If any acquired scans have been discarded before forming the imaging data file, ensure that an `onset` of 0 corresponds to the time the first image was stored. diff --git a/src/schema/rules/checks/events.yaml b/src/schema/rules/checks/events.yaml index cd8fd414bd..1d6c52584c 100644 --- a/src/schema/rules/checks/events.yaml +++ b/src/schema/rules/checks/events.yaml @@ -27,3 +27,16 @@ StimulusFileMissing: - columns.stim_file != null checks: - exists(columns.stim_file, "stimuli") == length(columns.stim_file) - count(columns.stim_file, "n/a") + +SortedOnsets: + issue: + code: EVENT_ONSET_ORDER + message: | + The onset column in events.tsv files should be sorted. + level: warning + selectors: + - suffix == "events" + - extension == ".tsv" + checks: + # n/a values will likely cause false alarms if encountered. Consider alternatives. + - sorted(columns.onset) == columns.onset