Skip to content

Commit

Permalink
fix(schema): Add issues for NIRS checks
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Aug 5, 2024
1 parent c5cb8ee commit 02049c5
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/schema/meta/context.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,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
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

0 comments on commit 02049c5

Please sign in to comment.