diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bf26a564..181bd372 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python-version: ["3.7", "3.11"] + python-version: ["3.8", "3.11"] fail-fast: false runs-on: ${{ matrix.os }} defaults: diff --git a/.gitignore b/.gitignore index aef061f1..8632e2b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -.venv +.venv* /.project /.pydevproject *.pyc diff --git a/example-specs/task/ants_n4_bias_field_correction.yaml b/example-specs/task/ants_n4_bias_field_correction.yaml index dfa4ab6b..8cd7dfc8 100644 --- a/example-specs/task/ants_n4_bias_field_correction.yaml +++ b/example-specs/task/ants_n4_bias_field_correction.yaml @@ -164,6 +164,8 @@ tests: dimension: '3' input_image: bspline_fitting_distance: '300' + save_bias: 'False' + copy_header: 'False' shrink_factor: '3' n_iterations: '[50,50,30,20]' imports: &id001 @@ -186,6 +188,10 @@ tests: # dict[str, str] - values to provide to inputs fields in the task initialisation # (if not specified, will try to choose a sensible value) convergence_threshold: 1e-6 + n_iterations: '[50,50,30,20]' + input_image: + save_bias: 'False' + copy_header: 'False' imports: # list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item # consisting of 'module', 'name', and optionally 'alias' keys @@ -205,6 +211,10 @@ tests: # dict[str, str] - values to provide to inputs fields in the task initialisation # (if not specified, will try to choose a sensible value) bspline_order: '5' + bspline_fitting_distance: 10 + save_bias: 'False' + copy_header: 'False' + input_image: imports: # list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item # consisting of 'module', 'name', and optionally 'alias' keys @@ -225,6 +235,7 @@ tests: # (if not specified, will try to choose a sensible value) input_image: save_bias: 'True' + copy_header: 'False' dimension: '3' imports: # list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item @@ -247,6 +258,8 @@ tests: input_image: dimension: '3' histogram_sharpening: (0.12, 0.02, 200) + save_bias: 'False' + copy_header: 'False' imports: # list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item # consisting of 'module', 'name', and optionally 'alias' keys @@ -274,6 +287,8 @@ doctests: bspline_fitting_distance: '300' shrink_factor: '3' n_iterations: '[50,50,30,20]' + save_bias: 'False' + copy_header: 'False' imports: *id001 # list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item # consisting of 'module', 'name', and optionally 'alias' keys @@ -286,6 +301,9 @@ doctests: # If the field is of file-format type and the value is None, then the # '.mock()' method of the corresponding class is used instead. convergence_threshold: 1e-6 + n_iterations: '[50,50,30,20]' + save_bias: 'False' + copy_header: 'False' imports: # list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item # consisting of 'module', 'name', and optionally 'alias' keys @@ -298,6 +316,8 @@ doctests: # If the field is of file-format type and the value is None, then the # '.mock()' method of the corresponding class is used instead. bspline_order: '5' + save_bias: 'False' + copy_header: 'False' imports: # list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item # consisting of 'module', 'name', and optionally 'alias' keys @@ -311,6 +331,7 @@ doctests: # '.mock()' method of the corresponding class is used instead. input_image: save_bias: 'True' + copy_header: 'False' dimension: '3' imports: # list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item @@ -324,6 +345,8 @@ doctests: # If the field is of file-format type and the value is None, then the # '.mock()' method of the corresponding class is used instead. input_image: + save_bias: 'False' + copy_header: 'False' dimension: '3' histogram_sharpening: (0.12, 0.02, 200) imports: diff --git a/nipype2pydra/utils.py b/nipype2pydra/utils.py index 868c3270..afc46d49 100644 --- a/nipype2pydra/utils.py +++ b/nipype2pydra/utils.py @@ -8,6 +8,11 @@ from pathlib import Path from fileformats.core import FileSet +try: + from typing import GenericAlias +except ImportError: + from typing import _GenericAlias as GenericAlias + from importlib import import_module @@ -70,7 +75,7 @@ def add_to_sys_path(path: Path): def is_fileset(tp: type): return ( inspect.isclass(tp) - and type(tp) is not ty.GenericAlias + and type(tp) is not GenericAlias and issubclass(tp, FileSet) ) diff --git a/pyproject.toml b/pyproject.toml index c030eda3..a6627eb1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,6 +60,7 @@ test = [ "pytest >=6.2.5", "pytest-env>=0.6.2", "pytest-cov>=2.12.1", + "fileformats-medimage-extras", ] docs = [ "packaging", diff --git a/tests/test_task.py b/tests/test_task.py index 6dbc5756..cc18b982 100644 --- a/tests/test_task.py +++ b/tests/test_task.py @@ -2,7 +2,6 @@ import yaml from conftest import show_cli_trace import pytest -import shutil import logging from nipype2pydra.cli import task as task_cli from nipype2pydra.utils import add_to_sys_path @@ -18,7 +17,6 @@ "trait_modified", "environ", "output_type", - "crop_list", ] @@ -48,7 +46,7 @@ def test_task_conversion(task_spec_file, cli_runner, work_dir, gen_test_conftest pydra_module = import_module(output_module_path) pydra_task = getattr(pydra_module, task_spec["task_name"]) nipype_interface = getattr( - import_module(task_spec["nipype_module"]), task_spec["task_name"] + import_module(task_spec["nipype_module"]), task_spec["nipype_name"] ) nipype_trait_names = nipype_interface.input_spec().all_trait_names()