Skip to content

Commit ef4a939

Browse files
authored
feat(schema): Move coordsystem.json rules out of rules.sidecars (#1892)
* feat(schema): Move coordsystem.json rules out of rules.sidecars * feat: Add make_json_table macro * feat(spec): Render coordsystem JSON tables * feat(metaschema): Add schema.rules.json
1 parent 0de4c9c commit ef4a939

File tree

17 files changed

+470
-379
lines changed

17 files changed

+470
-379
lines changed

src/metaschema.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,19 +386,25 @@
386386
"required": ["common", "deriv", "raw"],
387387
"additionalProperties": false
388388
},
389+
"json": {
390+
"type": "object",
391+
"additionalProperties": {
392+
"$ref": "#/definitions/json"
393+
}
394+
},
389395
"sidecars": {
390396
"type": "object",
391397
"patternProperties": {
392398
"^derivatives$": {
393399
"type": "object",
394400
"properties": {
395-
"common_derivatives": { "$ref": "#/definitions/sidecar" }
401+
"common_derivatives": { "$ref": "#/definitions/json" }
396402
},
397403
"required": ["common_derivatives"],
398404
"additionalProperties": false
399405
},
400406
"^(?!derivatives$)[a-z_]+$": {
401-
"$ref": "#/definitions/sidecar"
407+
"$ref": "#/definitions/json"
402408
},
403409
"additionalProperties": false
404410
},
@@ -476,6 +482,7 @@
476482
"required": [
477483
"entities",
478484
"files",
485+
"json",
479486
"sidecars",
480487
"tabular_data",
481488
"common_principles",
@@ -586,7 +593,7 @@
586593
}
587594
}
588595
},
589-
"sidecar": {
596+
"json": {
590597
"type": "object",
591598
"patternProperties": {
592599
"^[a-zA-Z0-9_]+$": {

src/modality-specific-files/electroencephalography.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ The definitions of the fields specified in these tables may be found in
390390
A guide for using macros can be found at
391391
https://github.com/bids-standard/bids-specification/blob/master/macros_doc.md
392392
-->
393-
{{ MACROS___make_sidecar_table("eeg.EEGCoordsystemGeneral") }}
393+
{{ MACROS___make_json_table("json.eeg.EEGCoordsystemGeneral") }}
394394

395395
Fields relating to the EEG electrode positions:
396396

@@ -402,7 +402,7 @@ The definitions of the fields specified in these tables may be found in
402402
A guide for using macros can be found at
403403
https://github.com/bids-standard/bids-specification/blob/master/macros_doc.md
404404
-->
405-
{{ MACROS___make_sidecar_table("eeg.EEGCoordsystemPositions") }}
405+
{{ MACROS___make_json_table("json.eeg.EEGCoordsystemPositions") }}
406406

407407
Fields relating to the position of fiducials measured during an EEG session/run:
408408

@@ -414,7 +414,7 @@ The definitions of the fields specified in these tables may be found in
414414
A guide for using macros can be found at
415415
https://github.com/bids-standard/bids-specification/blob/master/macros_doc.md
416416
-->
417-
{{ MACROS___make_sidecar_table("eeg.EEGCoordsystemFiducials") }}
417+
{{ MACROS___make_json_table("json.eeg.EEGCoordsystemFiducials") }}
418418

419419
Fields relating to the position of anatomical landmark measured during an EEG session/run:
420420

@@ -426,7 +426,7 @@ The definitions of the fields specified in these tables may be found in
426426
A guide for using macros can be found at
427427
https://github.com/bids-standard/bids-specification/blob/master/macros_doc.md
428428
-->
429-
{{ MACROS___make_sidecar_table(["eeg.EEGCoordsystemLandmark", "eeg.EEGCoordsystemLandmarkDescriptionRec"]) }}
429+
{{ MACROS___make_json_table(["json.eeg.EEGCoordsystemLandmark", "json.eeg.EEGCoordsystemLandmarkDescriptionRec"]) }}
430430

431431
If the position of anatomical landmarks is measured using the same system or
432432
device used to measure electrode positions, and if thereby the anatomical

src/modality-specific-files/intracranial-electroencephalography.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ The definitions of the fields specified in these tables may be found in
389389
A guide for using macros can be found at
390390
https://github.com/bids-standard/bids-specification/blob/master/macros_doc.md
391391
-->
392-
{{ MACROS___make_sidecar_table("ieeg.iEEGCoordsystemGeneral") }}
392+
{{ MACROS___make_json_table("json.ieeg.iEEGCoordsystemGeneral") }}
393393

394394
Fields relating to the iEEG electrode positions:
395395

@@ -401,7 +401,7 @@ The definitions of the fields specified in these tables may be found in
401401
A guide for using macros can be found at
402402
https://github.com/bids-standard/bids-specification/blob/master/macros_doc.md
403403
-->
404-
{{ MACROS___make_sidecar_table("ieeg.iEEGCoordsystemPositions") }}
404+
{{ MACROS___make_json_table("json.ieeg.iEEGCoordsystemPositions") }}
405405

406406
### Recommended 3D coordinate systems
407407

src/modality-specific-files/magnetoencephalography.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ The definitions of the fields specified in these tables may be found in
343343
A guide for using macros can be found at
344344
https://github.com/bids-standard/bids-specification/blob/master/macros_doc.md
345345
-->
346-
{{ MACROS___make_sidecar_table("meg.MEGCoordsystemWithEEG") }}
346+
{{ MACROS___make_json_table("json.meg.MEGCoordsystemWithEEG") }}
347347

348348
Head localization coils:
349349

@@ -355,7 +355,7 @@ The definitions of the fields specified in these tables may be found in
355355
A guide for using macros can be found at
356356
https://github.com/bids-standard/bids-specification/blob/master/macros_doc.md
357357
-->
358-
{{ MACROS___make_sidecar_table("meg.MEGCoordsystemHeadLocalizationCoils") }}
358+
{{ MACROS___make_json_table("json.meg.MEGCoordsystemHeadLocalizationCoils") }}
359359

360360
Digitized head points:
361361

@@ -367,7 +367,7 @@ The definitions of the fields specified in these tables may be found in
367367
A guide for using macros can be found at
368368
https://github.com/bids-standard/bids-specification/blob/master/macros_doc.md
369369
-->
370-
{{ MACROS___make_sidecar_table("meg.MEGCoordsystemDigitizedHeadPoints") }}
370+
{{ MACROS___make_json_table("json.meg.MEGCoordsystemDigitizedHeadPoints") }}
371371

372372
Anatomical MRI:
373373

@@ -379,7 +379,7 @@ The definitions of the fields specified in these tables may be found in
379379
A guide for using macros can be found at
380380
https://github.com/bids-standard/bids-specification/blob/master/macros_doc.md
381381
-->
382-
{{ MACROS___make_sidecar_table("meg.MEGCoordsystemAnatomicalMRI") }}
382+
{{ MACROS___make_json_table("json.meg.MEGCoordsystemAnatomicalMRI") }}
383383

384384
Anatomical landmarks:
385385

@@ -391,7 +391,7 @@ The definitions of the fields specified in these tables may be found in
391391
A guide for using macros can be found at
392392
https://github.com/bids-standard/bids-specification/blob/master/macros_doc.md
393393
-->
394-
{{ MACROS___make_sidecar_table("meg.MEGCoordsystemAnatomicalLandmarks") }}
394+
{{ MACROS___make_json_table("json.meg.MEGCoordsystemAnatomicalLandmarks") }}
395395

396396
It is also RECOMMENDED that the MRI voxel coordinates of the actual anatomical
397397
landmarks for co-registration of MEG with structural MRI are stored in the
@@ -419,7 +419,7 @@ The definitions of the fields specified in these tables may be found in
419419
A guide for using macros can be found at
420420
https://github.com/bids-standard/bids-specification/blob/master/macros_doc.md
421421
-->
422-
{{ MACROS___make_sidecar_table("meg.MEGCoordsystemFiducialsInformation") }}
422+
{{ MACROS___make_json_table("json.meg.MEGCoordsystemFiducialsInformation") }}
423423

424424
For more information on the definition of anatomical landmarks, please visit:
425425
[How are the Left and Right Pre-Auricular (LPA and RPA) points defined? - FieldTrip Toolbox](https://www.fieldtriptoolbox.org/faq/how_are_the_lpa_and_rpa_points_defined/)

src/modality-specific-files/near-infrared-spectroscopy.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ A guide for using macros can be found at
386386
https://github.com/bids-standard/bids-specification/blob/master/macros_doc.md
387387
-->
388388

389-
{{ MACROS___make_sidecar_table("nirs.CoordsystemGeneral") }}
389+
{{ MACROS___make_json_table("json.nirs.CoordsystemGeneral") }}
390390

391391
Fields relating to the NIRS optode positions:
392392

@@ -399,7 +399,7 @@ A guide for using macros can be found at
399399
https://github.com/bids-standard/bids-specification/blob/master/macros_doc.md
400400
-->
401401

402-
{{ MACROS___make_sidecar_table(["nirs.CoordinateSystem", "nirs.CoordinateSystemDescriptionRec"]) }}
402+
{{ MACROS___make_json_table(["json.nirs.CoordinateSystem", "json.nirs.CoordinateSystemDescriptionRec"]) }}
403403

404404
Fields relating to the position of fiducials measured during an NIRS session/run:
405405

@@ -412,7 +412,7 @@ A guide for using macros can be found at
412412
https://github.com/bids-standard/bids-specification/blob/master/macros_doc.md
413413
-->
414414

415-
{{ MACROS___make_sidecar_table(["nirs.Fiducials", "nirs.FiducialsCoordinateSystemDescriptionRec"]) }}
415+
{{ MACROS___make_json_table(["json.nirs.Fiducials", "json.nirs.FiducialsCoordinateSystemDescriptionRec"]) }}
416416

417417
Fields relating to the position of anatomical landmarks measured during an NIRS session/run:
418418

@@ -425,7 +425,7 @@ A guide for using macros can be found at
425425
https://github.com/bids-standard/bids-specification/blob/master/macros_doc.md
426426
-->
427427

428-
{{ MACROS___make_sidecar_table(["nirs.AnatomicalLandmark", "nirs.AnatomicalLandmarkCoordinateSystemDescriptionRec"]) }}
428+
{{ MACROS___make_json_table(["json.nirs.AnatomicalLandmark", "json.nirs.AnatomicalLandmarkCoordinateSystemDescriptionRec"]) }}
429429

430430
### Example `*_coordsystem.json`
431431

src/schema/rules/json/eeg.yaml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#
2+
# Groups of related metadata fields
3+
#
4+
# Assumptions: never need disjunction of selectors
5+
# Assumptions: top-to-bottom overrides is sufficient logic
6+
7+
---
8+
# General fields
9+
EEGCoordsystemGeneral:
10+
selectors:
11+
- datatype == "eeg"
12+
- suffix == "coordsystem"
13+
fields:
14+
IntendedFor:
15+
level: optional
16+
description_addendum: |
17+
This identifies the MRI or CT scan associated with the electrodes,
18+
landmarks, and fiducials.
19+
20+
# Fields relating to the EEG electrode positions
21+
EEGCoordsystemPositions:
22+
selectors:
23+
- datatype == "eeg"
24+
- suffix == "coordsystem"
25+
fields:
26+
EEGCoordinateSystem: required
27+
EEGCoordinateUnits: required
28+
EEGCoordinateSystemDescription:
29+
level: recommended
30+
level_addendum: required if `EEGCoordinateSystem` is `"Other"`
31+
32+
EEGCoordsystemOther:
33+
selectors:
34+
- datatype == "eeg"
35+
- suffix == "coordsystem"
36+
- '"EEGCoordinateSystem" in json'
37+
- json.EEGCoordinateSystem == "Other"
38+
fields:
39+
EEGCoordinateSystemDescription: required
40+
41+
# Fields relating to the position of fiducials measured during an EEG session/run
42+
EEGCoordsystemFiducials:
43+
selectors:
44+
- datatype == "eeg"
45+
- suffix == "coordsystem"
46+
fields:
47+
FiducialsDescription: optional
48+
FiducialsCoordinates: recommended
49+
FiducialsCoordinateSystem: recommended
50+
FiducialsCoordinateUnits: recommended
51+
FiducialsCoordinateSystemDescription:
52+
level: recommended
53+
level_addendum: required if `FiducialsCoordinateSystem` is `"Other"`
54+
55+
EEGCoordsystemOtherFiducialCoordinateSystem:
56+
selectors:
57+
- datatype == "eeg"
58+
- suffix == "coordsystem"
59+
- json.FiducialsCoordinateSystem == "Other"
60+
fields:
61+
FiducialsCoordinateSystemDescription: required
62+
63+
# Fields relating to the position of anatomical landmark measured during an EEG session/run
64+
EEGCoordsystemLandmark:
65+
selectors:
66+
- datatype == "eeg"
67+
- suffix == "coordsystem"
68+
fields:
69+
AnatomicalLandmarkCoordinates: recommended
70+
AnatomicalLandmarkCoordinateSystem:
71+
level: recommended
72+
description_addendum: Preferably the same as the `EEGCoordinateSystem`.
73+
AnatomicalLandmarkCoordinateUnits: recommended
74+
75+
EEGCoordsystemLandmarkDescriptionRec:
76+
selectors:
77+
- datatype == "eeg"
78+
- suffix == "coordsystem"
79+
- json.AnatomicalLandmarkCoordinateSystem != "Other"
80+
fields:
81+
AnatomicalLandmarkCoordinateSystemDescription:
82+
level: recommended
83+
level_addendum: required if `AnatomicalLandmarkCoordinateSystem` is `"Other"`
84+
85+
EEGCoordsystemLandmarkDescriptionReq:
86+
selectors:
87+
- datatype == "eeg"
88+
- suffix == "coordsystem"
89+
- json.AnatomicalLandmarkCoordinateSystem == "Other"
90+
fields:
91+
AnatomicalLandmarkCoordinateSystemDescription: required

src/schema/rules/json/ieeg.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#
2+
# Groups of related metadata fields
3+
#
4+
# Assumptions: never need disjunction of selectors
5+
# Assumptions: top-to-bottom overrides is sufficient logic
6+
7+
---
8+
# General fields
9+
iEEGCoordsystemGeneral:
10+
selectors:
11+
- datatype == "ieeg"
12+
- suffix == "coordsystem"
13+
fields:
14+
IntendedFor__ds_relative:
15+
level: optional
16+
description_addendum: |
17+
If only a surface reconstruction is available, this should point to
18+
the surface reconstruction file.
19+
Note that this file should have the same coordinate system
20+
specified in `iEEGCoordinateSystem`.
21+
For example, **T1**: `'bids::sub-<label>/ses-<label>/anat/sub-01_T1w.nii.gz'`
22+
**Surface**: `'bids::derivatives/surfaces/sub-<label>/ses-<label>/anat/
23+
sub-01_hemi-R_desc-T1w_pial.surf.gii'`
24+
**Operative photo**: `'bids::sub-<label>/ses-<label>/ieeg/
25+
sub-0001_ses-01_acq-photo1_photo.jpg'`
26+
**Talairach**: `'bids::derivatives/surfaces/sub-Talairach/ses-01/anat/
27+
sub-Talairach_hemi-R_pial.surf.gii'`
28+
29+
# Fields relating to the iEEG electrode positions
30+
iEEGCoordsystemPositions:
31+
selectors:
32+
- datatype == "ieeg"
33+
- suffix == "coordsystem"
34+
fields:
35+
iEEGCoordinateSystem: required
36+
iEEGCoordinateUnits: required
37+
iEEGCoordinateSystemDescription:
38+
level: recommended
39+
level_addendum: required if `iEEGCoordinateSystem` is `"Other"`
40+
iEEGCoordinateProcessingDescription: recommended
41+
iEEGCoordinateProcessingReference: recommended
42+
43+
iEEGCoordsystemOther:
44+
selectors:
45+
- datatype == "ieeg"
46+
- suffix == "coordsystem"
47+
- '"iEEGCoordinateSystem" in json'
48+
- json.iEEGCoordinateSystem == "Other"
49+
fields:
50+
iEEGCoordinateSystemDescription: required

0 commit comments

Comments
 (0)