Skip to content

Commit

Permalink
fix(schema): Fix checks to reduce false positives (#1878)
Browse files Browse the repository at this point in the history
* fix(schema): Limit EVENTS_TSV_MISSING to data files

* fix(schema): Move VolumeTiming check into checks

* fix(schema): Associated file checks only apply to data files

* fix(schema): Improve targeting of B0Field* recommendations

* fix(schema): Improve targeting of MRIAnatomicalLandmarks

* fix(schema): Check sidecars of data files only

* fix(schema): NIRS SamplingFrequency check should look in sidecar
  • Loading branch information
effigies authored Jul 30, 2024
1 parent 6bd4458 commit b1be676
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ The definitions of the fields specified in these tables may be found in
A guide for using macros can be found at
https://github.com/bids-standard/bids-specification/blob/master/macros_doc.md
-->
{{ MACROS___make_sidecar_table("mri.MRIEchoPlanarImagingAndB0Mapping") }}
{{ MACROS___make_sidecar_table([
"mri.MRIB0FieldIdentifier",
"mri.MRIEchoPlanarImagingAndB0FieldSource",
])
}}

#### Tissue description

Expand Down
1 change: 1 addition & 0 deletions src/schema/rules/checks/events.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ EventsMissing:
- '"task" in entities'
- '!match(entities.task, "rest")'
- suffix != "events"
- extension != ".json"
checks:
- '"events" in associations'

Expand Down
3 changes: 3 additions & 0 deletions src/schema/rules/checks/fmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ EchoTime12DifferenceUnreasonable:
level: error
selectors:
- suffix == "phasediff"
- match(extension, '\.nii(\.gz)?$')
checks:
- sidecar.EchoTime2 - sidecar.EchoTime1 >= 0.0001
- sidecar.EchoTime2 - sidecar.EchoTime1 <= 0.01
Expand All @@ -22,6 +23,7 @@ FmapFieldmapWithoutMagnitude:
level: error
selectors:
- suffix == "fieldmap"
- match(extension, '\.nii(\.gz)?$')
checks:
- '"magnitude" in associations'

Expand All @@ -34,6 +36,7 @@ FmapPhasediffWithoutMagnitude:
level: warning
selectors:
- suffix == "phasediff"
- match(extension, '\.nii(\.gz)?$')
checks:
- '"magnitude1" in associations'

Expand Down
11 changes: 11 additions & 0 deletions src/schema/rules/checks/func.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,14 @@ SliceTimingAcquisitionDurationMutex:
checks:
- type(sidecar.AcquisitionDuration) == "null"
- type(sidecar.DelayTime) == "null"

VolumeTimingMissingAcquisitionDuration:
issue:
code: VOLUME_TIMING_MISSING_ACQUISITION_DURATION
message: |
The field 'VolumeTiming' requires 'AcquisitionDuration' or 'SliceTiming' to be defined.
level: error
selectors:
- type(sidecar.VolumeTiming) != "null"
checks:
- '"SliceTiming" in sidecar || "AcquisitionDuration" in sidecar'
3 changes: 2 additions & 1 deletion src/schema/rules/checks/nirs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
NASamplingFreq:
selectors:
- suffix == "nirs"
- samplingFrequency == "n/a"
- sidecar.SamplingFrequency == "n/a"
checks:
- associations.channels.sampling_frequency != null

NIRSChannelCount:
selectors:
- datatype == "nirs"
- suffix == "nirs"
- match(extension, '\.nii(\.gz)?$')
checks:
- |
sidecar.NIRSChannelCount
Expand Down
4 changes: 0 additions & 4 deletions src/schema/rules/sidecars/func.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ MRIFuncTimingParameters:
required for sequences that are described with the `VolumeTiming`
field and that do not have the `SliceTiming` field set to allow for
accurate calculation of "acquisition time"
issue:
code: VOLUME_TIMING_MISSING_ACQUISITION_DURATION
message: |
The field 'VolumeTiming' requires 'AcquisitionDuration' or 'SliceTiming' to be defined.
DelayAfterTrigger: recommended

# fMRI task information
Expand Down
14 changes: 11 additions & 3 deletions src/schema/rules/sidecars/mri.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -296,15 +296,23 @@ MRISliceAcceleration:

MRIAnatomicalLandmarks:
selectors:
- modality == "mri"
- datatype == "anat"
- intersects(dataset.datatypes, ["meg"])
fields:
AnatomicalLandmarkCoordinates__mri: recommended

MRIEchoPlanarImagingAndB0Mapping:
MRIB0FieldIdentifier:
selectors:
- modality == "mri"
- datatype == 'fmap'
- match(extension, '\.nii(\.gz)?$')
fields:
B0FieldIdentifier: recommended

MRIEchoPlanarImagingAndB0FieldSource:
selectors:
- intersects(datatype, ['dwi', 'func', 'perf'])
- intersects(dataset.datatypes, ['fmap'])
fields:
B0FieldSource: recommended

MRIInstitutionInformation:
Expand Down

0 comments on commit b1be676

Please sign in to comment.