Skip to content

[BUG] Invalid schema (bad yaml file) #2060

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

Closed
dipterix opened this issue Feb 19, 2025 · 4 comments
Closed

[BUG] Invalid schema (bad yaml file) #2060

dipterix opened this issue Feb 19, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@dipterix
Copy link

Describe your problem in detail.

YAML 1.1 interprets y:... as key true instead of literal y, hence this enum will be interpreted as

{true: {
  value: true,
  display_name: true,
  ...
}}

Describe what you expected.

Suggested change:

x:
  value: x
  display_name: x
  description: |
    The x dimension of the coordinate system.
"y":
  value: "y"
  display_name: "y"
  description: |
    The y dimension of the coordinate system.
z:
  value: z
  display_name: z
  description: |
    The z dimension of the coordinate system.

BIDS specification section

https://bids-specification.readthedocs.io/en/latest/...

@dipterix dipterix added the bug Something isn't working label Feb 19, 2025
@dipterix dipterix changed the title [BUG] Invalid schema [BUG] Invalid schema (bad yaml file) Feb 19, 2025
@effigies
Copy link
Collaborator

It seems to have done the right thing when converted to JSON:

Image

https://bids-specification.readthedocs.io/en/latest/schema.json

We don't generally expect people to parse the YAML separately. What is the context where you're hitting problems?

Anyway, we can definitely accept a patch to use quotes. Would be worth adding a comment so they don't get removed in the future.

@dipterix
Copy link
Author

dipterix commented Feb 20, 2025

Ah I see. I'm using the json now. Thanks!

Can I ask two questions here?

First question is I found that schema.rules.files.raw.anat.nonparametric is identical to schema.rules.files.deriv.imaging.anat_nonparametric_volumetric, I wonder what's the key (unique ID) for the entity table? Somehow I thought the datatype+suffix consists the unique key for the entity table. Now I'm not sure...

The second question is that I'm trying to implement some basic rules from schema so I don't have to maintain them manually when BIDS version changes. I noticed that in schema, there are the following "contexts": (according to https://bidsschematools.readthedocs.io/en/latest/description.html#on-reused-objects-with-different-definitions <term>_<context> syntax, e.g. timeseries__mri_no_task)

 [1] "scans"         "sessions"      "channels"      "optode"        "entities"      "channel"      
 [7] "electrodes"    "optodes"       "segmentations" "motion"        "eeg"           "ieeg"         
[13] "nirs"          "mtransfer"     "mri"           "coordsystem"   "fmap"          "ds_relative"  
[19] "mrs"           "meg_common"    "motion_common" "eeg_common"    "meg"           "micr"         
[25] "mri_no_task"   "pet"           "anat"          "func"    

I wonder where can I get these context string, or how are they defined?

@effigies
Copy link
Collaborator

First question is I found that schema.rules.files.raw.anat.nonparametric is identical to schema.rules.files.deriv.imaging.anat_nonparametric_volumetric, I wonder what's the key (unique ID) for the entity table? Somehow I thought the datatype+suffix consists the unique key for the entity table.

The difference between these is that anat_nonparametric_volumetric should also have space, desc, resolution and density entities, and is valid if dataset_description.DatasetType == "derivative":

anat_parametric_volumetric:
$ref: rules.files.raw.anat.parametric
entities:
$ref: rules.files.raw.anat.parametric.entities
space: optional
resolution: optional
density: optional
description: optional

There's discussion in #2052 about adding explicit selectors to file rules.

The second question is that I'm trying to implement some basic rules from schema so I don't have to maintain them manually when BIDS version changes. I noticed that in schema, there are the following "contexts": (according to https://bidsschematools.readthedocs.io/en/latest/description.html#on-reused-objects-with-different-definitions <term>_<context> syntax, e.g. timeseries__mri_no_task)

 [1] "scans"         "sessions"      "channels"      "optode"        "entities"      "channel"      
 [7] "electrodes"    "optodes"       "segmentations" "motion"        "eeg"           "ieeg"         
[13] "nirs"          "mtransfer"     "mri"           "coordsystem"   "fmap"          "ds_relative"  
[19] "mrs"           "meg_common"    "motion_common" "eeg_common"    "meg"           "micr"         
[25] "mri_no_task"   "pet"           "anat"          "func"    

They're not defined. They're just mnemonics for giving the terms unique names, which allows them to be referenced elsewhere in the schema.

@dipterix
Copy link
Author

Got it. So there are rules for which schema to be used based on context, but they are not yet stale. Thanks for answering my questions promptly, and I will watch/follow up on issue 2052 from now on.

Please feel free to close this comment as all questions have been addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants