|
1 | 1 | # 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 | +{.only-dark align=center} |
| 32 | +{.only-light align=center} |
| 34 | + |
| 35 | +{.only-dark align=center} |
| 37 | +{.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. | |
0 commit comments