-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: added populating order of entities from bids schema copy
- Loading branch information
1 parent
38032b5
commit de07958
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |