Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SCHEMA] Proposal: Add selectors to file rules #2052

Open
effigies opened this issue Feb 13, 2025 · 1 comment · May be fixed by #2079
Open

[SCHEMA] Proposal: Add selectors to file rules #2052

effigies opened this issue Feb 13, 2025 · 1 comment · May be fixed by #2079

Comments

@effigies
Copy link
Collaborator

We could consider putting selectors in filename rules to achieve this. Something like:

stimuli_default:
  selectors:
    - '!exists("stimuli/stimuli.tsv", "dataset")'
  datatypes:
    - stimuli
  stem:
    - '*'
  extensions:
    - '*'

audio:
  selectors:
    - exists("stimuli/stimuli.tsv", "dataset")
  suffixes:
    - audio
  extensions:
    - .wav
    - .mp3
    - .aac
    - .ogg
  datatypes:
    - stimuli
  entities:
    - stim: required
    - part: optional

...

Originally posted by @effigies in #1828

The above proposal considers the case where the contents of stimuli/ may be free-form or structured, depending on a condition. This is necessary to preserve backwards compatibility while extending BIDS principles into previously un-managed areas.

This is also the basic problem we had with derivatives, which we resolved by creating the rules.files.derivatives branch. With this proposal, we could use dataset.description.DatasetType != 'raw' (or similar) to indicate rules that are invalid in raw but permissible in derivative datasets.

cc @rwblair @nellh @tsalo @bids-standard/schema-users

@rwblair
Copy link
Member

rwblair commented Feb 13, 2025

This seems workable. To capture non audio files when stimuli.tsv exists the first selector could be modified with:

stimuli_default:
  selectors:
    - '!exists("stimuli/stimuli.tsv", "dataset")' || suffix != "audio"
  datatypes:
    - stimuli
  stem:
    - '*'
  extensions:
    - '*'

audio:
  selectors:
    - exists("stimuli/stimuli.tsv", "dataset")
  suffixes:
    - audio
  extensions:
    - .wav
    - .mp3
    - .aac
    - .ogg
  datatypes:
    - stimuli
  entities:
    - stim: required
    - part: optional

With respect to the JS validator we could apply the selectors in filenameIdentify.ts findRuleMatches, this is where we currently filter out derivative rules from the schema for raw datasets. I believe the context will be sufficiently populated by this time to handle any variables that can be used in selectors.

We could imagine folding all path, stem and suffixes entries into the selectors, this is how the JS validator makes its initial guess at what potential rules might apply to a given filename. (then making the other entries into traditional checks?) I don't think we should do this, I'm not seeing the immediate benefit other that conceptual harmony among all rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants