diff --git a/.codespellrc b/.codespellrc index 22cd48ca96..8eae2b3993 100644 --- a/.codespellrc +++ b/.codespellrc @@ -1,5 +1,7 @@ [codespell] skip = *.js,*.svg,*.eps,.git,node_modules,env,venv,.mypy_cache,package-lock.json,CITATION.cff,tools/new_contributors.tsv,./tools/schemacode/docs/build +# Ignore diff/git format-patch headings which could include truncated lines +ignore-regex = ^@@ -[0-9].*@@.* ignore-words-list = fo,te,als,Acknowledgements,acknowledgements,weill,bu,winn,manuel builtin = clear,rare,en-GB_to_en-US # this overloads default dictionaries and I have not yet figured out diff --git a/tools/bids-2.0/README.md b/tools/bids-2.0/README.md index 860fcb875a..c787bb7c7d 100644 --- a/tools/bids-2.0/README.md +++ b/tools/bids-2.0/README.md @@ -2,3 +2,19 @@ This directory to contain various little helpers which would script desired automated changes (where possible) for migrating specification (not datasets) to BIDS 2.0. Ideally scripts should have some header pointing to the underlying issue they are addressing. + +## `apply_all` + +`apply_all` script goes through `patches/` in a (numeric) sorted order +and applies those "patches". + +"patches" could be of two types: + +- an executable -- a script to be executed which introduces the changes. +- `.patch` - a regular patch which needs to be applied using `patch -p1` + +Typically for the same leading index (e.g. `01`) there would be a script and +then a patch to possibly manually tune up remaining changes. + +`apply_all` could also take an index -- then it would stop applying patches +having applied patches up to that index. diff --git a/tools/bids-2.0/apply_all b/tools/bids-2.0/apply_all index a605b222f6..b486317cab 100755 --- a/tools/bids-2.0/apply_all +++ b/tools/bids-2.0/apply_all @@ -1,5 +1,29 @@ #!/bin/bash +set -eu + +# hardcoding for now - relative path from the top +rpath=tools/bids-2.0 + path="$(dirname "$0")" +cd "$path/../.." # go to the top of bids-specification + +apply_until=${1:-} + +# harmonize appearance +if [ -n "$apply_until" ] ; then + apply_until=$(printf "%02d" "$apply_until") +fi -"$path/rename_participants_to_subjects" +/bin/ls "$rpath"/patches/[0-9]* | sort -n | while read p; do + if [ "${p##*.}" == "patch" ]; then + echo "I: apply $p" + patch -p1 < $p + elif [ -x "$p" ] ; then + echo "I: run $p" + $p + else + echo "E: Do not know how to handle patch $p" >&2 + exit 1 + fi +done diff --git a/tools/bids-2.0/rename_participants_to_subjects b/tools/bids-2.0/patches/01-01-rename_participants_to_subjects similarity index 100% rename from tools/bids-2.0/rename_participants_to_subjects rename to tools/bids-2.0/patches/01-01-rename_participants_to_subjects diff --git a/tools/bids-2.0/patches/01-02-rename_participants_to_subjects-fixup.patch b/tools/bids-2.0/patches/01-02-rename_participants_to_subjects-fixup.patch new file mode 100644 index 0000000000..3c90141eef --- /dev/null +++ b/tools/bids-2.0/patches/01-02-rename_participants_to_subjects-fixup.patch @@ -0,0 +1,53 @@ +From 087982854fd000f6cb9d321faf25c68e4a2f1b1c Mon Sep 17 00:00:00 2001 +From: Yaroslav Halchenko +Date: Fri, 12 Apr 2024 15:54:31 -0400 +Subject: [PATCH] Post fixes to apply_all to fix some indentations due to + participant -> subject + +--- + src/appendices/coordinate-systems.md | 6 +++--- + src/schema/README.md | 4 ++-- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/src/appendices/coordinate-systems.md b/src/appendices/coordinate-systems.md +index 9eb57359..9cb031b0 100644 +--- a/src/appendices/coordinate-systems.md ++++ b/src/appendices/coordinate-systems.md +@@ -233,10 +233,10 @@ described in [Common file level metadata fields][common file level metadata fiel + + In the case of multiple study templates, additional names may need to be defined. + +-| **Coordinate System** | **Description** | +-| --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ++| **Coordinate System** | **Description** | ++| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | + | individual | Subject specific anatomical space (for example derived from T1w and/or T2w images). This coordinate system requires specifying an additional, subject-specific file to be fully defined. In context of surfaces this space has been referred to as `fsnative`. | +-| study | Custom space defined using a group/study-specific template. This coordinate system requires specifying an additional file to be fully defined. | ++| study | Custom space defined using a group/study-specific template. This coordinate system requires specifying an additional file to be fully defined. | + + ### Non-template coordinate system identifiers + +diff --git a/src/schema/README.md b/src/schema/README.md +index 0a6d7a3c..7587f01d 100644 +--- a/src/schema/README.md ++++ b/src/schema/README.md +@@ -243,7 +243,7 @@ and provide the *namespace* in which expressions are evaluated. + The following operators should be defined by an interpreter: + + | Operator | Definition | Example | +-| ----------- | ------------------------------------------------------------- | --------------------------------------------- | ++| ----------- | ------------------------------------------------------------- |-----------------------------------------------| + | `==` | equality | `suffix == "T1w"` | + | `!=` | inequality | `entities.task != "rest"` | + | `<`/`>` | less-than / greater-than | `sidecar.EchoTime < 0.5` | +@@ -253,7 +253,7 @@ The following operators should be defined by an interpreter: + | `&&` | conjunction, true if both RHS and LHS are true | `"Units" in sidecar && sidecar.Units == "mm"` | + | `\|\|` | disjunction, true if either RHS or LHS is true | `a < mn \|\| a > mx` | + | `.` | object query, returns value of subfield | `sidecar.Units` | +-| `[]` | array/string index, returns value of Nth element (0-indexed) | `columns.subject_label[0]` | ++| `[]` | array/string index, returns value of Nth element (0-indexed) | `columns.subject_label[0]` | + | `+` | numeric addition / string concatenation | `x + 1`, `stem + "suffix"` | + | `-`/`*`/`/` | numeric operators (division coerces to float) | `length(array) - 2`, `x * 2`, `1 / 2 == 0.5` | + +-- +2.43.0