From 735bf2339c673c449586bb9b4c971de00b134322 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Sat, 23 Mar 2024 14:47:25 -0400 Subject: [PATCH 1/3] SCHEMA: Update existence checks to consider empty lists --- src/schema/rules/checks/references.yaml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/schema/rules/checks/references.yaml b/src/schema/rules/checks/references.yaml index cbbc8f5454..54957cb959 100644 --- a/src/schema/rules/checks/references.yaml +++ b/src/schema/rules/checks/references.yaml @@ -3,6 +3,7 @@ SubjectRelativeIntendedFor: selectors: - datatype != "ieeg" - type(sidecar.IntendedFor) != "null" + - length(sidecar.IntendedFor) > 0 checks: - exists(sidecar.IntendedFor, "bids-uri") || exists(sidecar.IntendedFor, "subject") @@ -10,6 +11,7 @@ DatasetRelativeIntendedFor: selectors: - datatype == "ieeg" - type(sidecar.IntendedFor) != "null" + - length(sidecar.IntendedFor) > 0 checks: - exists(sidecar.IntendedFor, "bids-uri") || exists(sidecar.IntendedFor, "dataset") @@ -17,21 +19,15 @@ AssociatedEmptyRoom: selectors: - suffix == "meg" - type(sidecar.AssociatedEmptyRoom) != "null" + - length(sidecar.AssociatedEmptyRoom) > 0 checks: - exists(sidecar.AssociatedEmptyRoom, "bids-uri") || exists(sidecar.AssociatedEmptyRoom, "dataset") -Stimuli: - selectors: - - suffix == "events" - - extension == ".tsv" - - type(columns.stim_file) != "null" - checks: - - exists(columns.stim_file, "stimuli") - Sources: selectors: - dataset.dataset_description.DatasetType == "derivatives" - type(sidecar.Sources) != "null" + - length(sidecar.Sources) > 0 checks: - exists(sidecar.Sources, "bids-uri") || exists(sidecar.Sources, "dataset") From 61c11c7dc4ad31097a196049915622bcb80d4d37 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Thu, 18 Apr 2024 15:10:39 -0400 Subject: [PATCH 2/3] RF: Split rules by array or string --- src/schema/rules/checks/references.yaml | 62 ++++++++++++++++++------- 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/src/schema/rules/checks/references.yaml b/src/schema/rules/checks/references.yaml index 54957cb959..099e913f0f 100644 --- a/src/schema/rules/checks/references.yaml +++ b/src/schema/rules/checks/references.yaml @@ -1,39 +1,65 @@ --- -SubjectRelativeIntendedFor: +SubjectRelativeIntendedForString: selectors: - datatype != "ieeg" - - type(sidecar.IntendedFor) != "null" - - length(sidecar.IntendedFor) > 0 + - type(sidecar.IntendedFor) == "string" checks: - - exists(sidecar.IntendedFor, "bids-uri") || exists(sidecar.IntendedFor, "subject") + - exists(sidecar.IntendedFor, "bids-uri") + exists(sidecar.IntendedFor, "subject") == 1 -DatasetRelativeIntendedFor: +SubjectRelativeIntendedForArray: + selectors: + - datatype != "ieeg" + - type(sidecar.IntendedFor) == "array" + checks: + - exists(sidecar.IntendedFor, "bids-uri") + exists(sidecar.IntendedFor, "subject") == length(sidecar.IntendedFor) + +DatasetRelativeIntendedForString: + selectors: + - datatype == "ieeg" + - type(sidecar.IntendedFor) == "string" + checks: + - exists(sidecar.IntendedFor, "bids-uri") + exists(sidecar.IntendedFor, "dataset") == 1 + +DatasetRelativeIntendedForArray: selectors: - datatype == "ieeg" - - type(sidecar.IntendedFor) != "null" - - length(sidecar.IntendedFor) > 0 + - type(sidecar.IntendedFor) == "array" checks: - - exists(sidecar.IntendedFor, "bids-uri") || exists(sidecar.IntendedFor, "dataset") + - exists(sidecar.IntendedFor, "bids-uri") + exists(sidecar.IntendedFor, "dataset") == length(sidecar.IntendedFor) -AssociatedEmptyRoom: +AssociatedEmptyRoomString: selectors: - - suffix == "meg" - - type(sidecar.AssociatedEmptyRoom) != "null" - - length(sidecar.AssociatedEmptyRoom) > 0 + - datatype == "meg" + - type(sidecar.AssociatedEmptyRoom) == "string" checks: - - exists(sidecar.AssociatedEmptyRoom, "bids-uri") || exists(sidecar.AssociatedEmptyRoom, "dataset") + - exists(sidecar.AssociatedEmptyRoom, "bids-uri") + exists(sidecar.AssociatedEmptyRoom, "dataset") == 1 + +AssociatedEmptyRoomArray: + selectors: + - datatype == "meg" + - type(sidecar.AssociatedEmptyRoom) == "array" + checks: + - | + exists(sidecar.AssociatedEmptyRoom, "bids-uri") + exists(sidecar.AssociatedEmptyRoom, "dataset") + == length(sidecar.AssociatedEmptyRoom) Sources: selectors: - dataset.dataset_description.DatasetType == "derivatives" - type(sidecar.Sources) != "null" - - length(sidecar.Sources) > 0 checks: - - exists(sidecar.Sources, "bids-uri") || exists(sidecar.Sources, "dataset") + - exists(sidecar.Sources, "bids-uri") + exists(sidecar.Sources, "dataset") == length(sidecar.Sources) + +SpatialReferencesString: + selectors: + - dataset.dataset_description.DatasetType == "derivatives" + - type(sidecar.SpatialReference.URI) == "string" + checks: + - exists(sidecar.SpatialReference.URI, "bids-uri") + exists(sidecar.SpatialReference.URI, "dataset") == 1 -SpatialReferences: +SpatialReferencesArray: selectors: - dataset.dataset_description.DatasetType == "derivatives" - - type(sidecar.SpatialReference.URI) != "null" + - type(sidecar.SpatialReference.URI) == "array" checks: - - exists(sidecar.SpatialReference.URI, "bids-uri") || exists(sidecar.SpatialReference.URI, "dataset") + - exists(sidecar.SpatialReference.URI, "bids-uri") + exists(sidecar.SpatialReference.URI, "dataset") == length(sidecar.SpatialReference.URI) From de4bb1a9bbdba35039274809ba61350c52f4355f Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Thu, 18 Apr 2024 15:28:12 -0400 Subject: [PATCH 3/3] SpatialReferences considered out-of-scope --- src/schema/rules/checks/references.yaml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/schema/rules/checks/references.yaml b/src/schema/rules/checks/references.yaml index 099e913f0f..b0f1dd6e9d 100644 --- a/src/schema/rules/checks/references.yaml +++ b/src/schema/rules/checks/references.yaml @@ -50,16 +50,15 @@ Sources: checks: - exists(sidecar.Sources, "bids-uri") + exists(sidecar.Sources, "dataset") == length(sidecar.Sources) -SpatialReferencesString: - selectors: - - dataset.dataset_description.DatasetType == "derivatives" - - type(sidecar.SpatialReference.URI) == "string" - checks: - - exists(sidecar.SpatialReference.URI, "bids-uri") + exists(sidecar.SpatialReference.URI, "dataset") == 1 - -SpatialReferencesArray: - selectors: - - dataset.dataset_description.DatasetType == "derivatives" - - type(sidecar.SpatialReference.URI) == "array" - checks: - - exists(sidecar.SpatialReference.URI, "bids-uri") + exists(sidecar.SpatialReference.URI, "dataset") == length(sidecar.SpatialReference.URI) +## Verifying the existence of SpatialReferences is out-of-scope for schema validation +## The ability to use any URI leaves this field too open-ended for effective validation, and the +## object of key/URI pairs is worse. +## +## 2024.04.18 CJM & RWB +# +# SpatialReferencesString: +# selectors: +# - dataset.dataset_description.DatasetType == "derivatives" +# - type(sidecar.SpatialReference) == "string" +# checks: +# - exists(sidecar.SpatialReference, "bids-uri") + exists(sidecar.SpatialReference, "dataset") == 1