From 0f7b5bf5f36532a9193d2a541995c4fca89a0707 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Wed, 15 May 2024 12:11:29 -0400 Subject: [PATCH] Initial stab for migrations code... want to see if there more cases first --- .../schemacode/bidsschematools/migrations.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/schemacode/bidsschematools/migrations.py b/tools/schemacode/bidsschematools/migrations.py index 1cf0441cf1..eae92b1e87 100644 --- a/tools/schemacode/bidsschematools/migrations.py +++ b/tools/schemacode/bidsschematools/migrations.py @@ -58,6 +58,25 @@ def migrate_participants(dataset_path: Path): lgr.info(f" - migrated content in {new_file}") +def migrate_tsv_columns(dataset_path: Path): + """ + Rename some columns in .tsv (and corresponding sidecar .json) + """ + # TODO: ideally here we would not provide file_glob + # but rather take schema and deduce which files could have + # the column... alternatively - consider all .tsv files and + # their .json files (note -- could be above and multiple given + # inheritance principle) + for col_from, col_to, file_glob in ( + # https://github.com/bids-standard/bids-2-devel/issues/78 + ("hplc_recovery_fractions", "hplc_recovery_fraction", "*_blood.*"), + # https://github.com/bids-standard/bids-2-devel/issues/15 + ("units", "unit", "_channels.*"), # dependency on migrate_participants + # ??? Any other columns to rename for some reason? + ): + raise NotImplementedError() + + def migrate_dataset(dataset_path): lgr.info(f"Migrating dataset at {dataset_path}") dataset_path = Path(dataset_path) @@ -74,6 +93,7 @@ def migrate_dataset(dataset_path): for migration in [ migrate_participants, migrate_version, + migrate_tsv_columns, # depends on migrate_participants ]: lgr.info(f" - applying migration {migration.__name__}") migration(dataset_path)