Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCHEMA: Update existence checks to consider empty lists #1747

Merged
merged 3 commits into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 43 additions & 22 deletions src/schema/rules/checks/references.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,64 @@
---
SubjectRelativeIntendedFor:
SubjectRelativeIntendedForString:
selectors:
- datatype != "ieeg"
- type(sidecar.IntendedFor) != "null"
- 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) != "null"
- type(sidecar.IntendedFor) == "string"
checks:
- exists(sidecar.IntendedFor, "bids-uri") || exists(sidecar.IntendedFor, "dataset")
- exists(sidecar.IntendedFor, "bids-uri") + exists(sidecar.IntendedFor, "dataset") == 1

AssociatedEmptyRoom:
DatasetRelativeIntendedForArray:
selectors:
- suffix == "meg"
- type(sidecar.AssociatedEmptyRoom) != "null"
- datatype == "ieeg"
- type(sidecar.IntendedFor) == "array"
checks:
- exists(sidecar.AssociatedEmptyRoom, "bids-uri") || exists(sidecar.AssociatedEmptyRoom, "dataset")
- exists(sidecar.IntendedFor, "bids-uri") + exists(sidecar.IntendedFor, "dataset") == length(sidecar.IntendedFor)

Stimuli:
AssociatedEmptyRoomString:
selectors:
- suffix == "events"
- extension == ".tsv"
- type(columns.stim_file) != "null"
- datatype == "meg"
- type(sidecar.AssociatedEmptyRoom) == "string"
checks:
- exists(columns.stim_file, "stimuli")
- exists(sidecar.AssociatedEmptyRoom, "bids-uri") + exists(sidecar.AssociatedEmptyRoom, "dataset") == 1

Sources:
AssociatedEmptyRoomArray:
selectors:
- dataset.dataset_description.DatasetType == "derivatives"
- type(sidecar.Sources) != "null"
- datatype == "meg"
- type(sidecar.AssociatedEmptyRoom) == "array"
checks:
- exists(sidecar.Sources, "bids-uri") || exists(sidecar.Sources, "dataset")
- |
exists(sidecar.AssociatedEmptyRoom, "bids-uri") + exists(sidecar.AssociatedEmptyRoom, "dataset")
== length(sidecar.AssociatedEmptyRoom)

SpatialReferences:
Sources:
selectors:
- dataset.dataset_description.DatasetType == "derivatives"
- type(sidecar.SpatialReference.URI) != "null"
- type(sidecar.Sources) != "null"
checks:
- exists(sidecar.SpatialReference.URI, "bids-uri") || exists(sidecar.SpatialReference.URI, "dataset")
- exists(sidecar.Sources, "bids-uri") + exists(sidecar.Sources, "dataset") == length(sidecar.Sources)

## 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