diff --git a/.circleci/config.yml b/.circleci/config.yml index 15c86a7..d20947c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -185,7 +185,9 @@ workflows: - DOCKER_HUB requires: - test - + filters: + tags: + only: /.*/ # VS Code Extension Version: 1.5.1 diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 4429ffc..94489af 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -8,52 +8,26 @@ on: tags: - '*' -defaults: - run: - shell: bash - jobs: package: - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - - # Build packages and upload - runs-on: ${{ matrix.os }} - strategy: - matrix: - include: - - os: ubuntu-latest - python-version: '3.11' - + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 with: submodules: recursive fetch-depth: 0 - - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} - + python-version: 3.11 - name: Display Python version run: python -c "import sys; print(sys.version)" - - name: Install build run: python -m pip install build - - name: Build sdist and wheel run: python -m build - - - name: Test PyPI upload - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.TEST_PYPI_API_TOKEN }} - repository_url: https://test.pypi.org/legacy/ - skip_existing: true - - name: Upload to PyPI (on tags) + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ diff --git a/.github/workflows/test_and_coverage.yml b/.github/workflows/test_and_coverage.yml index b804dbb..e433b79 100644 --- a/.github/workflows/test_and_coverage.yml +++ b/.github/workflows/test_and_coverage.yml @@ -19,9 +19,9 @@ jobs: matrix: os: [ubuntu-latest, macOS-latest] # windows-latest: do not work. antspyx is not available for windows python-version: ['3.9', '3.10', '3.11'] - exclude: - - os: macOS-latest # anstpyx install is messed up with macOS and python 3.9 - python-version: '3.9' + # exclude: + # - os: macOS-latest # anstpyx install is messed up with macOS and python 3.9 + # python-version: '3.9' fail-fast: false steps: diff --git a/.sourcery.yaml b/.sourcery.yaml index c24bdd6..d054b22 100644 --- a/.sourcery.yaml +++ b/.sourcery.yaml @@ -21,7 +21,6 @@ ignore: # A list of paths or files which Sourcery will ignore. - .tox - node_modules - vendor -- vendor - bidsmreye/_version.py rule_settings: @@ -32,7 +31,7 @@ rule_settings: - refactoring - suggestion - comment - python_version: '3.8' # A string specifying the lowest Python version your project supports. Sourcery will not suggest refactorings requiring a higher Python version. + python_version: '3.9' # rules: # A list of custom rules Sourcery will include in its analysis. # - id: no-print-statements @@ -52,8 +51,8 @@ rule_settings: # rule_tags: {} # Additional rule tags. -# metrics: -# quality_threshold: 25.0 +metrics: + quality_threshold: 25.0 # github: # labels: [] diff --git a/Makefile b/Makefile index b59cc88..ff6b5b8 100644 --- a/Makefile +++ b/Makefile @@ -48,19 +48,20 @@ clean-test: ## remove test and coverage artifacts rm -fr htmlcov/ rm -fr .pytest_cache + ## INSTALL install_dev: clean ## install the package and development dependencies to the active Python's site-packages pip install -e .[dev] make models -release: dist ## package and upload a release - twine upload dist/* - dist: clean ## builds source and wheel package python -m build ls -l dist +release: dist ## package and upload a release + twine upload dist/* + ## PRE-TRAINED MODELS .PHONY: models @@ -83,6 +84,7 @@ models/dataset4_pursuit.h5: models/dataset5_free_viewing.h5: bidsmreye_model --model 5_free_viewing + ## DOC .PHONY: docs docs/source/FAQ.md @@ -129,7 +131,7 @@ prepare: tests/data/moae_fmriprep ## demo: prepares the data of MOAE dataset prepare \ -vv \ --reset_database \ - --non_linear_coreg + --linear_coreg generalize: ## demo: predicts labels of MOAE dataset bidsmreye $$PWD/tests/data/moae_fmriprep \ diff --git a/bidsmreye/_cli.py b/bidsmreye/_cli.py index fd893e5..8c00d32 100644 --- a/bidsmreye/_cli.py +++ b/bidsmreye/_cli.py @@ -54,7 +54,7 @@ def cli(argv: Any = sys.argv) -> None: model_weights_file=model_weights_file, reset_database=args.reset_database, bids_filter_file=args.bids_filter_file, - non_linear_coreg=bool(getattr(args, "non_linear_coreg", False)), + linear_coreg=bool(getattr(args, "linear_coreg", False)), log_level_name=log_level_name, force=bool(getattr(args, "force", False)), ) diff --git a/bidsmreye/_parsers.py b/bidsmreye/_parsers.py index 69dcbdf..d807161 100644 --- a/bidsmreye/_parsers.py +++ b/bidsmreye/_parsers.py @@ -158,10 +158,13 @@ def common_parser(formatter_class: type[HelpFormatter] = HelpFormatter) -> Argum prepare_parser = _add_common_arguments(prepare_parser) # TODO make it possible to pass path to a model ? prepare_parser.add_argument( - "--non_linear_coreg", + "--linear_coreg", help=""" -Uses a more aggressive (and non-linear) alignment procedure -to the deepmreye template.""", +Uses a less aggressive (and linear) alignment procedure +to the deepmreye template. + +May lead to worse results so check your outputs. +""", action="store_true", ) @@ -190,10 +193,12 @@ def common_parser(formatter_class: type[HelpFormatter] = HelpFormatter) -> Argum all_parser = _add_common_arguments(all_parser) # TODO make it possible to pass path to a model ? all_parser.add_argument( - "--non_linear_coreg", + "--linear_coreg", help=""" -Uses a more aggressive (and non-linear) alignment procedure +Uses a less aggressive (and linear) alignment procedure to the deepmreye template. + +May lead to worse results so check your outputs. """, action="store_true", ) diff --git a/bidsmreye/bidsmreye.py b/bidsmreye/bidsmreye.py index ca85362..e013ccd 100755 --- a/bidsmreye/bidsmreye.py +++ b/bidsmreye/bidsmreye.py @@ -27,7 +27,7 @@ def bidsmreye( model_weights_file: str | None = None, reset_database: bool | None = None, bids_filter_file: str | None = None, - non_linear_coreg: bool = False, + linear_coreg: bool = False, log_level_name: str | None = None, force: bool = False, ) -> None: @@ -50,7 +50,7 @@ def bidsmreye( model_weights_file=model_weights_file, reset_database=reset_database, bids_filter=bids_filter, - non_linear_coreg=non_linear_coreg, + linear_coreg=linear_coreg, force=force, ) # type: ignore diff --git a/bidsmreye/configuration.py b/bidsmreye/configuration.py index 35e4b5e..9dee2a4 100644 --- a/bidsmreye/configuration.py +++ b/bidsmreye/configuration.py @@ -54,7 +54,7 @@ def _check_input_dir(self, attribute: str, value: Path) -> None: debug: str | bool | None = field(kw_only=True, default=None) reset_database: bool = field(kw_only=True, default=False) - non_linear_coreg: bool = field(kw_only=True, default=False) + linear_coreg: bool = field(kw_only=True, default=False) force: bool = field(kw_only=True, default=False) has_GPU: bool = False diff --git a/bidsmreye/prepare_data.py b/bidsmreye/prepare_data.py index e3f4d4c..126cf6d 100644 --- a/bidsmreye/prepare_data.py +++ b/bidsmreye/prepare_data.py @@ -33,7 +33,7 @@ log = bidsmreye_log(name="bidsmreye") -def coregister_and_extract_data(img: str, non_linear_coreg: bool = False) -> None: +def coregister_and_extract_data(img: str, linear_coreg: bool = False) -> None: """Coregister image to eye template and extract data from eye mask for one image. :param img: Image to coregister and extract data from @@ -49,7 +49,7 @@ def coregister_and_extract_data(img: str, non_linear_coreg: bool = False) -> Non z_edges, ) = preprocess.get_masks() - transforms = ["Affine", "Affine", "SyNAggro"] if non_linear_coreg else None + transforms = None if linear_coreg else ["Affine", "Affine", "SyNAggro"] preprocess.run_participant( img, @@ -168,7 +168,7 @@ def prepapre_image( log.info(f"Processing file: {Path(img_path).name}") - coregister_and_extract_data(img_path, non_linear_coreg=cfg.non_linear_coreg) + coregister_and_extract_data(img_path, linear_coreg=cfg.linear_coreg) deepmreye_mask_report = get_deepmreye_filename( layout_in, img=img_path, filetype="report" @@ -205,8 +205,8 @@ def prepare_data(cfg: Config) -> None: subjects = list_subjects(cfg, layout_in) text = "PREPARING DATA" - if cfg.non_linear_coreg: - log.info("Using non-linear coregistration") + if cfg.linear_coreg: + log.info("Using linear coregistration") with progress_bar(text=text) as progress: subject_loop = progress.add_task( diff --git a/boutiques/bidsmreye_0.4.0.json b/boutiques/bidsmreye_0.4.0.json index 7824419..d8da8cd 100644 --- a/boutiques/bidsmreye_0.4.0.json +++ b/boutiques/bidsmreye_0.4.0.json @@ -3,7 +3,7 @@ "description": "bids app using deepMReye to decode eye motion for fMRI time series data", "tool-version": "0.4.0", "schema-version": "0.5", - "command-line": "bidsmreye [VERSION] [BIDS_DIR] [OUTPUT_DIR] [ANALYSIS_LEVEL] [COMMAND] [PARTICIPANT_LABEL] [TASK] [RUN] [SPACE] [LOG_LEVEL] [DEBUG] [RESET_DATABASE] [BIDS_FILTER_FILE] [FORCE] [NON_LINEAR_COREG] [MODEL]", + "command-line": "bidsmreye [VERSION] [BIDS_DIR] [OUTPUT_DIR] [ANALYSIS_LEVEL] [COMMAND] [PARTICIPANT_LABEL] [TASK] [RUN] [SPACE] [LOG_LEVEL] [DEBUG] [RESET_DATABASE] [BIDS_FILTER_FILE] [FORCE] [LINEAR_COREG] [MODEL]", "inputs": [ { "name": "version", @@ -132,13 +132,13 @@ "value-key": "[FORCE]" }, { - "name": "non_linear_coreg", - "id": "non_linear_coreg", - "description": "Uses a more aggressive (and non-linear) alignment procedure to the deepmreye template.", + "name": "linear_coreg", + "id": "linear_coreg", + "description": "Uses a less aggressive (linear) alignment procedure to the deepmreye template.", "type": "Flag", "optional": true, - "command-line-flag": "--non_linear_coreg", - "value-key": "[NON_LINEAR_COREG]" + "command-line-flag": "--linear_coreg", + "value-key": "[LINEAR_COREG]" }, { "name": "model", @@ -187,7 +187,7 @@ "reset_database", "debug", "force", - "non_linear_coreg", + "linear_coreg", "log_level", "run", "space", @@ -199,7 +199,6 @@ "reset_database", "debug", "force", - "non_linear_coreg", "log_level", "model", "run", @@ -212,13 +211,12 @@ "reset_database", "debug", "force", - "non_linear_coreg", + "linear_coreg", "log_level", "model", "run", "space", "bids_filter_file", - "participant_label", "task" ] } diff --git a/boutiques/invocation.json b/boutiques/invocation.json index 45b02e1..9dec5e2 100644 --- a/boutiques/invocation.json +++ b/boutiques/invocation.json @@ -13,6 +13,6 @@ "debug": false, "reset_database": true, "force": false, - "non_linear_coreg": true, + "linear_coreg": true, "model": "1_guided_fixations" } diff --git a/docs/source/CHANGELOG.md b/docs/source/CHANGELOG.md index 6202411..7fa649d 100644 --- a/docs/source/CHANGELOG.md +++ b/docs/source/CHANGELOG.md @@ -23,22 +23,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -* [ENH] Extra metadata have been added to the output of the `generalize` step to better align with BIDS BEP20 @Remi-Gau in https://github.com/cpp-lln-lab/bidsMReye/pull/232 +* [ENH] Extra metadata have been added to the output of the `generalize` step to better align with BIDS BEP20 by @Remi-Gau in https://github.com/cpp-lln-lab/bidsMReye/pull/232 ### Changed -* [ENH] Output filenames of the prepare step has been changed to use the `timeseries` suffix and the output of the `generalize` step now include the name of the Deepmreye model used to compute them @Remi-Gau in https://github.com/cpp-lln-lab/bidsMReye/pull/232 +* [ENH] Output filenames of the prepare step has been changed to use the `timeseries` suffix and the output of the `generalize` step now include the name of the Deepmreye model used to compute them by @Remi-Gau in https://github.com/cpp-lln-lab/bidsMReye/pull/232 -### Deprecated +* [ENH] use non-linear alignment as default by @Remi-Gau in https://github.com/cpp-lln-lab/bidsMReye/pull/234 ### Removed -### Fixed - -* [FIX] do not apply run found for one task to all tasks by @Remi-Gau in https://github.com/cpp-lln-lab/bidsMReye/pull/228 +* [ENH] the `--non_linear_coreg` CLI argument was replaced by the `--linear_coreg` by @Remi-Gau in https://github.com/cpp-lln-lab/bidsMReye/pull/234 -### Security +### Fixed +* [FIX] do not apply `run` found for one task to all tasks by @Remi-Gau in https://github.com/cpp-lln-lab/bidsMReye/pull/228 ## [0.4.0] - 20234-08-05 diff --git a/tests/data/derivatives/bidsmreye/dataset_description.json b/tests/data/derivatives/bidsmreye/dataset_description.json index fc31552..caca3be 100644 --- a/tests/data/derivatives/bidsmreye/dataset_description.json +++ b/tests/data/derivatives/bidsmreye/dataset_description.json @@ -66,7 +66,7 @@ }, "debug": false, "reset_database": false, - "non_linear_coreg": false + "linear_coreg": false } } ], diff --git a/tests/test_configuration.py b/tests/test_configuration.py index eac2598..20e0ca5 100644 --- a/tests/test_configuration.py +++ b/tests/test_configuration.py @@ -17,7 +17,7 @@ def test_Config(data_dir, pybids_test_dataset): data_dir, ) assert not cfg.debug - assert not cfg.non_linear_coreg + assert not cfg.linear_coreg assert cfg.input_dir == pybids_test_dataset assert cfg.output_dir == data_dir / "bidsmreye" assert sorted(cfg.subjects) == ["01", "02", "03", "04", "05"] diff --git a/tests/test_parsers.py b/tests/test_parsers.py index d41260e..6fa1e83 100644 --- a/tests/test_parsers.py +++ b/tests/test_parsers.py @@ -14,12 +14,12 @@ def test_parser() -> None: "--task", "foo", "bar", - "--non_linear_coreg", + "--linear_coreg", ] ) assert args.task == ["foo", "bar"] - assert args.non_linear_coreg + assert args.linear_coreg def test_parser_basic() -> None: @@ -43,7 +43,7 @@ def test_parser_basic() -> None: ) assert args.task == ["foo", "bar"] - assert args.non_linear_coreg is False + assert args.linear_coreg is False def test_download_parser(): diff --git a/tools/create_boutiques_descriptor.py b/tools/create_boutiques_descriptor.py index 1faf21b..4781637 100644 --- a/tools/create_boutiques_descriptor.py +++ b/tools/create_boutiques_descriptor.py @@ -11,7 +11,7 @@ "$PWD/outputs/moae_fmriprep/derivatives " "participant " "all " - "--reset_database --non_linear_coreg --model 1_guided_fixations -vv" + "--reset_database --linear_coreg --model 1_guided_fixations -vv" ) cmd = cmd.split(" ")