Skip to content

Commit

Permalink
Merge pull request #1880 from effigies/fix/check-issues
Browse files Browse the repository at this point in the history
fix(schema): Add issue definitions for all checks
  • Loading branch information
nellh authored Aug 8, 2024
2 parents cb00fd6 + 02049c5 commit 817454b
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/metaschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@
"$ref": "#/definitions/ruleTypes/expressionList"
}
},
"required": ["checks", "selectors"],
"required": ["checks", "selectors", "issue"],
"additionalProperties": false
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/schema/meta/context.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,16 @@ properties:
type: array
items:
type: string
short_channel:
description: 'Contents of the short_channel column'
type: array
items:
type: string
sampling_frequency:
description: 'Contents of the sampling_frequency column'
type: array
items:
type: string
coordsystem:
description: 'Coordinate system file'
type: object
Expand Down
14 changes: 14 additions & 0 deletions src/schema/rules/checks/common_derivatives.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
---
ResInSidecar:
issue:
code: MISSING_RESOLUTION_DESCRIPTION
message: |
The Resolution metadata object does not contain an entry for the file's
res-<label> entity.
level: error
selectors:
- dataset.dataset_description.DatasetType == "derivative"
- intersects([modality], ["mri", "pet"])
- match(extension, '^\.nii(\.gz)?$')
- type(entities.resolution) != 'null'
- type(sidecar.Resolution) == "object"
checks:
- entities.resolution in sidecar.Resolution

DenInSidecar:
issue:
code: MISSING_DENSITY_DESCRIPTION
message: |
The Density metadata object does not contain an entry for the file's
res-<label> entity.
level: error
selectors:
- dataset.dataset_description.DatasetType == "derivative"
- intersects([modality], ["mri", "pet"])
- match(extension, '^\.nii(\.gz)?$')
- type(entities.density) != 'null'
- type(sidecar.Density) == "object"
checks:
- entities.density in sidecar.Density
62 changes: 62 additions & 0 deletions src/schema/rules/checks/nirs.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
---
NASamplingFreq:
issue:
code: NIRS_SAMPLING_FREQUENCY
message: |
Sampling frequency must be defined in the sidecar, or else as a sampling_frequency
column of channels.tsv.
level: error
selectors:
- suffix == "nirs"
- sidecar.SamplingFrequency == "n/a"
checks:
- associations.channels.sampling_frequency != null

NIRSChannelCount:
issue:
code: NIRS_CHANNEL_COUNT
message: |
NIRSChannelCount metadata must equal the number of channels with type NIRS*,
as listed in channels.tsv.
level: error
selectors:
- datatype == "nirs"
- suffix == "nirs"
- match(extension, '\.nii(\.gz)?$')
- type(sidecar.NIRSChannelCount) != 'null'
checks:
- |
sidecar.NIRSChannelCount
Expand All @@ -22,34 +35,63 @@ NIRSChannelCount:
+ count(associations.channels.type, "NIRSCWMUA")
ACCELChannelCountReq:
issue:
code: ACCEL_CHANNEL_COUNT
message: |
ACCELChannelCount metadata must equal the number of channels with type ACCEL,
as listed in channels.tsv.
level: error
selectors:
- suffix == "nirs"
- count(associations.channels.type, "ACCEL") > 0
checks:
- sidecar.ACCELChannelCount == count(associations.channels.type, "ACCEL")

GYROChannelCountReq:
issue:
code: GYRO_CHANNEL_COUNT
message: |
GYROChannelCount metadata must equal the number of channels with type GYRO,
as listed in channels.tsv.
level: error
selectors:
- suffix == "nirs"
- count(associations.channels.type, "GYRO") > 0
checks:
- sidecar.GYROChannelCount == count(associations.channels.type, "GYRO")

MAGNChannelCountReq:
issue:
code: MAGN_CHANNEL_COUNT
message: |
MAGNChannelCount metadata must equal the number of channels with type MAGN,
as listed in channels.tsv.
level: error
selectors:
- suffix == "nirs"
- count(associations.channels.type, "MAGN") > 0
checks:
- sidecar.MAGNChannelCount == count(associations.channels.type, "MAGN")

ShortChannelCountReq:
issue:
code: SHORT_CHANNEL_COUNT
message: |
ShortChannelCount metadata must equal the number of channels with the value `true`
in the `short_channel` column of channels.tsv.
level: error
selectors:
- suffix == "nirs"
- '"ShortChannelCount" in sidecar'
checks:
- sidecar.ShortChannelCount == count(associations.channels.short_channel, "true")

Component:
issue:
code: COMPONENT_COLUMN_REQUIRED
message: |
ACCEL, GYRO, and MAGN columns require a `component` column in channels.tsv.
level: error
selectors:
- datatype == "nirs"
- suffix == "channels"
Expand All @@ -71,6 +113,11 @@ RecommendedChannels:
- associations.channels != null

RequiredTemplateX:
issue:
code: REQUIRED_TEMPLATE_X
message: |
The `template_x` column MUST be defined if the `x` column is `n/a`.
level: error
selectors:
- datatype == "nirs"
- suffix == "optodes"
Expand All @@ -80,6 +127,11 @@ RequiredTemplateX:
- columns.template_x != null

RequiredTemplateY:
issue:
code: REQUIRED_TEMPLATE_Y
message: |
The `template_y` column MUST be defined if the `y` column is `n/a`.
level: error
selectors:
- datatype == "nirs"
- suffix == "optodes"
Expand All @@ -89,6 +141,11 @@ RequiredTemplateY:
- columns.template_y != null

RequiredTemplateZ:
issue:
code: REQUIRED_TEMPLATE_Z
message: |
The `template_z` column MUST be defined if the `z` column is `n/a`.
level: error
selectors:
- datatype == "nirs"
- suffix == "optodes"
Expand All @@ -98,6 +155,11 @@ RequiredTemplateZ:
- columns.template_z != null

RequiredCoordsystem:
issue:
code: REQUIRED_COORDSYSTEM
message: |
If an optodes.tsv file is provided, an associated coordsystem.json must also be present.
level: error
selectors:
- datatype == "nirs"
- suffix == "optodes"
Expand Down
42 changes: 42 additions & 0 deletions src/schema/rules/checks/references.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,76 @@
---
SubjectRelativeIntendedForString:
issue:
code: INTENDED_FOR
message: |
'IntendedFor' field needs to point to an existing file.
Files must be subject-relative paths or BIDS URIs.
level: error
selectors:
- datatype != "ieeg"
- type(sidecar.IntendedFor) == "string"
checks:
- exists(sidecar.IntendedFor, "bids-uri") + exists(sidecar.IntendedFor, "subject") == 1

SubjectRelativeIntendedForArray:
issue:
code: INTENDED_FOR
message: |
'IntendedFor' field needs to point to an existing file.
Files must be subject-relative paths or BIDS URIs.
level: error
selectors:
- datatype != "ieeg"
- type(sidecar.IntendedFor) == "array"
checks:
- exists(sidecar.IntendedFor, "bids-uri") + exists(sidecar.IntendedFor, "subject") == length(sidecar.IntendedFor)

DatasetRelativeIntendedForString:
issue:
code: INTENDED_FOR
message: |
'IntendedFor' field needs to point to an existing file.
Files must be dataset-relative paths or BIDS URIs.
level: error
selectors:
- datatype == "ieeg"
- type(sidecar.IntendedFor) == "string"
checks:
- exists(sidecar.IntendedFor, "bids-uri") + exists(sidecar.IntendedFor, "dataset") == 1

DatasetRelativeIntendedForArray:
issue:
code: INTENDED_FOR
message: |
'IntendedFor' field needs to point to an existing file.
Files must be dataset-relative paths or BIDS URIs.
level: error
selectors:
- datatype == "ieeg"
- type(sidecar.IntendedFor) == "array"
checks:
- exists(sidecar.IntendedFor, "bids-uri") + exists(sidecar.IntendedFor, "dataset") == length(sidecar.IntendedFor)

AssociatedEmptyRoomString:
issue:
code: ASSOCIATED_EMPTY_ROOM
message: |
'AssociatedEmptyRoom' field needs to point to an existing file.
Files must be dataset-relative paths or BIDS URIs.
level: error
selectors:
- datatype == "meg"
- type(sidecar.AssociatedEmptyRoom) == "string"
checks:
- exists(sidecar.AssociatedEmptyRoom, "bids-uri") + exists(sidecar.AssociatedEmptyRoom, "dataset") == 1

AssociatedEmptyRoomArray:
issue:
code: ASSOCIATED_EMPTY_ROOM
message: |
'AssociatedEmptyRoom' field needs to point to an existing file.
Files must be dataset-relative paths or BIDS URIs.
level: error
selectors:
- datatype == "meg"
- type(sidecar.AssociatedEmptyRoom) == "array"
Expand All @@ -44,6 +80,12 @@ AssociatedEmptyRoomArray:
== length(sidecar.AssociatedEmptyRoom)
Sources:
issue:
code: SOURCE_FILE_EXIST
message: |
'Sources' field needs to point to existing files.
Files must be dataset-relative paths or BIDS URIs.
level: error
selectors:
- dataset.dataset_description.DatasetType == "derivatives"
- type(sidecar.Sources) != "null"
Expand Down

0 comments on commit 817454b

Please sign in to comment.