From 4b1b8820c221ab630114464eb63b00d8b67e9fca Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 3 Nov 2023 08:15:40 -0400 Subject: [PATCH 1/5] RF: Convert column description into a common definition --- .../json/schemas/common_definitions.json | 69 +++++++++++++++++- .../json/schemas/data_dictionary.json | 72 +------------------ .../validators/json/schemas/events.json | 66 +---------------- 3 files changed, 70 insertions(+), 137 deletions(-) diff --git a/bids-validator/validators/json/schemas/common_definitions.json b/bids-validator/validators/json/schemas/common_definitions.json index ad0e9bf40..5980ca3c2 100644 --- a/bids-validator/validators/json/schemas/common_definitions.json +++ b/bids-validator/validators/json/schemas/common_definitions.json @@ -122,6 +122,73 @@ "SoftwareVersions": { "type": "string" }, "TaskDescription": { "type": "string" }, "TaskName": { "type": "string", "minLength": 1 }, - "TriggerChannelCount": { "type": "integer", "minimum": 0 } + "TermURL": { + "title": "TermURL", + "description": "URL pointing to a formal definition in an ontology available on the web.", + "type": "string", + "format": "uri" + }, + "TriggerChannelCount": { "type": "integer", "minimum": 0 }, + "ColumnDescription": { + "type": "object", + "title": "Column", + "description": "Column of a corresponding tabular file.", + "properties": { + "LongName": { + "title": "LongName", + "description": " Long (unabbreviated) name of column.", + "type": "string" + }, + "Description": { + "title": "Description", + "description": "Description of the column.", + "type": "string" + }, + "Units": { + "title": "Units", + "description": "Measurement units.", + "type": "string" + }, + "Levels": { + "type": "object", + "title": "Levels", + "description": "For categorical variables: a dictionary of possible values (keys) and their descriptions (values).", + "patternProperties": { + "^.+$": { + "anyOf": [ + { "type": "string" }, + { + "type": "object", + "properties": { + "Description": { "type": "string" }, + "TermURL": { "$ref": "#/definitions/TermURL" } + } + } + ] + } + } + }, + "TermURL": { "$ref": "#/definitions/TermURL" }, + "HED": { + "anyOf": [ + { + "type": "object", + "title": "HED", + "description": "For categorical variables: a dictionary of possible values (keys) and their HED strings (values).", + "patternProperties": { + "^.+$": { + "type": "string" + } + } + }, + { + "type": "string", + "title": "HED", + "description": "For value variables: a string with a single '#' character where the cell value is to be interpolated." + } + ] + } + } + } } } diff --git a/bids-validator/validators/json/schemas/data_dictionary.json b/bids-validator/validators/json/schemas/data_dictionary.json index 75322abac..f3bfc1921 100644 --- a/bids-validator/validators/json/schemas/data_dictionary.json +++ b/bids-validator/validators/json/schemas/data_dictionary.json @@ -1,76 +1,6 @@ { "type": "object", "patternProperties": { - "^.+$": { - "type": "object", - "title": "Column", - "description": "Column of a corresponding tabular file.", - "properties": { - "LongName": { - "title": "LongName", - "description": " Long (unabbreviated) name of column.", - "type": "string" - }, - "Description": { - "title": "Description", - "description": "Description of the column.", - "type": "string" - }, - "Units": { - "title": "Units", - "description": "Measurement units.", - "type": "string" - }, - "Levels": { - "type": "object", - "title": "Levels", - "description": "For categorical variables: a dictionary of possible values (keys) and their descriptions (values).", - "patternProperties": { - "^.+$": { - "anyOf": [ - { "type": "string" }, - { - "type": "object", - "properties": { - "Description": { "type": "string" }, - "TermURL": { - "title": "TermURL", - "description": "URL pointing to a formal definition in an ontology available on the web.", - "type": "string", - "format": "uri" - } - } - } - ] - } - } - }, - "TermURL": { - "title": "TermURL", - "description": "URL pointing to a formal definition in an ontology available on the web.", - "type": "string", - "format": "uri" - }, - "HED": { - "anyOf": [ - { - "type": "object", - "title": "HED", - "description": "For categorical variables: a dictionary of possible values (keys) and their HED strings (values).", - "patternProperties": { - "^.+$": { - "type": "string" - } - } - }, - { - "type": "string", - "title": "HED", - "description": "For value variables: a string with a single '#' character where the cell value is to be interpolated." - } - ] - } - } - } + "^.+$": { "$ref": "common_definitions.json#/definitions/ColumnDescription" } } } diff --git a/bids-validator/validators/json/schemas/events.json b/bids-validator/validators/json/schemas/events.json index 73d27e47d..bace2aa3a 100644 --- a/bids-validator/validators/json/schemas/events.json +++ b/bids-validator/validators/json/schemas/events.json @@ -1,71 +1,7 @@ { "type": "object", "patternProperties": { - "^.+$": { - "type": "object", - "title": "Column", - "description": "Column of a corresponding tabular file.", - "properties": { - "LongName": { - "title": "LongName", - "description": " Long (unabbreviated) name of column.", - "type": "string" - }, - "Description": { - "title": "Description", - "description": "Description of the column.", - "type": "string" - }, - "Units": { - "title": "Units", - "description": "Measurement units.", - "type": "string" - }, - "Levels": { - "type": "object", - "title": "Levels", - "description": "For categorical variables: a dictionary of possible values (keys) and their descriptions (values).", - "patternProperties": { - "^.+$": { - "anyOf": [ - { "type": "string" }, - { - "type": "object", - "properties": { - "Description": { "type": "string" }, - "TermURL": { - "title": "TermURL", - "description": "URL pointing to a formal definition in an ontology available on the web.", - "type": "string", - "format": "uri" - } - } - } - ] - } - } - }, - "HED": { - "anyOf": [ - { - "type": "object", - "title": "HED", - "description": "For categorical variables: a dictionary of possible values (keys) and their HED strings (values).", - "patternProperties": { - "^.+$": { - "type": "string" - } - } - }, - { - "type": "string", - "title": "HED", - "description": "For value variables: a string with a single '#' character where the cell value is to be interpolated." - } - ] - } - } - } + "^.+$": { "$ref": "common_definitions.json#/definitions/ColumnDescription" } }, "properties": { "StimulusPresentation": { From bfa80cddbcb3194e1cf9cce37c36d2b5ec03d221 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 3 Nov 2023 08:17:13 -0400 Subject: [PATCH 2/5] ENH: Add column definitions for channels.json --- bids-validator/validators/json/json.js | 2 ++ .../validators/json/schemas/channels.json | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 bids-validator/validators/json/schemas/channels.json diff --git a/bids-validator/validators/json/json.js b/bids-validator/validators/json/json.js index bf0c8aa65..2f0e63445 100644 --- a/bids-validator/validators/json/json.js +++ b/bids-validator/validators/json/json.js @@ -161,6 +161,8 @@ const selectSchema = (file) => { schema = require('./schemas/beh.json') } else if (file.name.endsWith('_motion.json')) { schema = require('./schemas/motion.json') + } else if (file.name.endsWith('_channels.json')) { + schema = require('./schemas/channels.json') } } return schema diff --git a/bids-validator/validators/json/schemas/channels.json b/bids-validator/validators/json/schemas/channels.json new file mode 100644 index 000000000..e6e32f947 --- /dev/null +++ b/bids-validator/validators/json/schemas/channels.json @@ -0,0 +1,36 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "type": "object", + "properties": { + "reference_frame": { + "$ref": "common_definitions.json#/definitions/ColumnDescription", + "title": "Reference Frame", + "properties": { + "$ref": "common_definitions.json#/definitions/ColumnDescription/properties", + "Levels": { + "$ref": "common_definitions.json#/definitions/ColumnDescription/properties/Levels", + "properties": { + "RotationOrder": { + "description": "The sequence in which the extrinsic rotations are applied around the three axes.", + "type": "string", + "enum": ["XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX"] + }, + "RotationRule": { + "description": "The direction of rotation around each axis.", + "type": "string", + "enum": ["left-hand", "right-hand"] + }, + "SpatialAxes": { + "description": "The coordinate system in which the motion data are to be interpreted. A sequence of characters from the set `{'A', 'P', 'L', 'R', 'S', 'I', '_'}` indicating the direction of each axis. For example `\"ARS\"` indicates positive values in the X, Y, Z axes are respectively anterior, right, and superior of the origin, while `\"PLI\"` indicates positive values are posterior, left, and inferior of the origin. The `\"_\"` character may be used for unused axes.", + "type": "string", + "pattern": "^[APLRSI_]{3}$" + } + } + } + } + } + }, + "patternProperties": { + "^.+$": { "$ref": "common_definitions.json#/definitions/ColumnDescription" } + } +} From 71b88c1e029862b954c5a02a7ce1620fae078dfc Mon Sep 17 00:00:00 2001 From: Ross Blair Date: Fri, 3 Nov 2023 10:35:27 -0500 Subject: [PATCH 3/5] force channels json to validate against both column descriptions and stricter level object. --- .../validators/json/schemas/channels.json | 53 +++++++++---------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/bids-validator/validators/json/schemas/channels.json b/bids-validator/validators/json/schemas/channels.json index e6e32f947..9ea8fcdac 100644 --- a/bids-validator/validators/json/schemas/channels.json +++ b/bids-validator/validators/json/schemas/channels.json @@ -1,36 +1,35 @@ { "$schema": "http://json-schema.org/draft-06/schema#", - "type": "object", - "properties": { - "reference_frame": { - "$ref": "common_definitions.json#/definitions/ColumnDescription", - "title": "Reference Frame", + "allOf": [ + { + "type": "object", "properties": { - "$ref": "common_definitions.json#/definitions/ColumnDescription/properties", - "Levels": { - "$ref": "common_definitions.json#/definitions/ColumnDescription/properties/Levels", + "reference_frame": { + "title": "Reference Frame", "properties": { - "RotationOrder": { - "description": "The sequence in which the extrinsic rotations are applied around the three axes.", - "type": "string", - "enum": ["XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX"] - }, - "RotationRule": { - "description": "The direction of rotation around each axis.", - "type": "string", - "enum": ["left-hand", "right-hand"] - }, - "SpatialAxes": { - "description": "The coordinate system in which the motion data are to be interpreted. A sequence of characters from the set `{'A', 'P', 'L', 'R', 'S', 'I', '_'}` indicating the direction of each axis. For example `\"ARS\"` indicates positive values in the X, Y, Z axes are respectively anterior, right, and superior of the origin, while `\"PLI\"` indicates positive values are posterior, left, and inferior of the origin. The `\"_\"` character may be used for unused axes.", - "type": "string", - "pattern": "^[APLRSI_]{3}$" + "Levels": { + "properties": { + "RotationOrder": { + "description": "The sequence in which the extrinsic rotations are applied around the three axes.", + "type": "string", + "enum": ["XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX"] + }, + "RotationRule": { + "description": "The direction of rotation around each axis.", + "type": "string", + "enum": ["left-hand", "right-hand"] + }, + "SpatialAxes": { + "description": "The coordinate system in which the motion data are to be interpreted. A sequence of characters from the set `{'A', 'P', 'L', 'R', 'S', 'I', '_'}` indicating the direction of each axis. For example `\"ARS\"` indicates positive values in the X, Y, Z axes are respectively anterior, right, and superior of the origin, while `\"PLI\"` indicates positive values are posterior, left, and inferior of the origin. The `\"_\"` character may be used for unused axes.", + "type": "string", + "pattern": "^[APLRSI_]{3}$" + } + } } } } } - } - }, - "patternProperties": { - "^.+$": { "$ref": "common_definitions.json#/definitions/ColumnDescription" } - } + }, + { "$ref": "common_definitions.json#/definitions/ColumnDescription" } + ] } From 0718b6170d5c64e17e627f59e92b52aa3565c9dd Mon Sep 17 00:00:00 2001 From: Ross Blair Date: Fri, 3 Nov 2023 10:41:29 -0500 Subject: [PATCH 4/5] columndescription in channels is describing objects as values of properties, not the top level properties themselves --- bids-validator/validators/json/schemas/channels.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bids-validator/validators/json/schemas/channels.json b/bids-validator/validators/json/schemas/channels.json index 9ea8fcdac..fd97cf7ec 100644 --- a/bids-validator/validators/json/schemas/channels.json +++ b/bids-validator/validators/json/schemas/channels.json @@ -30,6 +30,11 @@ } } }, - { "$ref": "common_definitions.json#/definitions/ColumnDescription" } + { + "type": "object", + "patternProperties": { + "^.+$": { "$ref": "common_definitions.json#/definitions/ColumnDescription" } + } + } ] } From 5b338cacd093f49b1fd82b47873e1730e6f8f937 Mon Sep 17 00:00:00 2001 From: Ross Blair Date: Fri, 3 Nov 2023 11:07:21 -0500 Subject: [PATCH 5/5] fix missing pattern properties in reference_frame schema --- .../validators/json/schemas/channels.json | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/bids-validator/validators/json/schemas/channels.json b/bids-validator/validators/json/schemas/channels.json index fd97cf7ec..e4be45d89 100644 --- a/bids-validator/validators/json/schemas/channels.json +++ b/bids-validator/validators/json/schemas/channels.json @@ -6,27 +6,34 @@ "properties": { "reference_frame": { "title": "Reference Frame", + "type": "object", "properties": { "Levels": { - "properties": { - "RotationOrder": { - "description": "The sequence in which the extrinsic rotations are applied around the three axes.", - "type": "string", - "enum": ["XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX"] - }, - "RotationRule": { - "description": "The direction of rotation around each axis.", - "type": "string", - "enum": ["left-hand", "right-hand"] - }, - "SpatialAxes": { - "description": "The coordinate system in which the motion data are to be interpreted. A sequence of characters from the set `{'A', 'P', 'L', 'R', 'S', 'I', '_'}` indicating the direction of each axis. For example `\"ARS\"` indicates positive values in the X, Y, Z axes are respectively anterior, right, and superior of the origin, while `\"PLI\"` indicates positive values are posterior, left, and inferior of the origin. The `\"_\"` character may be used for unused axes.", - "type": "string", - "pattern": "^[APLRSI_]{3}$" + "type": "object", + "patternProperties": { + "^.+$": { + "type": "object", + "properties": { + "RotationOrder": { + "description": "The sequence in which the extrinsic rotations are applied around the three axes.", + "type": "string", + "enum": ["XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX"] + }, + "RotationRule": { + "description": "The direction of rotation around each axis.", + "type": "string", + "enum": ["left-hand", "right-hand"] + }, + "SpatialAxes": { + "description": "The coordinate system in which the motion data are to be interpreted. A sequence of characters from the set `{'A', 'P', 'L', 'R', 'S', 'I', '_'}` indicating the direction of each axis. For example `\"ARS\"` indicates positive values in the X, Y, Z axes are respectively anterior, right, and superior of the origin, while `\"PLI\"` indicates positive values are posterior, left, and inferior of the origin. The `\"_\"` character may be used for unused axes.", + "type": "string", + "pattern": "^[APLRSI_]{3}$" + } + } } } } - } + } } } },