Skip to content

Commit dd17442

Browse files
committed
RF patching so we can run 'script patches' and also apply direct patches
1 parent 05f267b commit dd17442

File tree

5 files changed

+96
-1
lines changed

5 files changed

+96
-1
lines changed

.codespellrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[codespell]
22
skip = *.js,*.svg,*.eps,.git,node_modules,env,venv,.mypy_cache,package-lock.json,CITATION.cff,tools/new_contributors.tsv,./tools/schemacode/docs/build
3+
# Ignore diff/git format-patch headings which could include truncated lines
4+
ignore-regex = ^@@ -[0-9].*@@.*
35
ignore-words-list = fo,te,als,Acknowledgements,acknowledgements,weill,bu,winn,manuel
46
builtin = clear,rare,en-GB_to_en-US
57
# this overloads default dictionaries and I have not yet figured out

tools/bids-2.0/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,19 @@ This directory to contain various little helpers which would script desired
22
automated changes (where possible) for migrating specification (not datasets)
33
to BIDS 2.0. Ideally scripts should have some header pointing to the
44
underlying issue they are addressing.
5+
6+
## `apply_all`
7+
8+
`apply_all` script goes through `patches/` in a (numeric) sorted order
9+
and applies those "patches".
10+
11+
"patches" could be of two types:
12+
13+
- an executable -- a script to be executed which introduces the changes.
14+
- `.patch` - a regular patch which needs to be applied using `patch -p1`
15+
16+
Typically for the same leading index (e.g. `01`) there would be a script and
17+
then a patch to possibly manually tune up remaining changes.
18+
19+
`apply_all` could also take an index -- then it would stop applying patches
20+
having applied patches up to that index.

tools/bids-2.0/apply_all

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
#!/bin/bash
22

3+
set -eu
4+
5+
# hardcoding for now - relative path from the top
6+
rpath=tools/bids-2.0
7+
38
path="$(dirname "$0")"
9+
cd "$path/../.." # go to the top of bids-specification
10+
11+
apply_until=${1:-}
12+
13+
# harmonize appearance
14+
if [ -n "$apply_until" ] ; then
15+
apply_until=$(printf "%02d" "$apply_until")
16+
fi
417

5-
"$path/rename_participants_to_subjects"
18+
/bin/ls "$rpath"/patches/[0-9]* | sort -n | while read p; do
19+
if [ "${p##*.}" == "patch" ]; then
20+
echo "I: apply $p"
21+
patch -p1 < $p
22+
elif [ -x "$p" ] ; then
23+
echo "I: run $p"
24+
$p
25+
else
26+
echo "E: Do not know how to handle patch $p" >&2
27+
exit 1
28+
fi
29+
done
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
From 087982854fd000f6cb9d321faf25c68e4a2f1b1c Mon Sep 17 00:00:00 2001
2+
From: Yaroslav Halchenko <[email protected]>
3+
Date: Fri, 12 Apr 2024 15:54:31 -0400
4+
Subject: [PATCH] Post fixes to apply_all to fix some indentations due to
5+
participant -> subject
6+
7+
---
8+
src/appendices/coordinate-systems.md | 6 +++---
9+
src/schema/README.md | 4 ++--
10+
2 files changed, 5 insertions(+), 5 deletions(-)
11+
12+
diff --git a/src/appendices/coordinate-systems.md b/src/appendices/coordinate-systems.md
13+
index 9eb57359..9cb031b0 100644
14+
--- a/src/appendices/coordinate-systems.md
15+
+++ b/src/appendices/coordinate-systems.md
16+
@@ -233,10 +233,10 @@ described in [Common file level metadata fields][common file level metadata fiel
17+
18+
In the case of multiple study templates, additional names may need to be defined.
19+
20+
-| **Coordinate System** | **Description** |
21+
-| --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
22+
+| **Coordinate System** | **Description** |
23+
+| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
24+
| 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`. |
25+
-| study | Custom space defined using a group/study-specific template. This coordinate system requires specifying an additional file to be fully defined. |
26+
+| study | Custom space defined using a group/study-specific template. This coordinate system requires specifying an additional file to be fully defined. |
27+
28+
### Non-template coordinate system identifiers
29+
30+
diff --git a/src/schema/README.md b/src/schema/README.md
31+
index 0a6d7a3c..7587f01d 100644
32+
--- a/src/schema/README.md
33+
+++ b/src/schema/README.md
34+
@@ -243,7 +243,7 @@ and provide the *namespace* in which expressions are evaluated.
35+
The following operators should be defined by an interpreter:
36+
37+
| Operator | Definition | Example |
38+
-| ----------- | ------------------------------------------------------------- | --------------------------------------------- |
39+
+| ----------- | ------------------------------------------------------------- |-----------------------------------------------|
40+
| `==` | equality | `suffix == "T1w"` |
41+
| `!=` | inequality | `entities.task != "rest"` |
42+
| `<`/`>` | less-than / greater-than | `sidecar.EchoTime < 0.5` |
43+
@@ -253,7 +253,7 @@ The following operators should be defined by an interpreter:
44+
| `&&` | conjunction, true if both RHS and LHS are true | `"Units" in sidecar && sidecar.Units == "mm"` |
45+
| `\|\|` | disjunction, true if either RHS or LHS is true | `a < mn \|\| a > mx` |
46+
| `.` | object query, returns value of subfield | `sidecar.Units` |
47+
-| `[]` | array/string index, returns value of Nth element (0-indexed) | `columns.subject_label[0]` |
48+
+| `[]` | array/string index, returns value of Nth element (0-indexed) | `columns.subject_label[0]` |
49+
| `+` | numeric addition / string concatenation | `x + 1`, `stem + "suffix"` |
50+
| `-`/`*`/`/` | numeric operators (division coerces to float) | `length(array) - 2`, `x * 2`, `1 / 2 == 0.5` |
51+
52+
--
53+
2.43.0

0 commit comments

Comments
 (0)