Skip to content

Commit

Permalink
ENH: added populating order of entities from bids schema copy
Browse files Browse the repository at this point in the history
  • Loading branch information
yarikoptic committed Feb 7, 2022
1 parent 38032b5 commit de07958
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions heudiconv/bids/schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from pathlib import Path
import yaml


def _load_entities_order():
# we carry the copy of the schema
schema_p = Path(__file__).parent / "data" / "schema"
with (schema_p / "objects" / "entities.yaml").open() as f:
entities = yaml.load(f)

with (schema_p / "rules" / "entities.yaml").open() as f:
entities_full_order = yaml.load(f)

# map from full name to short "entity"
return [entities[e]["entity"] for e in entities_full_order]


class BIDSFile:
""" as defined in https://bids-specification.readthedocs.io/en/stable/99-appendices/04-entity-table.html
which might soon become machine readable
order matters
"""

_known_entities = _load_entities_order()


# TEMP: just for now, could be moved/removed
def test_BIDSFile():
assert BIDSFile._known_entities[:2] == ['sub', 'ses']
print(BIDSFile._known_entities)

0 comments on commit de07958

Please sign in to comment.