From 7be4c855d25ae95bd1b7880a93cc70c129f9ea00 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Mon, 7 Feb 2022 13:49:41 -0500 Subject: [PATCH 1/8] RF: move .bids into .bids/ subpackage and move tests along This would open for a better structuring of BIDS support code etc. All bids.utils are imported within bids/__init__.py so there should be no effect on imports from heudiconv.bids --- heudiconv/bids/__init__.py | 1 + heudiconv/bids/tests/__init__.py | 0 .../{tests/test_bids.py => bids/tests/test_utils.py} | 4 ++-- heudiconv/{bids.py => bids/utils.py} | 8 ++++---- 4 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 heudiconv/bids/__init__.py create mode 100644 heudiconv/bids/tests/__init__.py rename heudiconv/{tests/test_bids.py => bids/tests/test_utils.py} (99%) rename heudiconv/{bids.py => bids/utils.py} (99%) diff --git a/heudiconv/bids/__init__.py b/heudiconv/bids/__init__.py new file mode 100644 index 00000000..16281fe0 --- /dev/null +++ b/heudiconv/bids/__init__.py @@ -0,0 +1 @@ +from .utils import * diff --git a/heudiconv/bids/tests/__init__.py b/heudiconv/bids/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/heudiconv/tests/test_bids.py b/heudiconv/bids/tests/test_utils.py similarity index 99% rename from heudiconv/tests/test_bids.py rename to heudiconv/bids/tests/test_utils.py index 8716bb59..4e70e7b6 100644 --- a/heudiconv/tests/test_bids.py +++ b/heudiconv/bids/tests/test_utils.py @@ -28,7 +28,7 @@ remove_suffix, ) -from heudiconv.bids import ( +from .. import ( maybe_na, treat_age, find_fmap_groups, @@ -44,7 +44,7 @@ BIDSFile, ) -from .utils import ( +from heudiconv.tests.utils import ( TESTS_DATA_PATH, ) diff --git a/heudiconv/bids.py b/heudiconv/bids/utils.py similarity index 99% rename from heudiconv/bids.py rename to heudiconv/bids/utils.py index 40deb1e5..66a2b2ff 100644 --- a/heudiconv/bids.py +++ b/heudiconv/bids/utils.py @@ -13,10 +13,10 @@ from glob import glob import errno -from .external.pydicom import dcm +from ..external.pydicom import dcm -from .parser import find_files -from .utils import ( +from ..parser import find_files +from ..utils import ( load_json, save_json, create_file_if_missing, @@ -28,7 +28,7 @@ remove_suffix, remove_prefix, ) -from . import __version__ +from .. import __version__ lgr = logging.getLogger(__name__) From 2ff3b98e1be94335ef994033697f73155d1c3e37 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Mon, 7 Feb 2022 13:53:33 -0500 Subject: [PATCH 2/8] Add entities objects+rules from bids v1.7.0 ATM we will need only these two files to establish consistent order of the entities in the filenames. Later we might want to carry a more complete copy of the schema, or may be eventually some proper bidsschema python package would appear to provide desired functionality anyways --- .../bids/data/schema/objects/entities.yaml | 356 ++++++++++++++++++ .../bids/data/schema/rules/entities.yaml | 30 ++ setup.py | 3 + 3 files changed, 389 insertions(+) create mode 100644 heudiconv/bids/data/schema/objects/entities.yaml create mode 100644 heudiconv/bids/data/schema/rules/entities.yaml diff --git a/heudiconv/bids/data/schema/objects/entities.yaml b/heudiconv/bids/data/schema/objects/entities.yaml new file mode 100644 index 00000000..3df87f7e --- /dev/null +++ b/heudiconv/bids/data/schema/objects/entities.yaml @@ -0,0 +1,356 @@ +--- +# This file describes entities present in BIDS filenames. +# WARNING: The entities are presented here in alphabetical order! +# The appropriate order of entities in filenames is defined in `rules/entities.yaml`, +# rather than this file (`objects/entities.yaml`). +acquisition: + name: Acquisition + entity: acq + description: | + The `acq-