Skip to content

Commit

Permalink
feat(schema): Improve type annotations of schema.context (#1886)
Browse files Browse the repository at this point in the history
* feat(schema): Add additionalProperties=false to context objects

This is intended to give better guidance to tooling that would
auto-generate classes or interfaces for the validation context.

* feat(schema): Set requirement levels for context properties

* feat(schema): Type more array/object values in context

* fix(schema): Not all files have a subject
  • Loading branch information
effigies committed Aug 14, 2024
1 parent 58e236e commit 98645a1
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions src/schema/meta/context.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,29 @@
#
---
type: object
required:
- schema
- dataset
- path
- size
- sidecar
- associations
additionalProperties: false
properties:
schema:
description: 'The BIDS specification schema'
type: object
dataset:
description: 'Properties and contents of the entire dataset'
type: object
required:
- dataset_description
- tree
- ignored
- datatypes
- modalities
- subjects
additionalProperties: false
properties:
dataset_description:
description: 'Contents of /dataset_description.json'
Expand All @@ -35,15 +51,24 @@ properties:
ignored:
description: 'Set of ignored files'
type: array
items:
type: string
datatypes:
description: 'Data types present in the dataset'
type: array
items:
type: string
modalities:
description: 'Modalities present in the dataset'
type: array
items:
type: string
subjects:
description: 'Collections of subjects in dataset'
type: object
required:
- sub_dirs
additionalProperties: false
properties:
sub_dirs:
description: 'Subjects as determined by sub-*/ directories'
Expand All @@ -63,10 +88,16 @@ properties:
subject:
description: 'Properties and contents of the current subject'
type: object
required:
- sessions
additionalProperties: false
properties:
sessions:
description: 'Collections of sessions in subject'
type: object
required:
- ses_dirs
additionalProperties: false
properties:
ses_dirs:
description: 'Sessions as determined by ses-*/ directories'
Expand Down Expand Up @@ -94,6 +125,8 @@ properties:
entities:
description: 'Entities parsed from the current filename'
type: object
additionalProperties:
type: string
datatype:
description: 'Datatype of current file, for examples, anat'
type: string
Expand All @@ -117,10 +150,13 @@ properties:
description: |
Associated files, indexed by suffix, selected according to the inheritance principle
type: object
additionalProperties: false
properties:
events:
description: 'Events file'
type: object
required: [path, onset]
additionalProperties: false
properties:
path:
description: 'Path to associated events file'
Expand All @@ -133,6 +169,8 @@ properties:
aslcontext:
description: 'ASL context file'
type: object
required: [path, n_rows, volume_type]
additionalProperties: false
properties:
path:
description: 'Path to associated aslcontext file'
Expand All @@ -148,27 +186,35 @@ properties:
m0scan:
description: 'M0 scan file'
type: object
required: [path]
additionalProperties: false
properties:
path:
description: 'Path to associated M0 scan file'
type: string
magnitude:
description: 'Magnitude image file'
type: object
required: [path]
additionalProperties: false
properties:
path:
description: 'Path to associated magnitude file'
type: string
magnitude1:
description: 'Magnitude1 image file'
type: object
required: [path]
additionalProperties: false
properties:
path:
description: 'Path to associated magnitude1 file'
type: string
bval:
description: 'B value file'
type: object
required: [path, n_cols, n_rows, values]
additionalProperties: false
properties:
path:
description: 'Path to associated bval file'
Expand All @@ -187,6 +233,8 @@ properties:
bvec:
description: 'B vector file'
type: object
required: [path, n_cols, n_rows]
additionalProperties: false
properties:
path:
description: 'Path to associated bvec file'
Expand All @@ -200,6 +248,8 @@ properties:
channels:
description: 'Channels file'
type: object
required: [path, type]
additionalProperties: false
properties:
path:
description: 'Path to associated channels file'
Expand All @@ -222,6 +272,8 @@ properties:
coordsystem:
description: 'Coordinate system file'
type: object
required: [path]
additionalProperties: false
properties:
path:
description: 'Path to associated coordsystem file'
Expand All @@ -232,12 +284,16 @@ properties:
type: object
additionalProperties:
type: array
items:
type: string
json:
description: 'Contents of the current JSON file'
type: object
gzip:
description: 'Parsed contents of gzip header'
type: object
required: [timestamp, filename]
additionalProperties: false
properties:
timestamp:
description: 'Modification time, unix timestamp'
Expand All @@ -252,11 +308,23 @@ properties:
name: 'NIfTI Header'
description: 'Parsed contents of NIfTI header referenced elsewhere in schema.'
type: object
required:
- dim_info
- dim
- pixdim
- shape
- voxel_sizes
- xyzt_units
- qform_code
- sform_code
additionalProperties: false
properties:
dim_info:
name: 'Dimension Information'
description: 'Metadata about dimensions data.'
type: object
required: [freq, phase, slice]
additionalProperties: false
properties:
freq:
name: 'Frequency'
Expand Down Expand Up @@ -306,6 +374,8 @@ properties:
name: 'XYZT Units'
description: 'Units of pixdim[1..4]'
type: object
required: [xyz, t]
additionalProperties: false
properties:
xyz:
name: 'XYZ Units'
Expand Down Expand Up @@ -339,6 +409,7 @@ properties:
name: 'Open Microscopy Environment fields'
description: 'Parsed contents of OME-XML header, which may be found in OME-TIFF or OME-ZARR files'
type: object
additionalProperties: false
properties:
PhysicalSizeX:
name: 'PhysicalSizeX'
Expand Down Expand Up @@ -368,6 +439,9 @@ properties:
name: 'TIFF'
description: 'TIFF file format metadata'
type: object
required:
- version
additionalProperties: false
properties:
version:
name: 'Version'
Expand Down

0 comments on commit 98645a1

Please sign in to comment.