Skip to content

Commit

Permalink
Merge branch 'master' into mri-redundancies-really
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalo authored Sep 5, 2022
2 parents 11b64c1 + 8b53807 commit a25114a
Show file tree
Hide file tree
Showing 26 changed files with 321 additions and 398 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ share/python-wheels/
*.egg
MANIFEST

# Poetry requirements / packaging
/pyproject.toml

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
Expand Down
2 changes: 1 addition & 1 deletion src/schema/SCHEMA_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.1-dev
0.5.0-dev
6 changes: 6 additions & 0 deletions src/schema/meta/context.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
context:
type: object
properties:
schema:
description: 'The BIDS specification schema'
type: object
dataset:
description: 'Properties and contents of the entire dataset'
type: object
Expand All @@ -36,6 +39,9 @@ context:
ignored:
description: 'Set of ignored files'
type: array
datatypes:
description: 'Data types present in the dataset'
type: array
modalities:
description: 'Modalities present in the dataset'
type: array
Expand Down
210 changes: 118 additions & 92 deletions src/schema/objects/entities.yaml

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions src/schema/rules/checks/asl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ASLLabelingDurationNiftiLength:
- '"LabelingDuration" in sidecar'
- type(sidecar.LabelingDuration) == 'array'
checks:
- nifti_header.dim[4] == sidecar.LabelingDuration.length
- length(sidecar.LabelingDuration) == nifti_header.dim[4]

# 165
ASLContextConsistent:
Expand Down Expand Up @@ -57,7 +57,7 @@ ASLFlipAngleNiftiLength:
- '"FlipAngle" in sidecar'
- type(sidecar.FlipAngle) == 'array'
checks:
- nifti_header.dim[4] == sidecar.FlipAngle.length
- length(sidecar.FlipAngle) == nifti_header.dim[4]

# 172
ASLFlipAngleASLContextLength:
Expand All @@ -79,7 +79,7 @@ ASLFlipAngleASLContextLength:
- '"FlipAngle" in sidecar'
- type(sidecar.FlipAngle) == 'array'
checks:
- aslcontext.n_rows == sidecar.FlipAngle.length
- length(sidecar.FlipAngle) == aslcontext.n_rows

# 173
ASLPostLabelingDelayNiftiLength:
Expand All @@ -103,7 +103,7 @@ ASLPostLabelingDelayNiftiLength:
- '"aslcontext" in associations'
- type(sidecar.PostLabelingDelay) == 'array'
checks:
- nifti_header.pixdim[4] == sidecar.PostLabelingDelay.length
- length(sidecar.PostLabelingDelay) == nifti_header.dim[4]

# 174
ASLPostLabelingDelayASLContextLength:
Expand All @@ -127,7 +127,7 @@ ASLPostLabelingDelayASLContextLength:
- '"aslcontext" in associations'
- type(sidecar.PostLabelingDelay) == 'array'
checks:
- aslcontext.n_rows == sidecar.PostLabelingDelay.length
- length(sidecar.PostLabelingDelay) == aslcontext.n_rows

# 175
ASLLabelingDurationASLContextLength:
Expand All @@ -153,7 +153,7 @@ ASLLabelingDurationASLContextLength:
- '"LabelingDuration" in sidecar'
- type(sidecar.LabelingDuration) == 'array'
checks:
- aslcontext.n_rows == sidecar.LabelingDuration.length
- length(sidecar.LabelingDuration) == aslcontext.n_rows

# 177
ASLRepetitionTimePreparationASLContextLength:
Expand All @@ -174,7 +174,7 @@ ASLRepetitionTimePreparationASLContextLength:
- '"RepetitionTimePreparation" in sidecar'
- type(sidecar.RepetitionTimePreparation) == 'array'
checks:
- aslcontext.n_rows == sidecar.RepetitionTimePreparation.length
- length(sidecar.RepetitionTimePreparation) == aslcontext.n_rows

# 180
ASLBackgroundSuppressionNumberPulses:
Expand All @@ -192,7 +192,7 @@ ASLBackgroundSuppressionNumberPulses:
- '"BackgroundSuppressionPulseTime" in sidecar'
- type(sidecar.BackgroundSuppressionPulseTime) == 'array'
checks:
- sidecar.BackgroundSuppressionPulseTime.length == sidecar.BackgroundSuppressionNumberPulses
- length(sidecar.BackgroundSuppressionPulseTime) == sidecar.BackgroundSuppressionNumberPulses

# 181
ASLTotalAcquiredVolumesASLContextLength:
Expand Down Expand Up @@ -226,7 +226,7 @@ ASLEchoTimeASLContextLength:
- '"EchoTime" in sidecar'
- type(sidecar.EchoTime) == 'array'
checks:
- aslcontext.n_rows == sidecar.EchoTime.length
- length(sidecar.EchoTime) == aslcontext.n_rows

# 198
ASLM0TypeAbsentScan:
Expand Down Expand Up @@ -256,7 +256,7 @@ ASLM0TypeAbsentASLContext:
selectors:
- suffix == "asl"
- '"aslcontext" in associations'
- aslcontext.volume_type.includes('"m0scan")
- intersects(aslcontext.volume_type, ["m0scan"])
- '"M0Type" in sidecar'
checks:
- sidecar.M0Type != "absent"
Expand Down
47 changes: 26 additions & 21 deletions src/schema/rules/checks/dwi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
---
# 29
DWIVolumeCount:
code: VOLUME_COUNT_MISMATCH
description: |
The number of volumes in this scan does not match the number of volumes in the
corresponding .bvec and .bval files.
level: error
issue:
code: VOLUME_COUNT_MISMATCH
message: |
The number of volumes in this scan does not match the number of volumes in the
corresponding .bvec and .bval files.
level: error
selectors:
- suffix == "dwi"
- '"bval" in associations'
Expand All @@ -17,43 +18,47 @@ DWIVolumeCount:

# 30
DWIBvalRows:
code: BVAL_MULTIPLE_ROWS
description: |
'.bval' files should contain exactly one row of volumes.
level: error
issue:
code: BVAL_MULTIPLE_ROWS
message: |
'.bval' files should contain exactly one row of volumes.
level: error
selectors:
- extension == "bval"
checks:
- data.n_rows == 1

# 31
DWIBvecRows:
code: BVEC_NUMBER_ROWS
description: |
'.bvec' files should contain exactly three rows of volumes.
level: error
issue:
code: BVEC_NUMBER_ROWS
message: |
'.bvec' files should contain exactly three rows of volumes.
level: error
selectors:
- extension == "bvec"
checks:
- data.n_rows == 3

# 32
DWIMissingBvec:
code: DWI_MISSING_BVEC
description: |
DWI scans must have a corresponding .bvec file.
level: error
issue:
code: DWI_MISSING_BVEC
message: |
DWI scans must have a corresponding .bvec file.
level: error
selectors:
- suffix == "dwi"
checks:
- '"bvec" in associations'

# 33
DWIMissingBval:
code: DWI_MISSING_BVAL
description: |
DWI scans must have a corresponding .bval file.
level: error
issue:
code: DWI_MISSING_BVAL
message: |
DWI scans must have a corresponding .bval file.
level: error
selectors:
- suffix == "dwi"
checks:
Expand Down
2 changes: 1 addition & 1 deletion src/schema/rules/checks/events.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ EventsMissing:
level: warning # could be an error with the proper selectors, I think
selectors:
- '"task" in entities'
- '!(entities.task.includes("rest"))'
- '!matches(entities.task, "rest")'
- suffix != "events"
checks:
- '"events" in associations'
2 changes: 1 addition & 1 deletion src/schema/rules/checks/func.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ PhaseSuffixDeprecated:
selectors:
- datatype == "func"
checks:
- '!(suffix == "phase")'
- suffix != "phase"
14 changes: 14 additions & 0 deletions src/schema/rules/checks/mri.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
PhasePartUnits:
issue:
code: PHASE_UNITS
message: |
Phase images (with the `part-phase` entity) must have units
"rad" or "arbitrary".
level: error
selectors:
- modality == "mri"
- entities.part == "phase"
- '"Units" in sidecar'
checks:
- intersects([sidecar.Units], ["rad", "arbitrary"])
8 changes: 4 additions & 4 deletions src/schema/rules/common_derivatives_validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
ResInSidecar:
selectors:
- dataset.dataset_description.DatasetType == "derivative"
- '["mri", "pet"].includes(modality)'
- '["nii", " nii.gz"].includes(extension)'
- intersects([modality], ["mri", "pet"])
- match(extension, '^\.nii(\.gz)?$')
- type(sidecar.Resolution) == "object"
checks:
- entities.resolution in sidecar.Resolution

DenInSidecar:
selectors:
- dataset.dataset_description.DatasetType == "derivative"
- '["mri", "pet"].includes(modality)'
- '[".nii", ".nii.gz"].includes(extension)'
- intersects([modality], ["mri", "pet"])
- match(extension, '^\.nii(\.gz)?$')
- type(sidecar.Density) == "object"
checks:
- entities.density in sidecar.Density
2 changes: 1 addition & 1 deletion src/schema/rules/dataset_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ derivative_description:
dataset_description_with_genetics:
selectors:
- path == "/dataset_description.json"
- 'dataset.files.includes("/genetic_info.json")'
- intersects(dataset.files, ["/genetic_info.json"])
fields:
Genetics: required
Genetics{}.Dataset:
Expand Down
10 changes: 5 additions & 5 deletions src/schema/rules/errors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ NiftiHeaderUnreadable:
Please ensure it is not corrupted or mislabeled.
level: error
selectors:
- '[".nii", ".nii.gz"].includes(extension)'
- match(extension, '^\.nii(\.gz)?$')

# BIDS Validator Original Issue Code #27
JsonInvalid:
Expand All @@ -27,7 +27,7 @@ GzNotGzipped:
This file ends in the .gz extension but is not actually gzipped.
level: error
selectors:
- extension.includes(".gz")
- match(extension, '\.gz$')

# BIDS Validator Original Issue Code #30
BvalMultipleRows:
Expand All @@ -54,7 +54,7 @@ NiftiTooSmall:
This file is too small to contain the minimal NIfTI header.
level: error
selectors:
- '[".nii", ".nii.gz"].includes(extension)'
- match(extension, '^\.nii(\.gz)?$')

# BIDS Validator Original Issue Code #43
OrphanedSymlink:
Expand Down Expand Up @@ -90,7 +90,7 @@ BFile:
and contain only numerical values.
level: error
selectors:
- '[".bval", ".bvec"].includes(extension)'
- intersects([extension], [".bval", ".bvec"])

# BIDS Validator Original Issue Code #55
JsonSchemaValidationError:
Expand Down Expand Up @@ -175,7 +175,7 @@ BrainvisionLinksBroken:
and *.vmrk) are broken or some files do not exist.
level: error
selectors:
- '[ ".eeg", ".vhdr", ".vmrk"].includes(extension)'
- intersects([extension], [".eeg", ".vhdr", ".vmrk"])

# BIDS Validator Original Issue Code #104
HedError:
Expand Down
6 changes: 3 additions & 3 deletions src/schema/rules/sidecars/anat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

MRIAnatomyCommonMetadataFields:
selectors:
- modality == "MRI"
- modality == "mri"
- datatype == "anat"
fields:
ContrastBolusIngredient: optional
Expand All @@ -18,15 +18,15 @@ MRIAnatomyCommonMetadataFields:

PhaseEntityUnits:
selectors:
- modality == "MRI"
- modality == "mri"
- datatype == "anat"
- entities.part == "phase"
fields:
Units: required

PhaseSuffixUnits:
selectors:
- modality == "MRI"
- modality == "mri"
- datatype == "anat"
- suffix == "phase"
fields:
Expand Down
Loading

0 comments on commit a25114a

Please sign in to comment.