Skip to content

Commit de07958

Browse files
committed
ENH: added populating order of entities from bids schema copy
1 parent 38032b5 commit de07958

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

heudiconv/bids/schema.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from pathlib import Path
2+
import yaml
3+
4+
5+
def _load_entities_order():
6+
# we carry the copy of the schema
7+
schema_p = Path(__file__).parent / "data" / "schema"
8+
with (schema_p / "objects" / "entities.yaml").open() as f:
9+
entities = yaml.load(f)
10+
11+
with (schema_p / "rules" / "entities.yaml").open() as f:
12+
entities_full_order = yaml.load(f)
13+
14+
# map from full name to short "entity"
15+
return [entities[e]["entity"] for e in entities_full_order]
16+
17+
18+
class BIDSFile:
19+
""" as defined in https://bids-specification.readthedocs.io/en/stable/99-appendices/04-entity-table.html
20+
which might soon become machine readable
21+
order matters
22+
"""
23+
24+
_known_entities = _load_entities_order()
25+
26+
27+
# TEMP: just for now, could be moved/removed
28+
def test_BIDSFile():
29+
assert BIDSFile._known_entities[:2] == ['sub', 'ses']
30+
print(BIDSFile._known_entities)

0 commit comments

Comments
 (0)