Skip to content

Commit 5e7d3c4

Browse files
committed
Merge remote-tracking branch 'upstream/main' into dev
2 parents b9adda9 + 6a43747 commit 5e7d3c4

16 files changed

+1932
-2328
lines changed

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
2+
<a id='changelog-"2.0.6"'></a>
3+
# "2.0.6" — 2025-05-23
4+
5+
## Added
6+
7+
- Explain the issue data fields in the documentation. ([#199])
8+
9+
[#199]: https://github.com/bids-standard/bids-validator/pull/199
10+
11+
## Changed
12+
13+
- Validator now returns exit code 16 instead of 1 for validation of a dataset with errors.
14+
15+
- Rely on `schema.meta.associations` to load context associations instead of relying on list maintained in validator.
16+
17+
## Fixed
18+
19+
- Sidecar checks are skipped for text files that should not have sidecars.
20+
This resolves a problem in derivative datasets, where BIDS specifies a
21+
RECOMMENDED field of `Description` in all derivative files. ([#202])
22+
23+
[#202]: https://github.com/bids-standard/bids-validator/issues/202
124
<a id='changelog-2.0.4'></a>
225
# 2.0.5 — 2025-03-31
326

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
},
2929
"imports": {
3030
"@ajv": "npm:[email protected]",
31-
"@bids/schema": "jsr:@bids/[email protected].12+78213dcf",
31+
"@bids/schema": "jsr:@bids/schema@^1.1.0-dev.16+a7dd34ad",
3232
"@cliffy/command": "jsr:@effigies/[email protected]",
3333
"@cliffy/table": "jsr:@effigies/[email protected]",
3434
"@hed/validator": "npm:[email protected]",

deno.lock

Lines changed: 12 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
28.6 KB
Loading
27 KB
Loading
24.7 KB
Loading
23.2 KB
Loading

docs/user_guide/issues.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,119 @@
11
# Understanding issues
2+
3+
BIDS Validator issues are structured results that describe problems or potential
4+
problems in the dataset.
5+
Issues can either be warnings or errors.
6+
7+
Errors are emitted when a violation of the BIDS specification is detected,
8+
or, in some cases, the validator is unable to read part of the dataset.
9+
Errors must be resolved in order for a dataset to be considered valid.
10+
11+
Warnings are emitted when BIDS specification recommendations are not followed,
12+
as well as cases where a common problem may be present, and user attention
13+
is needed to verify the validity of the dataset.
14+
15+
## Issue model
16+
17+
Every issue has a code indicating the issue type, a location indicating
18+
the file where the issue was detected, and a severity field that can
19+
either be "warning" or "error".
20+
If some issues are configured to be ignored, in JSON output mode they would still be listed and
21+
have severity "ignore".
22+
23+
| `code` | `location` | `severity` |
24+
| ------------------------- | -------------------------------- | ---------- |
25+
| `NIFTI_HEADER_UNREADABLE` | `/sub-01/anat/sub-01_T1w.nii.gz` | `error` |
26+
| `README_FILE_SMALL` | `/README` | `warning` |
27+
28+
In the web validator, these issues appear as:
29+
30+
![A NIFTI_HEADER_UNREADABLE error in the web validator. (Dark theme)
31+
](../_static/example_error_dark.png){.only-dark align=center}
32+
![A NIFTI_HEADER_UNREADABLE error in the web validator. (Light theme)
33+
](../_static/example_error_light.png){.only-light align=center}
34+
35+
![A README_FILE_SMALL warning in the web validator. (Dark theme)
36+
](../_static/example_warning_dark.png){.only-dark align=center}
37+
![A README_FILE_SMALL warning in the web validator. (Light theme)
38+
](../_static/example_warning_light.png){.only-light align=center}
39+
40+
In the command-line validator, these would be rendered as:
41+
42+
```console
43+
[WARNING] README_FILE_SMALL The recommended file '/README' is very small.
44+
Please consider expanding it with additional information about the dataset.
45+
46+
/README
47+
48+
[ERROR] NIFTI_HEADER_UNREADABLE We were unable to parse header data from this NIfTI file.
49+
Please ensure it is not corrupted or mislabeled.
50+
/sub-01/anat/sub-01_T1w.nii.gz
51+
/sub-02/anat/sub-02_T1w.nii.gz
52+
```
53+
54+
### Subcodes
55+
56+
Some classes of issue can be found many times, even in the same file.
57+
For example, invalid sidecar metadata,
58+
such as using `"MagneticFieldStrength": "3T"` instead of `"MagneticFieldStrength": 3`,
59+
triggers a `JSON_SCHEMA_VALIDATION_ERROR` because the value must be numeric rather
60+
than textual.
61+
62+
Consider the following issues:
63+
64+
| `code` | `subcode` | `location` | `severity` |
65+
| ------------------------------ | ----------------------- | ---------------------------------------- | ---------- |
66+
| `JSON_SCHEMA_VALIDATION_ERROR` | `MagneticFieldStrength` | `/T1w.json` | `error` |
67+
| `JSON_KEY_REQUIRED` | `BIDSVersion` | `/dataset_description.json` | `error` |
68+
| `JSON_KEY_RECOMMENDED` | `GeneratedBy` | `/dataset_description.json` | `warning` |
69+
| `SIDECAR_KEY_REQUIRED` | `RepetitionTime` | `/sub-01/func/sub-01_task-rest_bold.nii` | `error` |
70+
| `SIDECAR_KEY_RECOMMENDED` | `EchoTime` | `/sub-01/func/sub-01_task-rest_bold.nii` | `warning` |
71+
72+
Each of these issue codes are general, and the subcode indicates the specific
73+
JSON field that is missing or invalid.
74+
75+
Note that, when a value is absent or invalid in a specific file,
76+
the location is the JSON file can be listed.
77+
For example, the invalid `MagneticFieldStrength` may affect many `*_T1w.nii.gz` files,
78+
but it can be found in a single file.
79+
On the other hand, for missing sidecar keys, the [inheritance principle](../validation-model/index.md)
80+
permits the data to be defined in multiple files.
81+
82+
### All fields
83+
84+
The validator defines the following fields for issues:
85+
86+
| Field | Type | Description |
87+
| -------------- | ---------- | ------------------------------------------------------------------------ |
88+
| `code` | `string` | The type of issue detected |
89+
| `subCode` | `string` | For some `code`s, additional information to narrow the issue type |
90+
| `severity` | `string` | `"error"`, `"warning"` or `"ignore"` |
91+
| `location` | `string` | A path to the file in the dataset where the error occurs. |
92+
| `issueMessage` | `string` | A human-readable description of the issue. |
93+
| `suggestion` | `string` | A suggestion for a plausible fix. |
94+
| `affects` | `string[]` | A list of files affected by the error, if more than `location`. |
95+
| `rule` | `string` | The rule ID in the BIDS schema that failed to pass. |
96+
| `line` | `number` | The line number (0-indexed) in `location` that triggered the issue. |
97+
| `character` | `number` | The character column (0-indexed) in `location` that triggered the issue. |
98+
99+
All fields except `code`, `severity` and `location` are optional and may be
100+
absent from any issue.
101+
102+
## External validators
103+
104+
BIDS reuses many other data standards (see e.g. [BIDS Philosophy](https://bids.neuroimaging.io/index.html#philosophy) section).
105+
Where feasible, the BIDS Validator will call an external validator and
106+
expose its issues as BIDS issues.
107+
108+
### Hierarchical Event Descriptors (HED)
109+
110+
The HED validator produces issues of the following form:
111+
112+
| Field | Type | Description |
113+
| -------------- | ---------- | ------------------------------------------------------------------- |
114+
| `code` | `string` | `HED_WARNING` or `HED_ERROR` |
115+
| `subCode` | `string` | The `"hedCode"` emitted by the HED validator. |
116+
| `severity` | `string` | `"error"` or `"warning"` |
117+
| `location` | `string` | A path to the file in the dataset where the error occurs. |
118+
| `issueMessage` | `string` | A human-readable description of the issue. |
119+
| `line` | `number` | The line number (0-indexed) in `location` that triggered the issue. |

pdm_build.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ def pdm_build_initialize(context):
2727
"compile",
2828
"-ERNW",
2929
"--allow-run",
30+
# Types are checked elsewhere. Type checking at wheel build
31+
# is painful if some platforms have newer typescript than others.
32+
"--no-check",
3033
"-o",
3134
str(target),
3235
"src/bids-validator.ts",

src/bids-validator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ const result = await main()
44

55
const errors = result.issues.get({ severity: 'error' })
66
if (errors.length) {
7-
Deno.exit(1)
7+
Deno.exit(16)
88
}

0 commit comments

Comments
 (0)