Skip to content

Commit

Permalink
Fix up files w.r.t. recent entity name-changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalo committed Oct 2, 2020
1 parent d6d9213 commit 8c9e8de
Show file tree
Hide file tree
Showing 15 changed files with 98 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ actual anatomical nasion: `sub-0001_ses-001_acq-NAS_photo.jpg`

Template:

{{ make_filename_template(datatypes=["meg"], auxdatatypes=["headshape"]) }}
{{ make_filename_template(datatypes=["meg"], suffixes=["headshape"]) }}

```Text
sub-<label>/
Expand Down
2 changes: 1 addition & 1 deletion src/99-appendices/04-entity-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ while entity definitions are in [Appendix IX](09-entities.md).

## Magnetoencephalography (MEG)

{{ make_entity_table(datatypes=["meg"]) }}
{{ make_entity_table(datatypes=["meg"], auxdatatypes=["channels", "events", "photo"]) }}

## Behavioral Data

Expand Down
4 changes: 2 additions & 2 deletions src/schema/auxdatatypes/channels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
- .json
- .tsv
entities:
sub: required
ses: optional
subject: required
session: optional
task: required
run: optional
6 changes: 3 additions & 3 deletions src/schema/auxdatatypes/electrodes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- .json
- .tsv
entities:
sub: required
ses: optional
acq: optional
subject: required
session: optional
acquisition: optional
space: optional
4 changes: 2 additions & 2 deletions src/schema/auxdatatypes/events.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
- .json
- .tsv
entities:
sub: required
ses: optional
subject: required
session: optional
task: required
run: optional
6 changes: 3 additions & 3 deletions src/schema/auxdatatypes/photo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
extensions:
- .jpg
entities:
sub: required
ses: optional
acq: optional
subject: required
session: optional
acquisition: optional
22 changes: 11 additions & 11 deletions src/schema/datatypes/anat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
- .nii
- .json
entities:
sub: required
ses: optional
subject: required
session: optional
run: optional
acq: optional
ce: optional
rec: optional
acquisition: optional
ceagent: optional
reconstruction: optional
# Second group
- suffixes:
- defacemask
Expand All @@ -34,10 +34,10 @@
- .nii
- .json
entities:
sub: required
ses: optional
subject: required
session: optional
run: optional
acq: optional
ce: optional
rec: optional
mod: optional
acquisition: optional
ceagent: optional
reconstruction: optional
modality: optional
12 changes: 6 additions & 6 deletions src/schema/datatypes/beh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
- .tsv.gz
- .json
entities:
sub: required
ses: optional
subject: required
session: optional
task: required
acq: optional
acquisition: optional
run: optional
recording: optional
# Second group
Expand All @@ -21,8 +21,8 @@
- .tsv
- .json
entities:
sub: required
ses: optional
subject: required
session: optional
task: required
acq: optional
acquisition: optional
run: optional
16 changes: 8 additions & 8 deletions src/schema/datatypes/dwi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
- .bvec
- .bval
entities:
sub: required
ses: optional
acq: optional
dir: optional
subject: required
session: optional
acquisition: optional
direction: optional
run: optional
# Second group
- suffixes:
Expand All @@ -22,8 +22,8 @@
- .nii
- .json
entities:
sub: required
ses: optional
acq: optional
dir: optional
subject: required
session: optional
acquisition: optional
direction: optional
run: optional
6 changes: 3 additions & 3 deletions src/schema/datatypes/eeg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
- .fdt
- .bdf
entities:
sub: required
ses: optional
subject: required
session: optional
task: required
acq: optional
acquisition: optional
run: optional
16 changes: 8 additions & 8 deletions src/schema/datatypes/fmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
- .nii
- .json
entities:
sub: required
ses: optional
acq: optional
subject: required
session: optional
acquisition: optional
run: optional
# Second group
- suffixes:
Expand All @@ -25,9 +25,9 @@
- .nii
- .json
entities:
sub: required
ses: optional
acq: optional
ce: optional
dir: required
subject: required
session: optional
acquisition: optional
ceagent: optional
direction: required
run: optional
32 changes: 16 additions & 16 deletions src/schema/datatypes/func.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
- .nii
- .json
entities:
sub: required
ses: optional
subject: required
session: optional
task: required
acq: optional
ce: optional
rec: optional
dir: optional
acquisition: optional
ceagent: optional
reconstruction: optional
direction: optional
run: optional
echo: optional
# Second group
Expand All @@ -26,13 +26,13 @@
- .tsv
- .json
entities:
sub: required
ses: optional
subject: required
session: optional
task: required
acq: optional
ce: optional
rec: optional
dir: optional
acquisition: optional
ceagent: optional
reconstruction: optional
direction: optional
run: optional
echo: optional
# Third group
Expand All @@ -43,10 +43,10 @@
- .tsv.gz
- .json
entities:
sub: required
ses: optional
subject: required
session: optional
task: required
acq: optional
rec: optional
acquisition: optional
reconstruction: optional
run: optional
recording: optional
6 changes: 3 additions & 3 deletions src/schema/datatypes/ieeg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
- .fdt
- .nwb
entities:
sub: required
ses: optional
subject: required
session: optional
task: required
acq: optional
acquisition: optional
run: optional
30 changes: 20 additions & 10 deletions src/schema/datatypes/meg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
- .kdf
- .mhd
entities:
sub: required
ses: optional
subject: required
session: optional
task: required
acq: optional
acquisition: optional
run: optional
proc: optional
processing: optional
split: optional
# Second group
- suffixes:
Expand All @@ -29,17 +29,27 @@
- .pos
- .txt
entities:
sub: required
ses: optional
acq: optional
subject: required
session: optional
acquisition: optional
space: optional
# Third group
- suffixes:
- markers
extensions:
- .json
entities:
sub: required
ses: optional
subject: required
session: optional
task: optional
acq: optional
acquisition: optional
space: optional
# Fourth
- suffixes:
- coordsystem
extensions:
- .json
entities:
subject: required
session: optional
acquisition: optional
17 changes: 11 additions & 6 deletions tools/schemacode/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from itertools import chain
from pathlib import Path
from warnings import warn
from pprint import pprint

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -98,7 +99,7 @@ def make_entity_definitions(schema):
text += "\n\n"
text += "Full name: {}".format(entity_info["name"])
text += "\n\n"
text += "Format: `{}-<{}>`".format(entity, entity_info["format"])
text += "Format: `{}-<{}>`".format(entity_info["entity"], entity_info["format"])
text += "\n\n"
text += "Definition: {}".format(entity_info["description"])
return text
Expand Down Expand Up @@ -137,9 +138,9 @@ def build_filename_format(schema, **kwargs):
# Parent folders
paragraph += "{}-{}/[{}-{}/]\n".format(
"sub",
"<" + schema["entities"]["sub"]["format"] + ">",
"<" + schema["entities"]["subject"]["format"] + ">",
"ses",
"<" + schema["entities"]["ses"]["format"] + ">",
"<" + schema["entities"]["session"]["format"] + ">",
)

for datatype in schema["datatypes"].keys():
Expand All @@ -149,7 +150,8 @@ def build_filename_format(schema, **kwargs):
for group in schema["datatypes"][datatype]:
string = "\t\t"
for ent in entities:
ent_format = "{}-<{}>".format(ent, schema["entities"][ent]["format"])
entity_shorthand = schema["entities"][ent]["entity"]
ent_format = "{}-<{}>".format(entity_shorthand, schema["entities"][ent]["format"])
if ent in group["entities"]:
if group["entities"][ent] == "required":
if len(string.strip()):
Expand Down Expand Up @@ -179,7 +181,8 @@ def build_filename_format(schema, **kwargs):
new_string = string + extension
full_strings.append(new_string)
full_strings = sorted(full_strings)
paragraph += "\n".join(full_strings) + "\n"
if full_strings:
paragraph += "\n".join(full_strings) + "\n"
paragraph = paragraph.rstrip()
codeblock = "```Text\n" + paragraph + "\n```"
codeblock = codeblock.expandtabs(4)
Expand Down Expand Up @@ -219,8 +222,10 @@ def make_entity_table(schema, tablefmt="github", **kwargs):

# Compose header and formats first
for i, (entity, spec) in enumerate(schema["entities"].items()):
entity_shorthand = schema["entities"][entity]["entity"]
header.append(spec["name"])
formats.append(f'[`{entity}-<{spec["format"]}>`]' f"({ENTITIES_FILE}#{entity})")
formats.append(f'[`{entity_shorthand}-<{spec["format"]}>`]'
f"({ENTITIES_FILE}#{entity})")
entity_to_col[entity] = i + 1

# Go through data types
Expand Down

2 comments on commit 8c9e8de

@soichih
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change from "sub" to "subjects", "ses" to "session" broke our application, mainly because entities.yaml still uses the old entity names "sub", "ses", etc..

subject:
  name: Subject
  entity: sub
  description: |
    A person or animal participating in the study.
  format: label

https://github.com/bids-standard/bids-specification/blob/master/src/schema/entities.yaml#L4

@tsalo are you planning to update entities.yaml so that it will contain "entity: subject" (a bit redundant?), or am I supposed to lookup the entity definition using the object key "subject", then find the actual entity name (in this case "sub")?

In my humble opinion, though.. "sub" is actually the correct entity name as it is used as part of BIDS filenames and documented as "entity". Why was this update made?

@Remi-Gau
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tsalo are you planning to update entities.yaml so that it will contain "entity: subject" (a bit redundant?), or am I supposed to lookup the entity definition using the object key "subject", then find the actual entity name (in this case "sub")?

Yeah it did break things on the bids-matlab front and I ended up looking up the entity definitions to fix things. From my understanding the bids-schema is still not stable yet so I think that we should expect a few more things to break while the final form of the schema is being ironed out.

@tsalo recently reminded me of the to do list on the schema: #620 (comment)

I suspect the more help we can give on this, the faster we'll to a sea of stability. :-)

Please sign in to comment.