-
Notifications
You must be signed in to change notification settings - Fork 4
Align with BIDS nomenclature and resync from schema (#21) #27
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| { | ||
| "entities": [ | ||
| { | ||
| "name": "bp", | ||
| "display_name": "bodypart", | ||
| "key": "bp", | ||
| "name": "bodypart", | ||
| "pattern": "*(_bp-+([a-zA-Z0-9]))" | ||
| } | ||
| ] | ||
| } | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,25 +1,57 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Regenerate every schema-derived block used by libBIDS.sh from schema.json. | ||
| # schema.json is the authoritative BIDS specification source; treat it as the | ||
| # single source of truth and paste the blocks below into libBIDS.sh verbatim. | ||
| # | ||
| # BIDS nomenclature (see schema objects.entities): | ||
| # entity key = schema .name (e.g. "sub") -> filename token | ||
| # entity name = schema object key (e.g. "subject") -> table column header | ||
| # rules.entities provides the canonical filename ordering of entities. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| entities_order=($(jq -r .rules.entities.[] schema.json)) | ||
| entities_names_ordered=() | ||
| # Entities, in canonical BIDS filename order (rules.entities). | ||
| mapfile -t entity_names < <(jq -r '.rules.entities[]' schema.json) | ||
| entity_keys=() | ||
|
|
||
| for entity in ${entities_order[@]}; do | ||
| entity_name=$(jq -r .objects.entities.${entity}.name schema.json) | ||
| entities_names_ordered+=(${entity_name}) | ||
| entity_format=$(jq -r .objects.entities.${entity}.format schema.json) | ||
| echo "### entities=( ) glob patterns ###" | ||
| for entity in "${entity_names[@]}"; do | ||
| entity_key=$(jq -r ".objects.entities.${entity}.name" schema.json) | ||
| entity_keys+=("${entity_key}") | ||
| entity_format=$(jq -r ".objects.entities.${entity}.format" schema.json) | ||
| if [[ ${entity_format} == "label" ]]; then | ||
| echo \""*(_${entity_name}-+([a-zA-Z0-9]))"\" | ||
| echo " \"*(_${entity_key}-+([a-zA-Z0-9]))\"" | ||
| elif [[ ${entity_format} == "index" ]]; then | ||
| echo \""*(_${entity_name}-+([0-9]))"\" | ||
| echo " \"*(_${entity_key}-+([0-9]))\"" | ||
| else | ||
| echo "Unrecognized entity_format ${entity_format}" 1>&2 | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| printf "%s," ${entities_order[@]} | ||
| echo | ||
| printf "%s " ${entities_names_ordered[@]} | ||
| echo "### entities_order (entity keys, space separated) ###" | ||
| printf "%s " "${entity_keys[@]}" | ||
| echo | ||
|
|
||
| echo | ||
| echo "### entities_name_order (entity names / column headers, tab separated) ###" | ||
| printf "%s" "${entity_names[0]}" | ||
| printf "\\\\t%s" "${entity_names[@]:1}" | ||
| echo | ||
|
|
||
| echo | ||
| echo "### suffixes alternation ###" | ||
| printf '_@(%s)\n' "$(jq -r '.objects.suffixes[].value' schema.json | paste -sd'|')" | ||
|
|
||
| echo | ||
| echo "### extensions alternation (drops '.*' and '/', strips trailing '/') ###" | ||
| printf '@(%s)\n' "$(jq -r '.objects.extensions[].value' schema.json \ | ||
| | grep -vxF -e '.*' -e '/' -e '' \ | ||
| | sed 's:/$::' \ | ||
| | paste -sd'|')" | ||
|
|
||
| echo | ||
| echo "### datatype regex (for _libBIDSsh_parse_filename) ###" | ||
| printf '(%s)\n' "$(jq -r '.objects.datatypes | keys[]' schema.json | paste -sd'|')" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the required key/name/display-name reference table to README.
The section explains the terminology, but the guideline explicitly requires a reference table in
README.md. Please add a small table (key/name/display-name/example usage) near Line 55.As per coding guidelines: "
README.md: Documentation must clearly distinguish between entity keys, entity names, and entity display names, with a reference table in README.md".Also applies to: 67-67
🤖 Prompt for AI Agents
Source: Coding guidelines