Skip to content

Commit a6f8669

Browse files
authored
Merge branch 'master' into expand-acq-definition
2 parents 27e098e + 9854498 commit a6f8669

File tree

6 files changed

+81
-6
lines changed

6 files changed

+81
-6
lines changed

src/schema/meta/context.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ properties:
316316
- xyzt_units
317317
- qform_code
318318
- sform_code
319+
- axis_codes
319320
additionalProperties: false
320321
properties:
321322
dim_info:
@@ -404,6 +405,17 @@ properties:
404405
name: 'sform code'
405406
description: 'Use of the affine fields.'
406407
type: integer
408+
axis_codes:
409+
name: 'axis codes'
410+
description: >
411+
Orientation labels indicating primary direction of data axes defined
412+
with respect to the object of interest.
413+
type: array
414+
minItems: 3
415+
maxItems: 3
416+
items:
417+
type: string
418+
enum: ['R', 'L', 'A', 'P', 'S', 'I']
407419
mrs:
408420
name: 'NIfTI-MRS extension'
409421
description: 'NIfTI-MRS JSON fields'

src/schema/objects/entities.yaml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,23 @@ direction:
8383
This entity represents the `"PhaseEncodingDirection"` metadata field.
8484
Therefore, if the `dir-<label>` entity is present in a filename,
8585
`"PhaseEncodingDirection"` MUST be defined in the associated metadata.
86-
Please note that the `<label>` does not need to match the actual value of the field.
86+
87+
Labels need not follow any particular convention and in case of conflict,
88+
JSON metadata MUST take precedence in interpreting an image.
89+
90+
For example, `dir-j0` and `dir-j1` can indicate `"PhaseEncodingDirection": "j"` and `"j-"` (or vice versa),
91+
identifying the phase-encoding axis while avoiding indicating polarity.
92+
However, in case of a dataset indicating `dir-j0` with `"PhaseEncodingDirection": "i"`, the
93+
JSON metadata overrides the entity `dir-` setting.
94+
95+
The use of generic labels, such as `dir-reference` and `dir-reversed`, is RECOMMENDED
96+
to avoid any possible inconsistency.
97+
98+
To avoid inconsistency, if the `<label>` is `AP`, `PA`, `LR`, `RL`, `SI`, or `IS`,
99+
then the `"PhaseEncodingDirection"` SHOULD correspond to the data
100+
axis that most closely aligns with the cardinal direction and orientation.
101+
For example, `dir-PA` and `dir-AP` for an image in RAS+ orientation SHOULD have
102+
`"PhaseEncodingDirection": "j"` and `"j-"`, respectively.
87103
type: string
88104
format: label
89105
echo:

src/schema/rules/checks/nifti.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,19 @@ XformCodes0:
4949
- nifti_header != null
5050
checks:
5151
- nifti_header.qform_code != 0 || nifti_header.sform_code != 0
52+
53+
NiftiPEDir:
54+
issue:
55+
code: NIFTI_PE_DIRECTION_CONSISTENCY
56+
message: |
57+
The PhaseEncodingDirection and affine orientation indicate
58+
that the entity value (one of AP, PA, RL, LR, SI, IS) may be inaccurate.
59+
level: warning
60+
selectors:
61+
- type(nifti_header.axis_codes) != "null"
62+
- intersects([entities.direction], ["AP", "PA", "RL", "LR", "SI", "IS"])
63+
- sidecar.PhaseEncodingDirection
64+
checks:
65+
- |
66+
entities.direction[2 - length(sidecar.PhaseEncodingDirection)]
67+
== nifti_header.axis_codes[index(["i", "j", "k"], sidecar.PhaseEncodingDirection[0])]

src/schema/rules/files/deriv/preprocessed_data.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,21 @@ anat_defacemask_common:
2626
space: optional
2727
description: optional
2828

29-
anat_multiecho_common:
29+
anat_megre_common:
3030
selectors:
3131
- dataset.dataset_description.DatasetType == 'derivative'
32-
$ref: rules.files.raw.anat.multiecho
32+
$ref: rules.files.raw.anat.megre
3333
entities:
34-
$ref: rules.files.raw.anat.multiecho.entities
34+
$ref: rules.files.raw.anat.megre.entities
35+
space: optional
36+
description: optional
37+
38+
anat_mese_common:
39+
selectors:
40+
- dataset.dataset_description.DatasetType == 'derivative'
41+
$ref: rules.files.raw.anat.mese
42+
entities:
43+
$ref: rules.files.raw.anat.mese.entities
3544
space: optional
3645
description: optional
3746

src/schema/rules/files/raw/anat.yaml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ defacemask:
8585
modality: optional
8686
chunk: optional
8787

88-
multiecho:
88+
megre:
8989
suffixes:
90-
- MESE
9190
- MEGRE
9291
extensions:
9392
- .nii.gz
@@ -107,6 +106,28 @@ multiecho:
107106
part: optional
108107
chunk: optional
109108

109+
mese:
110+
suffixes:
111+
- MESE
112+
extensions:
113+
- .nii.gz
114+
- .nii
115+
- .json
116+
datatypes:
117+
- anat
118+
entities:
119+
subject: required
120+
session: optional
121+
task: optional
122+
acquisition: optional
123+
ceagent: optional
124+
reconstruction: optional
125+
direction: optional
126+
run: optional
127+
echo: required
128+
part: optional
129+
chunk: optional
130+
110131
multiflip:
111132
suffixes:
112133
- VFA

tools/schemacode/tests/test_context_types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def test_assignability() -> None:
7575
xyzt_units=xyzt_units,
7676
qform_code=1,
7777
sform_code=1,
78+
axis_codes=("L", "P", "S"),
7879
)
7980

8081
ome: p.Ome = ctx.Ome()

0 commit comments

Comments
 (0)