bids-standard / legacy-validator

Validator for the Brain Imaging Data Structure
https://bids-standard.github.io/legacy-validator/
MIT License
186 stars 111 forks source link

fix(cli): Allow blacklisting any modality from schema.rules.modalities #2176

Closed effigies closed 1 month ago

effigies commented 1 month ago

Before:

  --blacklistModalities  <modalities...>  - Array of modalities to error on if detected.                                    (Default: [], Values: "MRI", "PET", "MEG", "EEG", "iEEG",
                                                                                                                            "Microscopy", "NIRS", "MRS")

After:

  --blacklistModalities  <modalities...>  - Array of modalities to error on if detected.                                    (Default: [], Values: "mri", "eeg", "ieeg", "meg", "beh",
                                                                                                                            "pet", "micr", "motion", "nirs", "mrs")

We previously used "Microscopy", but we looked up the value from schema.rules.modalities, so that would fail. We could map the display names, but I don't think it will hurt anybody to use micr. We also weren't supporting motion.

This won't help with patched schemas introducing new modalities, but blacklisting a modality introduced by a patch seems like an extremely niche use case. It would be nice if we could get the suggested values without actually limiting, as there's no harm in blacklisting something that doesn't exist. But the main use case would be OpenNeuro blacklisting a modality, and we skip over argument parsing and call validate() directly.

This PR adds a check so that tools calling via the API will warn, not crash, if passing an unknown modality.

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.

Project coverage is 87.48%. Comparing base (f40d4de) to head (525163b). Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
bids-validator/src/validators/bids.ts 71.42% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master bids-standard/legacy-validator#2176 +/- ## ========================================== + Coverage 85.72% 87.48% +1.75% ========================================== Files 91 133 +42 Lines 3784 7055 +3271 Branches 1221 1671 +450 ========================================== + Hits 3244 6172 +2928 - Misses 454 788 +334 - Partials 86 95 +9 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.