diff --git a/.coveragerc b/.coveragerc index 7b98ae4cf..6532daacf 100644 --- a/.coveragerc +++ b/.coveragerc @@ -2,17 +2,16 @@ branch = True concurrency = multiprocessing data_file = .coverage -source_pkgs = - scilpy - scripts +source = src relative_files = True omit = - scripts/tests/*.py - scilpy/tests/**/*.py - scilpy/**/tests/*.py - scilpy/**/tests/**/*.py - scripts/tests/*.py - scripts/tests/**/*.py + src/scilpy/tests/**/*.py + src/scilpy/**/tests/*.py + src/scilpy/**/tests/**/*.py + src/scilpy/cli/tests/*.py + src/scilpy/cli/tests/**/*.py + src/scilpy/cli/scil_data_download.py + src/scilpy/io/deprecator.py [report] skip_empty = True diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e968a600e..0b66ae6c4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,14 +12,14 @@ on: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true - + env: MPLBACKEND: agg OPENBLAS_NUM_THREADS: 1 jobs: test: - runs-on: scilus-runners + runs-on: scilus-bigmem-runners if: github.repository == 'scilus/scilpy' steps: @@ -30,11 +30,12 @@ jobs: id: python-selector run: echo "python-version=$(head -1 .python-version)" >> $GITHUB_OUTPUT - - name: Set up Python for Scilpy - uses: actions/setup-python@v5.0.0 + - name: Set up Python and uv for Scilpy + uses: astral-sh/setup-uv@v6.4.3 with: python-version: ${{ steps.python-selector.outputs.python-version }} - cache: 'pip' + activate-environment: true + enable-cache: true - name: Install non-python dependencies run: | @@ -46,19 +47,30 @@ jobs: libblas-dev \ liblapack-dev \ libfreetype6-dev \ - libdrm-dev + libdrm-dev \ + libgl1-mesa-dev \ + libosmesa6-dev - - name: Install Scilpy + - name: stdlib checkout + if: ${{ !contains(steps.python-selector.outputs.python-version, '3.12') }} run: | - export SETUPTOOLS_USE_DISTUTILS=stdlib - python -m pip install --upgrade pip wheel - python -m pip install --upgrade "setuptools<71.0.0" - python -m pip install -e . + echo "SETUPTOOLS_USE_DISTUTILS=stdlib" >> "$GITHUB_ENV" + - name: Install Scilpy + run: | + uv pip install --upgrade pip wheel + uv pip install --upgrade "setuptools<71.0.0" + uv pip install -e . + # TODO: to adapt once Scilpy passes to VTK 9.4.0, which selects OSMesa at runtime + # https://discourse.vtk.org/t/status-update-runtime-opengl-render-window-selection-in-vtk/14583 + VTK_VERSION=$(cat pyproject.toml | grep 'vtk==' | sed 's/vtk==//g' | sed 's/\"//g' ) + uv pip install --extra-index-url https://wheels.vtk.org vtk-osmesa==$VTK_VERSION + uv pip install pytest-xdist pytest-cov - name: Run tests run: | export C_INCLUDE_PATH=$pythonLocation/include/python${{ steps.python-selector.outputs.python-version }}:$C_INCLUDE_PATH - pytest --cov-report term-missing:skip-covered + scil_data_download + uv run --active pytest --cov-report term-missing:skip-covered - name: Save test results and coverage uses: actions/upload-artifact@v4 @@ -80,27 +92,16 @@ jobs: - name: Checkout repository at merge uses: actions/checkout@v4 - - name: Set up Python for codecov upload - uses: actions/setup-python@v5.0.0 - with: - python-version: '3.10' - cache: 'pip' - - - name: Install pycoverage - run: pip install coverage - - name: Download test results and coverage uses: actions/download-artifact@v4 with: name: test-coverage-${{ github.run_id }} - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v5.4.3 with: token: ${{ secrets.CODECOV_TOKEN }} flags: unittests name: scilpy-unittests-${{ github.run_id }}-${{ github.run_attempt }} verbose: true fail_ci_if_error: true - plugin: pycoverage - diff --git a/.python-version b/.python-version index 88b4c7996..885016e20 100644 --- a/.python-version +++ b/.python-version @@ -1,2 +1,2 @@ -3.10 ->=3.9,<3.12 +3.12 +>=3.10, < 3.13 diff --git a/MANIFEST.in b/MANIFEST.in index e16edd8b0..81139b11f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,7 +3,7 @@ include LICENSE include requirements.txt include .python-version -recursive-include data/LUT * -recursive-include scilpy *.c -recursive-include scilpy *.cpp -recursive-include scilpy *.pyx +recursive-include src/scilpy/data * +recursive-include src/scilpy *.c +recursive-include src/scilpy *.cpp +recursive-include src/scilpy *.pyx diff --git a/README.md b/README.md index 39057ce9a..ea545a172 100644 --- a/README.md +++ b/README.md @@ -14,22 +14,10 @@ **Scilpy** mainly comprises tools and utilities to quickly work with diffusion MRI. Most of the tools are based on or are wrappers of the [DIPY] library, and most of them will eventually be migrated to [DIPY]. Those tools implement the recommended workflows and parameters used in the lab. -## Install scilpy as a user - -We highly encourage to install scilpy in a virtual environnement. Once done and you're in your virtual environnement you can run this command: - -``` -export SETUPTOOLS_USE_DISTUTILS=stdlib -pip install scilpy -``` - -## Install scilpy as a developer - -The library is now built for Python 3.9/3.10 and 3.11. Please, be sure to create a virtual environnement. -If none of these versions are installed on your computer, we suggest you to install python3.10: +The library is now built for Python 3.12 so be sure to create a virtual environnement for Python 3.12. If this version is not installed on your computer: ``` sudo add-apt-repository ppa:deadsnakes/ppa -sudo apt-get install python3.10 python3.10-dev python3.10-venv python3.10-minimal python3.10-tk +sudo apt-get install python3.12 python3.12-dev python3.12-venv python3.12-tk ``` Make sure your pip is up-to-date before trying to install: @@ -39,19 +27,34 @@ pip install --upgrade pip The library's structure is mostly aligned on that of [DIPY]. -The library and scripts can be installed locally by using: +We highly encourage to install scilpy in a virtual environnement. Once done and you're in your virtual environnement, the library and scripts can be installed locally by running these commands: + +## Install scilpy as a user + ``` +# If you are using Python3.10 or Python3.11, export this variable before installing export SETUPTOOLS_USE_DISTUTILS=stdlib -pip install -e . + +# If you don't want to install legacy scripts +export SCILPY_LEGACY='False' + +pip install scilpy # For the most recent release from PyPi ``` -If you don't want to install legacy scripts: +## Install scilpy as a developer + ``` +# If you are using Python3.10 or Python3.11, export this variable before installing +export SETUPTOOLS_USE_DISTUTILS=stdlib + +# If you don't want to install legacy scripts export SCILPY_LEGACY='False' -pip install -e . +pip install -e . # Install from source code (for development) ``` -(Then, without the legacy scripts, if you want to use pytest, use:) +## EXTRAS + +Then, without the legacy scripts, if you want to use pytest, use: ``` pytest --ignore=scripts/legacy ``` diff --git a/codecov.yml b/codecov.yml index 9f9d97b6f..df8be643f 100644 --- a/codecov.yml +++ b/codecov.yml @@ -24,11 +24,11 @@ component_management: - component_id: scilpy_scripts name: Scripts paths: - - scripts/ + - src/scilpy/cli/ - component_id: scilpy_library name: Library paths: - - scilpy/ + - "^src/scilpy/(?!cli)/.*$" comment: layout: "condensed_header, diff, components" \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 791959734..3d2d174ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,282 @@ -# Minimal build configuration at detailed here: -# https://github.com/pypa/pip/issues/11457 - [build-system] requires = [ "setuptools >= 64", + "setuptools_scm[toml]", "Cython==3.0.*", - "numpy==1.25.*" + "numpy==1.26.*" +] +build-backend = "setuptools.build_meta" + +[project] +name = "scilpy" +version = "2.2.0" +description = "Scilpy: diffusion MRI tools and utilities" +authors = [{ name = "SCIL Team" }] +readme = "README.md" +requires-python = ">=3.10, <3.13" +license-files = ["LICENSE"] +classifiers = [ + "Development Status :: 3 - Alpha", + "Environment :: Console", + "Intended Audience :: Science/Research", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Topic :: Scientific/Engineering" +] +dependencies = [ +"bctpy==0.6.*", +"bids-validator==1.14.*", +"bz2file==0.98", +"coloredlogs==15.0.*", +"cvxpy==1.6.*", +"cycler==0.12.*", +"deepdiff==8.1.*", +"dipy==1.11.*", +"dmri-amico==2.1.*", +"dmri-commit==2.3.*", +"docopt==0.6.*", +"dvc==3.59.*", +"formulaic==0.5.*", +"fury==0.12.*", +"future==1.0.*", +"GitPython==3.1.*", +"h5py==3.12.*", +"joblib==1.4.*", +"kiwisolver==1.4.*", +"matplotlib==3.10.*", +"nibabel==5.3.*", +"nilearn==0.11.*", +"nltk==3.9.*", +"numba==0.61.*", +"numba-kdtree==0.4.*", +"numpy==1.26.*", +"openpyxl==3.1.*", +"packaging==24.*", +"pybids==0.18.*", +"PyMCubes==0.1.*", +"pyparsing==3.2.*", +"PySocks==1.7.*", +"pytest==8.3.*", +"pytest-xdist==3.8.*", +"pytest-console-scripts==1.4.*", +"pytest-cov==6.0.*", +"pytest-html==4.1.*", +"pytest-metadata==3.1.*", +"pytest-mock==3.14.*", +"python-dateutil==2.9.*", +"pytz==2024.2", +"requests==2.32.*", +"scikit-image==0.25.*", +"scikit-learn==1.6.*", +"scipy==1.15.*", +"six==1.17.*", +"statsmodels==0.14.*", +"trimeshpy==0.0.*", +"vtk==9.3.*" ] + +[project.optional-dependencies] +dev = ["pytest", "ipython"] + +[tool.setuptools] +package-dir = { "" = "src" } +include-package-data = true + +[tool.setuptools.package-data] +"scilpy.data" = ["src/scilpy/data"] + +[project.scripts] +scil_aodf_metrics = "scilpy.cli.scil_aodf_metrics:main" +scil_bids_validate = "scilpy.cli.scil_bids_validate:main" +scil_bingham_metrics = "scilpy.cli.scil_bingham_metrics:main" +scil_btensor_metrics = "scilpy.cli.scil_btensor_metrics:main" +scil_bundle_alter_to_target_dice = "scilpy.cli.scil_bundle_alter_to_target_dice:main" +scil_bundle_clean_qbx_clusters = "scilpy.cli.scil_bundle_clean_qbx_clusters:main" +scil_bundle_compute_centroid = "scilpy.cli.scil_bundle_compute_centroid:main" +scil_bundle_compute_endpoints_map = "scilpy.cli.scil_bundle_compute_endpoints_map:main" +scil_bundle_diameter = "scilpy.cli.scil_bundle_diameter:main" +scil_bundle_explore_bundleseg = "scilpy.cli.scil_bundle_explore_bundleseg:main" +scil_bundle_filter_by_occurence = "scilpy.cli.scil_bundle_filter_by_occurence:main" +scil_bundle_fixel_analysis = "scilpy.cli.scil_bundle_fixel_analysis:main" +scil_bundle_generate_priors = "scilpy.cli.scil_bundle_generate_priors:main" +scil_bundle_label_map = "scilpy.cli.scil_bundle_label_map:main" +scil_bundle_mean_fixel_afd_from_hdf5 = "scilpy.cli.scil_bundle_mean_fixel_afd_from_hdf5:main" +scil_bundle_mean_fixel_afd = "scilpy.cli.scil_bundle_mean_fixel_afd:main" +scil_bundle_mean_fixel_bingham_metric = "scilpy.cli.scil_bundle_mean_fixel_bingham_metric:main" +scil_bundle_mean_fixel_mrds_metric = "scilpy.cli.scil_bundle_mean_fixel_mrds_metric:main" +scil_bundle_mean_std = "scilpy.cli.scil_bundle_mean_std:main" +scil_bundle_pairwise_comparison = "scilpy.cli.scil_bundle_pairwise_comparison:main" +scil_bundle_reject_outliers = "scilpy.cli.scil_bundle_reject_outliers:main" +scil_bundle_score_many_bundles_one_tractogram = "scilpy.cli.scil_bundle_score_many_bundles_one_tractogram:main" +scil_bundle_score_same_bundle_many_segmentations = "scilpy.cli.scil_bundle_score_same_bundle_many_segmentations:main" +scil_bundle_shape_measures = "scilpy.cli.scil_bundle_shape_measures:main" +scil_bundle_uniformize_endpoints = "scilpy.cli.scil_bundle_uniformize_endpoints:main" +scil_bundle_volume_per_label = "scilpy.cli.scil_bundle_volume_per_label:main" +scil_connectivity_compare_populations = "scilpy.cli.scil_connectivity_compare_populations:main" +scil_connectivity_compute_matrices = "scilpy.cli.scil_connectivity_compute_matrices:main" +scil_connectivity_compute_pca = "scilpy.cli.scil_connectivity_compute_pca:main" +scil_connectivity_compute_simple_matrix = "scilpy.cli.scil_connectivity_compute_simple_matrix:main" +scil_connectivity_filter = "scilpy.cli.scil_connectivity_filter:main" +scil_connectivity_graph_measures = "scilpy.cli.scil_connectivity_graph_measures:main" +scil_connectivity_hdf5_average_density_map = "scilpy.cli.scil_connectivity_hdf5_average_density_map:main" +scil_connectivity_math = "scilpy.cli.scil_connectivity_math:main" +scil_connectivity_normalize = "scilpy.cli.scil_connectivity_normalize:main" +scil_connectivity_pairwise_agreement = "scilpy.cli.scil_connectivity_pairwise_agreement:main" +scil_connectivity_print_filenames = "scilpy.cli.scil_connectivity_print_filenames:main" +scil_connectivity_reorder_rois = "scilpy.cli.scil_connectivity_reorder_rois:main" +scil_data_download = "scilpy.cli.scil_data_download:main" +scil_denoising_nlmeans = "scilpy.cli.scil_denoising_nlmeans:main" +scil_dki_metrics = "scilpy.cli.scil_dki_metrics:main" +scil_dti_convert_tensors = "scilpy.cli.scil_dti_convert_tensors:main" +scil_dti_metrics = "scilpy.cli.scil_dti_metrics:main" +scil_dwi_apply_bias_field = "scilpy.cli.scil_dwi_apply_bias_field:main" +scil_dwi_compute_snr = "scilpy.cli.scil_dwi_compute_snr:main" +scil_dwi_concatenate = "scilpy.cli.scil_dwi_concatenate:main" +scil_dwi_convert_FDF = "scilpy.cli.scil_dwi_convert_FDF:main" +scil_dwi_detect_volume_outliers = "scilpy.cli.scil_dwi_detect_volume_outliers:main" +scil_dwi_extract_b0 = "scilpy.cli.scil_dwi_extract_b0:main" +scil_dwi_extract_shell = "scilpy.cli.scil_dwi_extract_shell:main" +scil_dwi_powder_average = "scilpy.cli.scil_dwi_powder_average:main" +scil_dwi_prepare_eddy_command = "scilpy.cli.scil_dwi_prepare_eddy_command:main" +scil_dwi_prepare_topup_command = "scilpy.cli.scil_dwi_prepare_topup_command:main" +scil_dwi_reorder_philips = "scilpy.cli.scil_dwi_reorder_philips:main" +scil_dwi_split_by_indices = "scilpy.cli.scil_dwi_split_by_indices:main" +scil_dwi_to_sh = "scilpy.cli.scil_dwi_to_sh:main" +scil_fibertube_compute_density = "scilpy.cli.scil_fibertube_compute_density:main" +scil_fibertube_score_tractogram = "scilpy.cli.scil_fibertube_score_tractogram:main" +scil_fibertube_tracking = "scilpy.cli.scil_fibertube_tracking:main" +scil_fodf_bundleparc = "scilpy.cli.scil_fodf_bundleparc:main" +scil_fodf_max_in_ventricles = "scilpy.cli.scil_fodf_max_in_ventricles:main" +scil_fodf_memsmt = "scilpy.cli.scil_fodf_memsmt:main" +scil_fodf_metrics = "scilpy.cli.scil_fodf_metrics:main" +scil_fodf_msmt = "scilpy.cli.scil_fodf_msmt:main" +scil_fodf_ssst = "scilpy.cli.scil_fodf_ssst:main" +scil_fodf_to_bingham = "scilpy.cli.scil_fodf_to_bingham:main" +scil_freewater_maps = "scilpy.cli.scil_freewater_maps:main" +scil_freewater_priors = "scilpy.cli.scil_freewater_priors:main" +scil_frf_mean = "scilpy.cli.scil_frf_mean:main" +scil_frf_memsmt = "scilpy.cli.scil_frf_memsmt:main" +scil_frf_msmt = "scilpy.cli.scil_frf_msmt:main" +scil_frf_set_diffusivities = "scilpy.cli.scil_frf_set_diffusivities:main" +scil_frf_ssst = "scilpy.cli.scil_frf_ssst:main" +scil_get_version = "scilpy.cli.scil_get_version:main" +scil_gradients_apply_transform = "scilpy.cli.scil_gradients_apply_transform:main" +scil_gradients_convert = "scilpy.cli.scil_gradients_convert:main" +scil_gradients_generate_sampling = "scilpy.cli.scil_gradients_generate_sampling:main" +scil_gradients_modify_axes = "scilpy.cli.scil_gradients_modify_axes:main" +scil_gradients_normalize_bvecs = "scilpy.cli.scil_gradients_normalize_bvecs:main" +scil_gradients_round_bvals = "scilpy.cli.scil_gradients_round_bvals:main" +scil_gradients_validate_correct_eddy = "scilpy.cli.scil_gradients_validate_correct_eddy:main" +scil_gradients_validate_correct = "scilpy.cli.scil_gradients_validate_correct:main" +scil_gradients_validate_sampling = "scilpy.cli.scil_gradients_validate_sampling:main" +scil_header_print_info = "scilpy.cli.scil_header_print_info:main" +scil_header_validate_compatibility = "scilpy.cli.scil_header_validate_compatibility:main" +scil_json_convert_entries_to_xlsx = "scilpy.cli.scil_json_convert_entries_to_xlsx:main" +scil_json_harmonize_entries = "scilpy.cli.scil_json_harmonize_entries:main" +scil_json_merge_entries = "scilpy.cli.scil_json_merge_entries:main" +scil_labels_combine = "scilpy.cli.scil_labels_combine:main" +scil_labels_dilate = "scilpy.cli.scil_labels_dilate:main" +scil_labels_from_mask = "scilpy.cli.scil_labels_from_mask:main" +scil_labels_remove = "scilpy.cli.scil_labels_remove:main" +scil_labels_split_volume_by_ids = "scilpy.cli.scil_labels_split_volume_by_ids:main" +scil_labels_split_volume_from_lut = "scilpy.cli.scil_labels_split_volume_from_lut:main" +scil_lesions_generate_nawm = "scilpy.cli.scil_lesions_generate_nawm:main" +scil_lesions_harmonize_labels = "scilpy.cli.scil_lesions_harmonize_labels:main" +scil_lesions_info = "scilpy.cli.scil_lesions_info:main" +scil_mrds_metrics = "scilpy.cli.scil_mrds_metrics:main" +scil_mrds_select_number_of_tensors = "scilpy.cli.scil_mrds_select_number_of_tensors:main" +scil_mti_adjust_B1_header = "scilpy.cli.scil_mti_adjust_B1_header:main" +scil_mti_maps_ihMT = "scilpy.cli.scil_mti_maps_ihMT:main" +scil_mti_maps_MT = "scilpy.cli.scil_mti_maps_MT:main" +scil_NODDI_maps = "scilpy.cli.scil_NODDI_maps:main" +scil_NODDI_priors = "scilpy.cli.scil_NODDI_priors:main" +scil_plot_stats_per_point = "scilpy.cli.scil_plot_stats_per_point:main" +scil_qball_metrics = "scilpy.cli.scil_qball_metrics:main" +scil_rgb_convert = "scilpy.cli.scil_rgb_convert:main" +scil_search_keywords = "scilpy.cli.scil_search_keywords:main" +scil_sh_convert = "scilpy.cli.scil_sh_convert:main" +scil_sh_fusion = "scilpy.cli.scil_sh_fusion:main" +scil_sh_to_aodf = "scilpy.cli.scil_sh_to_aodf:main" +scil_sh_to_rish = "scilpy.cli.scil_sh_to_rish:main" +scil_sh_to_sf = "scilpy.cli.scil_sh_to_sf:main" +scil_stats_group_comparison = "scilpy.cli.scil_stats_group_comparison:main" +scil_surface_apply_transform = "scilpy.cli.scil_surface_apply_transform:main" +scil_surface_convert = "scilpy.cli.scil_surface_convert:main" +scil_surface_create = "scilpy.cli.scil_surface_create:main" +scil_surface_flip = "scilpy.cli.scil_surface_flip:main" +scil_surface_smooth = "scilpy.cli.scil_surface_smooth:main" +scil_tracking_local_dev = "scilpy.cli.scil_tracking_local_dev:main" +scil_tracking_local = "scilpy.cli.scil_tracking_local:main" +scil_tracking_pft_maps_edit = "scilpy.cli.scil_tracking_pft_maps_edit:main" +scil_tracking_pft_maps = "scilpy.cli.scil_tracking_pft_maps:main" +scil_tracking_pft = "scilpy.cli.scil_tracking_pft:main" +scil_tractogram_apply_transform = "scilpy.cli.scil_tractogram_apply_transform:main" +scil_tractogram_apply_transform_to_hdf5 = "scilpy.cli.scil_tractogram_apply_transform_to_hdf5:main" +scil_tractogram_assign_custom_color = "scilpy.cli.scil_tractogram_assign_custom_color:main" +scil_tractogram_assign_uniform_color = "scilpy.cli.scil_tractogram_assign_uniform_color:main" +scil_tractogram_commit = "scilpy.cli.scil_tractogram_commit:main" +scil_tractogram_compress = "scilpy.cli.scil_tractogram_compress:main" +scil_tractogram_compute_density_map = "scilpy.cli.scil_tractogram_compute_density_map:main" +scil_tractogram_compute_TODI = "scilpy.cli.scil_tractogram_compute_TODI:main" +scil_tractogram_convert_hdf5_to_trk = "scilpy.cli.scil_tractogram_convert_hdf5_to_trk:main" +scil_tractogram_convert = "scilpy.cli.scil_tractogram_convert:main" +scil_tractogram_convert_trk_to_hdf5 = "scilpy.cli.scil_tractogram_convert_trk_to_hdf5:main" +scil_tractogram_count_streamlines = "scilpy.cli.scil_tractogram_count_streamlines:main" +scil_tractogram_cut_streamlines = "scilpy.cli.scil_tractogram_cut_streamlines:main" +scil_tractogram_detect_loops = "scilpy.cli.scil_tractogram_detect_loops:main" +scil_tractogram_dpp_math = "scilpy.cli.scil_tractogram_dpp_math:main" +scil_tractogram_dps_math = "scilpy.cli.scil_tractogram_dps_math:main" +scil_tractogram_extract_ushape = "scilpy.cli.scil_tractogram_extract_ushape:main" +scil_tractogram_filter_by_anatomy = "scilpy.cli.scil_tractogram_filter_by_anatomy:main" +scil_tractogram_filter_by_length = "scilpy.cli.scil_tractogram_filter_by_length:main" +scil_tractogram_filter_by_orientation = "scilpy.cli.scil_tractogram_filter_by_orientation:main" +scil_tractogram_filter_by_roi = "scilpy.cli.scil_tractogram_filter_by_roi:main" +scil_tractogram_filter_collisions = "scilpy.cli.scil_tractogram_filter_collisions:main" +scil_tractogram_flip = "scilpy.cli.scil_tractogram_flip:main" +scil_tractogram_math = "scilpy.cli.scil_tractogram_math:main" +scil_tractogram_pairwise_comparison = "scilpy.cli.scil_tractogram_pairwise_comparison:main" +scil_tractogram_print_info = "scilpy.cli.scil_tractogram_print_info:main" +scil_tractogram_project_map_to_streamlines = "scilpy.cli.scil_tractogram_project_map_to_streamlines:main" +scil_tractogram_project_streamlines_to_map = "scilpy.cli.scil_tractogram_project_streamlines_to_map:main" +scil_tractogram_qbx = "scilpy.cli.scil_tractogram_qbx:main" +scil_tractogram_register = "scilpy.cli.scil_tractogram_register:main" +scil_tractogram_remove_invalid = "scilpy.cli.scil_tractogram_remove_invalid:main" +scil_tractogram_resample_nb_points = "scilpy.cli.scil_tractogram_resample_nb_points:main" +scil_tractogram_resample = "scilpy.cli.scil_tractogram_resample:main" +scil_tractogram_seed_density_map = "scilpy.cli.scil_tractogram_seed_density_map:main" +scil_tractogram_segment_connections_from_labels = "scilpy.cli.scil_tractogram_segment_connections_from_labels:main" +scil_tractogram_segment_with_bundleseg = "scilpy.cli.scil_tractogram_segment_with_bundleseg:main" +scil_tractogram_segment_with_recobundles = "scilpy.cli.scil_tractogram_segment_with_recobundles:main" +scil_tractogram_segment_with_ROI_and_score = "scilpy.cli.scil_tractogram_segment_with_ROI_and_score:main" +scil_tractogram_shuffle = "scilpy.cli.scil_tractogram_shuffle:main" +scil_tractogram_smooth = "scilpy.cli.scil_tractogram_smooth:main" +scil_tractogram_split = "scilpy.cli.scil_tractogram_split:main" +scil_viz_bingham_fit = "scilpy.cli.scil_viz_bingham_fit:main" +scil_viz_bundle = "scilpy.cli.scil_viz_bundle:main" +scil_viz_bundle_screenshot_mni = "scilpy.cli.scil_viz_bundle_screenshot_mni:main" +scil_viz_bundle_screenshot_mosaic = "scilpy.cli.scil_viz_bundle_screenshot_mosaic:main" +scil_viz_connectivity = "scilpy.cli.scil_viz_connectivity:main" +scil_viz_dti_screenshot = "scilpy.cli.scil_viz_dti_screenshot:main" +scil_viz_fodf = "scilpy.cli.scil_viz_fodf:main" +scil_viz_gradients_screenshot = "scilpy.cli.scil_viz_gradients_screenshot:main" +scil_viz_tractogram_collisions = "scilpy.cli.scil_viz_tractogram_collisions:main" +scil_viz_tractogram_seeds_3d = "scilpy.cli.scil_viz_tractogram_seeds_3d:main" +scil_viz_tractogram_seeds = "scilpy.cli.scil_viz_tractogram_seeds:main" +scil_viz_volume_histogram = "scilpy.cli.scil_viz_volume_histogram:main" +scil_viz_volume_scatterplot = "scilpy.cli.scil_viz_volume_scatterplot:main" +scil_viz_volume_screenshot_mosaic = "scilpy.cli.scil_viz_volume_screenshot_mosaic:main" +scil_viz_volume_screenshot = "scilpy.cli.scil_viz_volume_screenshot:main" +scil_volume_apply_transform = "scilpy.cli.scil_volume_apply_transform:main" +scil_volume_b0_synthesis = "scilpy.cli.scil_volume_b0_synthesis:main" +scil_volume_count_non_zero_voxels = "scilpy.cli.scil_volume_count_non_zero_voxels:main" +scil_volume_crop = "scilpy.cli.scil_volume_crop:main" +scil_volume_distance_map = "scilpy.cli.scil_volume_distance_map:main" +scil_volume_flip = "scilpy.cli.scil_volume_flip:main" +scil_volume_math = "scilpy.cli.scil_volume_math:main" +scil_volume_pairwise_comparison = "scilpy.cli.scil_volume_pairwise_comparison:main" +scil_volume_remove_outliers_ransac = "scilpy.cli.scil_volume_remove_outliers_ransac:main" +scil_volume_resample = "scilpy.cli.scil_volume_resample:main" +scil_volume_reshape = "scilpy.cli.scil_volume_reshape:main" +scil_volume_reslice_to_reference = "scilpy.cli.scil_volume_reslice_to_reference:main" +scil_volume_stats_in_labels = "scilpy.cli.scil_volume_stats_in_labels:main" +scil_volume_stats_in_ROI = "scilpy.cli.scil_volume_stats_in_ROI:main" diff --git a/pytest.ini b/pytest.ini index a9acefdde..26aeee91d 100644 --- a/pytest.ini +++ b/pytest.ini @@ -36,4 +36,10 @@ addopts = --junit-xml=.test_reports/junit.xml --cov --cov-report html - --cov-report xml \ No newline at end of file + --cov-report xml + -n auto + --dist worksteal + --cov-append + +markers = + ml: For tests related to machine learning (NLTK, Pytorch, etc.) diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index c99117ce9..000000000 --- a/requirements.txt +++ /dev/null @@ -1,52 +0,0 @@ -bids-validator==1.11.* -bctpy==0.5.* -bz2file==0.98.* -coloredlogs==15.0.* -cvxpy==1.4.* -cycler==0.11.* -#Cython==0.29.*, !=0.29.29 -Cython==3.0.* -dipy==1.10.* -deepdiff==6.3.0 -dmri-amico==2.1.* -dmri-commit==2.3.* -docopt==0.6.* -dvc==3.48.* -dvc-http==2.32.* -formulaic==0.3.* -fury==0.11.* -future==0.18.* -GitPython==3.1.* -h5py==3.10.* -joblib==1.2.* -kiwisolver==1.4.* -matplotlib==3.6.* -PyMCubes==0.1.* -nibabel==5.2.* -nilearn==0.9.* -numba==0.59.1 -numba-kdtree==0.4.0 -nltk==3.8.* -numpy==1.25.* -openpyxl==3.0.* -packaging == 23.2.* -Pillow==10.2.* -pybids==0.16.* -pyparsing==3.0.* -PySocks==1.7.* -pytest==7.2.* -pytest-console-scripts==1.3.* -pytest-cov==4.1.0 -pytest-html==4.1.1 -pytest-mock==3.10.* -python-dateutil==2.8.* -pytz==2022.6.* -requests==2.28.* -scikit-learn==1.2.* -scikit-image==0.22.* -scipy==1.11.* -six==1.16.* -spams==2.6.* -statsmodels==0.13.* -trimeshpy==0.0.4 -vtk==9.2.* diff --git a/scilpy/connectivity/tests/test_connectivity_tools.py b/scilpy/connectivity/tests/test_connectivity_tools.py deleted file mode 100644 index d89ad462e..000000000 --- a/scilpy/connectivity/tests/test_connectivity_tools.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- - - -def test_compute_olo(): - pass - - -def test_apply_olo(): - pass - - -def test_parse_ordering(): - pass - - -def test_apply_reordering(): - pass - - -def test_evaluate_graph_measures(): - pass - - -def test_normalize_matrix_from_values(): - pass - - -def test_normalize_matrix_from_parcel(): - pass diff --git a/scilpy/segment/models.py b/scilpy/segment/models.py deleted file mode 100644 index bea8c9ef8..000000000 --- a/scilpy/segment/models.py +++ /dev/null @@ -1,53 +0,0 @@ -# encoding: utf-8 - -from dipy.align.bundlemin import distance_matrix_mdf -from dipy.tracking.streamline import set_number_of_points -import numpy as np - - -def remove_similar_streamlines(streamlines, threshold=5): - """ Remove similar streamlines, shuffling streamlines will impact the - results. - Only provide a small set of streamlines (below 2000 if possible). - - Parameters - ---------- - streamlines : list of numpy.ndarray - Input streamlines to remove duplicates from. - threshold : float - Distance threshold to consider two streamlines similar, in mm. - - Returns - ------- - streamlines : list of numpy.ndarray - """ - if len(streamlines) == 1: - return streamlines - - sample_20_streamlines = set_number_of_points(streamlines, 20) - distance_matrix = distance_matrix_mdf(sample_20_streamlines, - sample_20_streamlines) - - current_indice = 0 - while True: - sim_indices = np.where(distance_matrix[current_indice] < threshold)[0] - - pop_count = 0 - # Every streamlines similar to yourself (excluding yourself) - # should be deleted from the set of desired streamlines - for ind in sim_indices: - if not current_indice == ind: - streamlines.pop(ind-pop_count) - - distance_matrix = np.delete(distance_matrix, ind-pop_count, - axis=0) - distance_matrix = np.delete(distance_matrix, ind-pop_count, - axis=1) - pop_count += 1 - - current_indice += 1 - # Once you reach the end of the remaining streamlines - if current_indice >= len(distance_matrix): - break - - return streamlines diff --git a/scripts/legacy/scil_add_tracking_mask_to_pft_maps.py b/scripts/legacy/scil_add_tracking_mask_to_pft_maps.py deleted file mode 100755 index 908eed73a..000000000 --- a/scripts/legacy/scil_add_tracking_mask_to_pft_maps.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tracking_pft_maps_edit import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tracking_pft_maps_edit.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_add_tracking_mask_to_pft_maps.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_analyse_lesions_load.py b/scripts/legacy/scil_analyse_lesions_load.py deleted file mode 100755 index 6352dd877..000000000 --- a/scripts/legacy/scil_analyse_lesions_load.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_lesions_info import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_lesions_info.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_analyse_lesions_load.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_apply_bias_field_on_dwi.py b/scripts/legacy/scil_apply_bias_field_on_dwi.py deleted file mode 100755 index 7b058d497..000000000 --- a/scripts/legacy/scil_apply_bias_field_on_dwi.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_dwi_apply_bias_field import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_dwi_apply_bias_field.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_apply_bias_field_on_dwi.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_apply_transform_to_bvecs.py b/scripts/legacy/scil_apply_transform_to_bvecs.py deleted file mode 100755 index fbd5fd326..000000000 --- a/scripts/legacy/scil_apply_transform_to_bvecs.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_gradients_apply_transform import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_gradients_apply_transform.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_apply_transform_to_bvecs.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_apply_transform_to_hdf5.py b/scripts/legacy/scil_apply_transform_to_hdf5.py deleted file mode 100755 index 00fe42d01..000000000 --- a/scripts/legacy/scil_apply_transform_to_hdf5.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_apply_transform_to_hdf5 import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_apply_transform_to_hdf5. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_apply_transform_to_hdf5.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_apply_transform_to_image.py b/scripts/legacy/scil_apply_transform_to_image.py deleted file mode 100755 index a04cfffed..000000000 --- a/scripts/legacy/scil_apply_transform_to_image.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_volume_apply_transform import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_volume_apply_transform.py. Please change -your existing pipelines accordingly. - -""" - - -@deprecate_script("scil_apply_transform_to_image.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_apply_transform_to_surface.py b/scripts/legacy/scil_apply_transform_to_surface.py deleted file mode 100755 index 99babdb4b..000000000 --- a/scripts/legacy/scil_apply_transform_to_surface.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_surface_apply_transform import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_surface_apply_transform.py. Please change -your existing pipelines accordingly. - -""" - - -@deprecate_script("scil_apply_transform_to_surface.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_apply_transform_to_tractogram.py b/scripts/legacy/scil_apply_transform_to_tractogram.py deleted file mode 100755 index ab71cdb08..000000000 --- a/scripts/legacy/scil_apply_transform_to_tractogram.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_apply_transform import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_apply_transform.py. Please change -your existing pipelines accordingly. - -""" - - -@deprecate_script("scil_apply_transform_to_tractogram.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_assign_custom_color_to_tractogram.py b/scripts/legacy/scil_assign_custom_color_to_tractogram.py deleted file mode 100755 index 6a53ee955..000000000 --- a/scripts/legacy/scil_assign_custom_color_to_tractogram.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_assign_custom_color import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_assign_custom_color.py. -Please change your existing pipelines accordingly. - -""" - - -@deprecate_script("scil_assign_custom_color_to_tractogram.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_assign_uniform_color_to_tractograms.py b/scripts/legacy/scil_assign_uniform_color_to_tractograms.py deleted file mode 100755 index f6f83de51..000000000 --- a/scripts/legacy/scil_assign_uniform_color_to_tractograms.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_assign_uniform_color import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_assign_uniform_color.py. -Please change your existing pipelines accordingly. - -""" - - -@deprecate_script("scil_assign_uniform_color_to_tractogram.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_clean_qbx_clusters.py b/scripts/legacy/scil_clean_qbx_clusters.py deleted file mode 100755 index 0d32d87ec..000000000 --- a/scripts/legacy/scil_clean_qbx_clusters.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_bundle_clean_qbx_clusters import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_bundle_clean_qbx_clusters.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_clean_qbx_clusters.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_combine_labels.py b/scripts/legacy/scil_combine_labels.py deleted file mode 100755 index 16a638e64..000000000 --- a/scripts/legacy/scil_combine_labels.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_labels_combine import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_labels_combine.py. -Now, all our scripts using labels start with scil_labels_...! - -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_combine_labels.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compare_connectivity.py b/scripts/legacy/scil_compare_connectivity.py deleted file mode 100755 index e431a600d..000000000 --- a/scripts/legacy/scil_compare_connectivity.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_connectivity_compare_populations import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_connectivity_compare_populations.py. -All our scripts regarding connectivity now start with scil_connectivity_...! - -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compare_connectivity.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compress_streamlines.py b/scripts/legacy/scil_compress_streamlines.py deleted file mode 100755 index 9088f8586..000000000 --- a/scripts/legacy/scil_compress_streamlines.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_compress import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_compress.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compress_streamlines.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_MT_maps.py b/scripts/legacy/scil_compute_MT_maps.py deleted file mode 100755 index 40d5a941d..000000000 --- a/scripts/legacy/scil_compute_MT_maps.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_mti_maps_MT import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_mti_maps_MT.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_MT_maps.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_NODDI.py b/scripts/legacy/scil_compute_NODDI.py deleted file mode 100755 index 2cbcdd060..000000000 --- a/scripts/legacy/scil_compute_NODDI.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_NODDI_maps import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_NODDI_maps.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_NODDI.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_NODDI_priors.py b/scripts/legacy/scil_compute_NODDI_priors.py deleted file mode 100755 index 998609e7d..000000000 --- a/scripts/legacy/scil_compute_NODDI_priors.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_NODDI_priors import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_NODDI_priors.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_NODDI_priors.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_asym_odf_metrics.py b/scripts/legacy/scil_compute_asym_odf_metrics.py deleted file mode 100755 index df570652c..000000000 --- a/scripts/legacy/scil_compute_asym_odf_metrics.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_aodf_metrics import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_aodf_metrics.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_asym_odf_metrics.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_bundle_mean_std.py b/scripts/legacy/scil_compute_bundle_mean_std.py deleted file mode 100755 index 59dd5a690..000000000 --- a/scripts/legacy/scil_compute_bundle_mean_std.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_bundle_mean_std import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_bundle_mean_std.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_bundle_mean_std.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_bundle_mean_std_per_point.py b/scripts/legacy/scil_compute_bundle_mean_std_per_point.py deleted file mode 100755 index 745659ed4..000000000 --- a/scripts/legacy/scil_compute_bundle_mean_std_per_point.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_bundle_mean_std import main as new_main - - -DEPRECATION_MSG = """ -This script has been merged with new script scil_bundle_mean_std.py. It is -now available through option '--per_point'. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_bundle_mean_std_per_point.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_bundle_volume.py b/scripts/legacy/scil_compute_bundle_volume.py deleted file mode 100755 index b51a27710..000000000 --- a/scripts/legacy/scil_compute_bundle_volume.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_bundle_shape_measures import main as new_main - - -DEPRECATION_MSG = """ -This script has been removed. You can now obtain this information using -scil_bundle_shape_measures.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_bundle_volume.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_bundle_volume_per_label.py b/scripts/legacy/scil_compute_bundle_volume_per_label.py deleted file mode 100755 index 2e4cbfd9c..000000000 --- a/scripts/legacy/scil_compute_bundle_volume_per_label.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_bundle_volume_per_label import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_bundle_volume_per_label.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_bundle_volume_per_label.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_bundle_voxel_label_map.py b/scripts/legacy/scil_compute_bundle_voxel_label_map.py deleted file mode 100755 index d573962f8..000000000 --- a/scripts/legacy/scil_compute_bundle_voxel_label_map.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_bundle_label_map import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_bundle_label_map.py. Please change -your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_bundle_voxel_label_map.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_centroid.py b/scripts/legacy/scil_compute_centroid.py deleted file mode 100755 index 12d6616e5..000000000 --- a/scripts/legacy/scil_compute_centroid.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_bundle_compute_centroid import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_bundle_compute_centroid.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_centroid.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_connectivity.py b/scripts/legacy/scil_compute_connectivity.py deleted file mode 100755 index be5f8adec..000000000 --- a/scripts/legacy/scil_compute_connectivity.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_connectivity_compute_matrices import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_connectivity_compute_matrices.py. -All our scripts regarding connectivity now start with scil_connectivity_...! - -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_connectivity.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_divide.py b/scripts/legacy/scil_compute_divide.py deleted file mode 100755 index e2acee782..000000000 --- a/scripts/legacy/scil_compute_divide.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_btensor_metrics import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_btensor_metrics.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_divide.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_dti_metrics.py b/scripts/legacy/scil_compute_dti_metrics.py deleted file mode 100755 index 04aaa6ebd..000000000 --- a/scripts/legacy/scil_compute_dti_metrics.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_dti_metrics import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_dti_metrics.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_dti_metrics.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_endpoints_map.py b/scripts/legacy/scil_compute_endpoints_map.py deleted file mode 100755 index 1f1a1d22f..000000000 --- a/scripts/legacy/scil_compute_endpoints_map.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_bundle_compute_endpoints_map import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_bundle_compute_endpoints_map.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_endpoints_map.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_fodf_max_in_ventricles.py b/scripts/legacy/scil_compute_fodf_max_in_ventricles.py deleted file mode 100755 index 2e3273da6..000000000 --- a/scripts/legacy/scil_compute_fodf_max_in_ventricles.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_fodf_max_in_ventricles import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_fodf_max_in_ventricles.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_fodf_max_in_ventricles.py", DEPRECATION_MSG, - '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_fodf_metrics.py b/scripts/legacy/scil_compute_fodf_metrics.py deleted file mode 100755 index 1117e78cd..000000000 --- a/scripts/legacy/scil_compute_fodf_metrics.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_fodf_metrics import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_fodf_metrics.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_fodf_metrics.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_freewater.py b/scripts/legacy/scil_compute_freewater.py deleted file mode 100755 index 630987674..000000000 --- a/scripts/legacy/scil_compute_freewater.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_freewater_maps import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_freewater_maps.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_freewater.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_hdf5_average_density_map.py b/scripts/legacy/scil_compute_hdf5_average_density_map.py deleted file mode 100755 index a11326a7a..000000000 --- a/scripts/legacy/scil_compute_hdf5_average_density_map.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_connectivity_hdf5_average_density_map import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_connectivity_hdf5_average_density_map.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_hdf5_average_density_map.py", DEPRECATION_MSG, - '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_ihMT_maps.py b/scripts/legacy/scil_compute_ihMT_maps.py deleted file mode 100755 index fe5f0d22f..000000000 --- a/scripts/legacy/scil_compute_ihMT_maps.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_mti_maps_ihMT import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_mti_maps_ihMT.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_ihMT_maps.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_kurtosis_metrics.py b/scripts/legacy/scil_compute_kurtosis_metrics.py deleted file mode 100755 index 1c985be40..000000000 --- a/scripts/legacy/scil_compute_kurtosis_metrics.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_dki_metrics import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_dki_metrics.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_kurtosis_metrics.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_lobe_specific_fodf_metrics.py b/scripts/legacy/scil_compute_lobe_specific_fodf_metrics.py deleted file mode 100755 index 207f3d734..000000000 --- a/scripts/legacy/scil_compute_lobe_specific_fodf_metrics.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_bingham_metrics import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_bingham_metrics.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_lobe_specific_fodf_metrics.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_local_tracking.py b/scripts/legacy/scil_compute_local_tracking.py deleted file mode 100755 index 47fd060e0..000000000 --- a/scripts/legacy/scil_compute_local_tracking.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tracking_local import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tracking_local.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_local_tracking.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_local_tracking_dev.py b/scripts/legacy/scil_compute_local_tracking_dev.py deleted file mode 100755 index e6bee6304..000000000 --- a/scripts/legacy/scil_compute_local_tracking_dev.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tracking_local_dev import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tracking_local_dev.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_local_tracking_dev.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_maps_for_particle_filter_tracking.py b/scripts/legacy/scil_compute_maps_for_particle_filter_tracking.py deleted file mode 100755 index d01f1700d..000000000 --- a/scripts/legacy/scil_compute_maps_for_particle_filter_tracking.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tracking_pft_maps import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tracking_pft_maps.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_maps_for_particle_filter_tracking.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_mean_fixel_afd_from_bundles.py b/scripts/legacy/scil_compute_mean_fixel_afd_from_bundles.py deleted file mode 100755 index adc416206..000000000 --- a/scripts/legacy/scil_compute_mean_fixel_afd_from_bundles.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_bundle_mean_fixel_afd import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_bundle_mean_fixel_afd.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_fixel_afd_from_bundles.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_mean_fixel_afd_from_hdf5.py b/scripts/legacy/scil_compute_mean_fixel_afd_from_hdf5.py deleted file mode 100755 index d7d29d51b..000000000 --- a/scripts/legacy/scil_compute_mean_fixel_afd_from_hdf5.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_bundle_mean_fixel_afd_from_hdf5 import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_bundle_mean_fixel_afd.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_fixel_afd_from_hdf5.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_mean_fixel_lobe_metric_from_bundles.py b/scripts/legacy/scil_compute_mean_fixel_lobe_metric_from_bundles.py deleted file mode 100755 index fb7cc7d8c..000000000 --- a/scripts/legacy/scil_compute_mean_fixel_lobe_metric_from_bundles.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_bundle_mean_fixel_bingham_metric import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_bundle_mean_fixel_bingham_metric.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_mean_fixel_lobe_metric_from_bundles.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_mean_frf.py b/scripts/legacy/scil_compute_mean_frf.py deleted file mode 100755 index d55da50a5..000000000 --- a/scripts/legacy/scil_compute_mean_frf.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_frf_mean import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_frf_mean.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_mean_frf.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_memsmt_fodf.py b/scripts/legacy/scil_compute_memsmt_fodf.py deleted file mode 100755 index 8b6439441..000000000 --- a/scripts/legacy/scil_compute_memsmt_fodf.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_fodf_memsmt import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_fodf_memsmt.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_memsmt_fodf.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_memsmt_frf.py b/scripts/legacy/scil_compute_memsmt_frf.py deleted file mode 100755 index 45d608c98..000000000 --- a/scripts/legacy/scil_compute_memsmt_frf.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_frf_memsmt import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_frf_memsmt.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_memsmt_frf.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_metrics_stats_in_ROI.py b/scripts/legacy/scil_compute_metrics_stats_in_ROI.py deleted file mode 100755 index 26174f809..000000000 --- a/scripts/legacy/scil_compute_metrics_stats_in_ROI.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_volume_stats_in_ROI import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_volume_stats_in_ROI.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_metrics_stats_in_ROI.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_msmt_fodf.py b/scripts/legacy/scil_compute_msmt_fodf.py deleted file mode 100755 index 5fbf6c2f8..000000000 --- a/scripts/legacy/scil_compute_msmt_fodf.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_fodf_msmt import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_fodf_msmt.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_msmt_fodf.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_msmt_frf.py b/scripts/legacy/scil_compute_msmt_frf.py deleted file mode 100755 index 37bfdf39b..000000000 --- a/scripts/legacy/scil_compute_msmt_frf.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_frf_msmt import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_frf_msmt.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_msmt_frf.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_pca.py b/scripts/legacy/scil_compute_pca.py deleted file mode 100755 index daa10731c..000000000 --- a/scripts/legacy/scil_compute_pca.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_connectivity_compute_pca import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_connectivity_compute_pca.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_pca.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_pft.py b/scripts/legacy/scil_compute_pft.py deleted file mode 100755 index b09cd9582..000000000 --- a/scripts/legacy/scil_compute_pft.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tracking_pft import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tracking_pft.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_pft.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_powder_average.py b/scripts/legacy/scil_compute_powder_average.py deleted file mode 100755 index d9fc0c2e8..000000000 --- a/scripts/legacy/scil_compute_powder_average.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_dwi_powder_average import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_dwi_powder_average.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_powder_average.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_qball_metrics.py b/scripts/legacy/scil_compute_qball_metrics.py deleted file mode 100755 index 6e917bcea..000000000 --- a/scripts/legacy/scil_compute_qball_metrics.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_qball_metrics import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_qball_metrics.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_qball_metrics.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_qbx.py b/scripts/legacy/scil_compute_qbx.py deleted file mode 100755 index 091486c6b..000000000 --- a/scripts/legacy/scil_compute_qbx.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_qbx import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_qbx.py. Please change -your existing pipelines accordingly. - -""" - - -@deprecate_script("scil_compute_qbx.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_rish_from_sh.py b/scripts/legacy/scil_compute_rish_from_sh.py deleted file mode 100755 index 1a29cf872..000000000 --- a/scripts/legacy/scil_compute_rish_from_sh.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_sh_to_rish import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_sh_to_rish.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_rish_from_sh.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_seed_by_labels.py b/scripts/legacy/scil_compute_seed_by_labels.py deleted file mode 100755 index 58cb1d663..000000000 --- a/scripts/legacy/scil_compute_seed_by_labels.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_volume_stats_in_labels import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_volume_stats_in_labels.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_seed_by_label.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_seed_density_map.py b/scripts/legacy/scil_compute_seed_density_map.py deleted file mode 100755 index 280a755c0..000000000 --- a/scripts/legacy/scil_compute_seed_density_map.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_seed_density_map import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_seed_density_map.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_seed_density_map.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_sf_from_sh.py b/scripts/legacy/scil_compute_sf_from_sh.py deleted file mode 100755 index 4fd792192..000000000 --- a/scripts/legacy/scil_compute_sf_from_sh.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_sh_to_sf import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_sh_to_sf.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_sf_from_sh.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_sh_from_signal.py b/scripts/legacy/scil_compute_sh_from_signal.py deleted file mode 100755 index 0d93ffeca..000000000 --- a/scripts/legacy/scil_compute_sh_from_signal.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_dwi_to_sh import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_dwi_to_sh.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_sh_from_signal.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_ssst_fodf.py b/scripts/legacy/scil_compute_ssst_fodf.py deleted file mode 100755 index 01f86b3ec..000000000 --- a/scripts/legacy/scil_compute_ssst_fodf.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_fodf_ssst import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_fodf_ssst.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_ssst_fodf.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_ssst_frf.py b/scripts/legacy/scil_compute_ssst_frf.py deleted file mode 100755 index a66032e80..000000000 --- a/scripts/legacy/scil_compute_ssst_frf.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_frf_ssst import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_frf_ssst.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_ssst_frf.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_streamlines_density_map.py b/scripts/legacy/scil_compute_streamlines_density_map.py deleted file mode 100755 index 683a711da..000000000 --- a/scripts/legacy/scil_compute_streamlines_density_map.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_compute_density_map import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_compute_density_map.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_streamlines_density_map.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_streamlines_length_stats.py b/scripts/legacy/scil_compute_streamlines_length_stats.py deleted file mode 100755 index a6182fa2c..000000000 --- a/scripts/legacy/scil_compute_streamlines_length_stats.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_print_info import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_print_info.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_compute_streamlines_length_stats.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_compute_todi.py b/scripts/legacy/scil_compute_todi.py deleted file mode 100755 index 395bd27d2..000000000 --- a/scripts/legacy/scil_compute_todi.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_compute_TODI import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_compute_TODI.py. Please change -your existing pipelines accordingly. - -""" - - -@deprecate_script("scil_compute_todi", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_concatenate_dwi.py b/scripts/legacy/scil_concatenate_dwi.py deleted file mode 100755 index 11934999e..000000000 --- a/scripts/legacy/scil_concatenate_dwi.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_dwi_concatenate import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_dwi_concatenate.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_concatenate_dwi.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_convert_fdf.py b/scripts/legacy/scil_convert_fdf.py deleted file mode 100755 index ac094fd6a..000000000 --- a/scripts/legacy/scil_convert_fdf.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_dwi_convert_FDF import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_dwi_convert_FDF.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_convert_fdf.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_convert_gradients_fsl_to_mrtrix.py b/scripts/legacy/scil_convert_gradients_fsl_to_mrtrix.py deleted file mode 100755 index d7815887d..000000000 --- a/scripts/legacy/scil_convert_gradients_fsl_to_mrtrix.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_gradients_convert import main as new_main - - -DEPRECATION_MSG = """ -This script has been merged with scil_gradients_convert_mrtrix_to_fsl.py -and renamed scil_gradients_convert.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_convert_gradients_fsl_to_mrtrix.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_convert_gradients_mrtrix_to_fsl.py b/scripts/legacy/scil_convert_gradients_mrtrix_to_fsl.py deleted file mode 100755 index be7b158e2..000000000 --- a/scripts/legacy/scil_convert_gradients_mrtrix_to_fsl.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_gradients_convert import main as new_main - - -DEPRECATION_MSG = """ -This script has been merged with scil_gradients_convert_fsl_to_mrtrix.py -and renamed scil_gradients_convert.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_convert_gradients_mrtrix_to_fsl.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_convert_json_to_xlsx.py b/scripts/legacy/scil_convert_json_to_xlsx.py deleted file mode 100755 index 790b17102..000000000 --- a/scripts/legacy/scil_convert_json_to_xlsx.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_json_convert_entries_to_xlsx import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_json_convert_entries_to_xlsx.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_convert_json_to_xlsx.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_convert_rgb.py b/scripts/legacy/scil_convert_rgb.py deleted file mode 100755 index 31730bf4c..000000000 --- a/scripts/legacy/scil_convert_rgb.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_rgb_convert import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_rgb_convert.py. -Now, all our scripts using metrics or reconstructions start -with scil_reconst_...! - -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_convert_rgb.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_convert_sh_basis.py b/scripts/legacy/scil_convert_sh_basis.py deleted file mode 100755 index 1a808fafe..000000000 --- a/scripts/legacy/scil_convert_sh_basis.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_sh_convert import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_sh_convert.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_convert_sh_basis.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_convert_surface.py b/scripts/legacy/scil_convert_surface.py deleted file mode 100755 index ceb27e057..000000000 --- a/scripts/legacy/scil_convert_surface.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_surface_convert import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_surface_convert.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_convert_surface.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_convert_tensors.py b/scripts/legacy/scil_convert_tensors.py deleted file mode 100755 index 7de4cbaea..000000000 --- a/scripts/legacy/scil_convert_tensors.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_dti_convert_tensors import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_dti_convert_tensors.py. Please change -your existing pipelines accordingly. -""" - - -@deprecate_script("scil_convert_tensors.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_convert_tractogram.py b/scripts/legacy/scil_convert_tractogram.py deleted file mode 100755 index d0a054a80..000000000 --- a/scripts/legacy/scil_convert_tractogram.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_convert import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_convert.py. -Now, all our scripts using tractogram start with scil_tractogram_...! - -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_convert_tractogram.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_count_non_zero_voxels.py b/scripts/legacy/scil_count_non_zero_voxels.py deleted file mode 100755 index 2c3c358b8..000000000 --- a/scripts/legacy/scil_count_non_zero_voxels.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_volume_count_non_zero_voxels import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_volume_count_non_zero_voxels.py. -Please change your existing pipelines accordingly. - -""" - - -@deprecate_script("scil_count_non_zero_voxels.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_count_streamlines.py b/scripts/legacy/scil_count_streamlines.py deleted file mode 100755 index 55a11e927..000000000 --- a/scripts/legacy/scil_count_streamlines.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_count_streamlines import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_count_streamlines.py. Please change -your existing pipelines accordingly. -""" - - -@deprecate_script("scil_count_streamlines.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_crop_volume.py b/scripts/legacy/scil_crop_volume.py deleted file mode 100755 index df95f4cae..000000000 --- a/scripts/legacy/scil_crop_volume.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_volume_crop import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_volume_crop.py. Please change -your existing pipelines accordingly. - -""" - - -@deprecate_script("scil_crop_volume.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_cut_streamlines.py b/scripts/legacy/scil_cut_streamlines.py deleted file mode 100755 index a76a7a562..000000000 --- a/scripts/legacy/scil_cut_streamlines.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_cut_streamlines import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_cut_streamlines.py. Please change -your existing pipelines accordingly. -""" - - -@deprecate_script("scil_cut_streamlines.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_decompose_connectivity.py b/scripts/legacy/scil_decompose_connectivity.py deleted file mode 100755 index f6b6bdc92..000000000 --- a/scripts/legacy/scil_decompose_connectivity.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_segment_connections_from_labels import main as m - - -DEPRECATION_MSG = """ -This script has been renamed -scil_tractogram_segment_connections_from_labels.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_decompose_connectivity.py", DEPRECATION_MSG, '2.0.0') -def main(): - m() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_detect_dwi_volume_outliers.py b/scripts/legacy/scil_detect_dwi_volume_outliers.py deleted file mode 100755 index a5b1cff26..000000000 --- a/scripts/legacy/scil_detect_dwi_volume_outliers.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_dwi_detect_volume_outliers import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_dwi_detect_volume_outliers.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_detect_dwi_volume_outliers.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_detect_streamlines_loops.py b/scripts/legacy/scil_detect_streamlines_loops.py deleted file mode 100755 index 973ec3ab9..000000000 --- a/scripts/legacy/scil_detect_streamlines_loops.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_detect_loops import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_detect_loops.py. Please change -your existing pipelines accordingly. - -""" - - -@deprecate_script("scil_detect_streamlines_loops.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_dilate_labels.py b/scripts/legacy/scil_dilate_labels.py deleted file mode 100755 index ef18e37c5..000000000 --- a/scripts/legacy/scil_dilate_labels.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_labels_dilate import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_labels_dilate.py. -Now, all our scripts using labels start with scil_labels_...! - -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_labels_dilate.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_estimate_bundles_diameter.py b/scripts/legacy/scil_estimate_bundles_diameter.py deleted file mode 100755 index ff6a413a1..000000000 --- a/scripts/legacy/scil_estimate_bundles_diameter.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_bundle_diameter import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_bundle_diameter.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_estimate_bundles_diameter.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_evaluate_bundles_binary_classification_measures.py b/scripts/legacy/scil_evaluate_bundles_binary_classification_measures.py deleted file mode 100755 index 3978b2465..000000000 --- a/scripts/legacy/scil_evaluate_bundles_binary_classification_measures.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_bundle_score_same_bundle_many_segmentations import \ - main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed -scil_bundle_score_same_bundle_many_segmentations.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_evaluate_bundles_binary_classification_measures.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_evaluate_bundles_individual_measures.py b/scripts/legacy/scil_evaluate_bundles_individual_measures.py deleted file mode 100755 index 55a0d8016..000000000 --- a/scripts/legacy/scil_evaluate_bundles_individual_measures.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_bundle_shape_measures import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_bundle_shape_measures.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_evaluate_bundles_invidiual_measures.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_evaluate_bundles_pairwise_agreement_measures.py b/scripts/legacy/scil_evaluate_bundles_pairwise_agreement_measures.py deleted file mode 100755 index 4a33ff12e..000000000 --- a/scripts/legacy/scil_evaluate_bundles_pairwise_agreement_measures.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_bundle_pairwise_comparison import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_bundle_pairwise_comparison.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_evaluate_bundles_pairwise_agreement_measures.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_evaluate_connectivity_graph_measures.py b/scripts/legacy/scil_evaluate_connectivity_graph_measures.py deleted file mode 100755 index dc5b31bcf..000000000 --- a/scripts/legacy/scil_evaluate_connectivity_graph_measures.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_connectivity_graph_measures import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_connectivity_graph_measures.py. -All our scripts regarding connectivity now start with scil_connectivity_...! - -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_evaluate_connectivity_graph_measures.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_evaluate_connectivity_pairwise_agreement_measures.py b/scripts/legacy/scil_evaluate_connectivity_pairwise_agreement_measures.py deleted file mode 100755 index 12065b63d..000000000 --- a/scripts/legacy/scil_evaluate_connectivity_pairwise_agreement_measures.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_connectivity_pairwise_agreement import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_connectivity_pairwise_agreement.py. -All our scripts regarding connectivity now start with scil_connectivity_...! - -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_evaluate_connectivity_pairwaise_agreement_measures.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_execute_angle_aware_bilateral_filtering.py b/scripts/legacy/scil_execute_angle_aware_bilateral_filtering.py deleted file mode 100755 index eaa71f26d..000000000 --- a/scripts/legacy/scil_execute_angle_aware_bilateral_filtering.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_sh_to_aodf import main as new_main - - -DEPRECATION_MSG = """ -This script has been merged with scil_execute_asymmetric_filtering.py -into scil_sh_to_aodf.py Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_execute_angle_aware_bilateral_filtering.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_execute_asymmetric_filtering.py b/scripts/legacy/scil_execute_asymmetric_filtering.py deleted file mode 100755 index 8c1a10093..000000000 --- a/scripts/legacy/scil_execute_asymmetric_filtering.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_sh_to_aodf import main as new_main - - -DEPRECATION_MSG = """ -This script has been merged with scil_execute_angle_aware_bilateral_filtering.py -into scil_sh_to_aodf.py Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_execute_asymmetric_filtering.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_extract_b0.py b/scripts/legacy/scil_extract_b0.py deleted file mode 100755 index 9570c899e..000000000 --- a/scripts/legacy/scil_extract_b0.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_dwi_extract_b0 import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_dwi_extract_b0.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_extract_b0.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_extract_dwi_shell.py b/scripts/legacy/scil_extract_dwi_shell.py deleted file mode 100755 index b7d009a45..000000000 --- a/scripts/legacy/scil_extract_dwi_shell.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_dwi_extract_shell import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_dwi_extract_shell.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_extract_dwi_shell.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_extract_ushape.py b/scripts/legacy/scil_extract_ushape.py deleted file mode 100755 index e4fc8da29..000000000 --- a/scripts/legacy/scil_extract_ushape.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_extract_ushape import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_extract_ushape.py. Please change -your existing pipelines accordingly. -""" - - -@deprecate_script("scil_extract_ushape.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_filter_connectivity.py b/scripts/legacy/scil_filter_connectivity.py deleted file mode 100755 index 76160be89..000000000 --- a/scripts/legacy/scil_filter_connectivity.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_connectivity_filter import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_connectivity_filter.py. -All our scripts regarding connectivity now start with scil_connectivity_...! - -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_filter_connectivity.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_filter_streamlines_by_length.py b/scripts/legacy/scil_filter_streamlines_by_length.py deleted file mode 100755 index ba4da5e88..000000000 --- a/scripts/legacy/scil_filter_streamlines_by_length.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_filter_by_length import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_filter_by_length.py. Please change -your existing pipelines accordingly. -""" - - -@deprecate_script("scil_filter_streamlines_by_length.py", DEPRECATION_MSG, - '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_filter_streamlines_by_orientation.py b/scripts/legacy/scil_filter_streamlines_by_orientation.py deleted file mode 100755 index cc9fac412..000000000 --- a/scripts/legacy/scil_filter_streamlines_by_orientation.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_filter_by_orientation import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_filter_by_orientation.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_filter_streamlines_by_orientation.py", DEPRECATION_MSG, - '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_filter_tractogram.py b/scripts/legacy/scil_filter_tractogram.py deleted file mode 100755 index 53bfe88e4..000000000 --- a/scripts/legacy/scil_filter_tractogram.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_filter_by_roi import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_filter_by_roi.py. Please change -your existing pipelines accordingly. -""" - - -@deprecate_script("scil_filter_tractogram.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_filter_tractogram_anatomically.py b/scripts/legacy/scil_filter_tractogram_anatomically.py deleted file mode 100755 index a15fe7c48..000000000 --- a/scripts/legacy/scil_filter_tractogram_anatomically.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_filter_by_anatomy import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_filter_by_anatomy.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_filter_streamlines_anatomically.py", DEPRECATION_MSG, - '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_fit_bingham_to_fodf.py b/scripts/legacy/scil_fit_bingham_to_fodf.py deleted file mode 100755 index 914936d95..000000000 --- a/scripts/legacy/scil_fit_bingham_to_fodf.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_fodf_to_bingham import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_fodf_to_bingham.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_fit_bingham_to_fodf.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_flip_gradients.py b/scripts/legacy/scil_flip_gradients.py deleted file mode 100755 index 6d0e9897e..000000000 --- a/scripts/legacy/scil_flip_gradients.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_gradients_modify_axes import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_gradients_modify_axes.py. -Please change your existing pipelines accordingly. Please note that options -have changed, too. -""" - - -@deprecate_script("scil_flip_gradients.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_flip_streamlines.py b/scripts/legacy/scil_flip_streamlines.py deleted file mode 100755 index a61e1be9b..000000000 --- a/scripts/legacy/scil_flip_streamlines.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_flip import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_flip.py. Please change -your existing pipelines accordingly. -""" - - -@deprecate_script("scil_flip_streamlines.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_flip_surface.py b/scripts/legacy/scil_flip_surface.py deleted file mode 100755 index e3109e9d1..000000000 --- a/scripts/legacy/scil_flip_surface.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_surface_flip import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_surface_flip.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_flip_surface.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_flip_volume.py b/scripts/legacy/scil_flip_volume.py deleted file mode 100755 index c84adaa36..000000000 --- a/scripts/legacy/scil_flip_volume.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_volume_flip import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_volume_flip.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_flip_volume.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_generate_gradient_sampling.py b/scripts/legacy/scil_generate_gradient_sampling.py deleted file mode 100755 index f00aa4932..000000000 --- a/scripts/legacy/scil_generate_gradient_sampling.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_gradients_generate_sampling import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_gradients_generate_sampling.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_generate_gradient_sampling.py", DEPRECATION_MSG, - '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_generate_priors_from_bundle.py b/scripts/legacy/scil_generate_priors_from_bundle.py deleted file mode 100755 index c8fb9a34b..000000000 --- a/scripts/legacy/scil_generate_priors_from_bundle.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_bundle_generate_priors import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_bundle_generate_priors.py. -Now, all our scripts using labels start with scil_labels_...! - -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_generate_priors_from_bundle.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_group_comparison.py b/scripts/legacy/scil_group_comparison.py deleted file mode 100755 index cbca6f546..000000000 --- a/scripts/legacy/scil_group_comparison.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_stats_group_comparison import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_stats_group_comparison.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_group_comparison.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_harmonize_json.py b/scripts/legacy/scil_harmonize_json.py deleted file mode 100755 index eedf80956..000000000 --- a/scripts/legacy/scil_harmonize_json.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_json_harmonize_entries import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_json_harmonize_entries.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_merge_json.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_image_math.py b/scripts/legacy/scil_image_math.py deleted file mode 100755 index d0dc1373a..000000000 --- a/scripts/legacy/scil_image_math.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_volume_math import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_volume_math.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_image_math.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_merge_json.py b/scripts/legacy/scil_merge_json.py deleted file mode 100755 index 2bc51bb25..000000000 --- a/scripts/legacy/scil_merge_json.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_json_merge_entries import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_json_merge_entries.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_json_merge_entries.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_merge_sh.py b/scripts/legacy/scil_merge_sh.py deleted file mode 100755 index 74792d24f..000000000 --- a/scripts/legacy/scil_merge_sh.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_sh_fusion import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_sh_fusion.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_merge_sh.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_normalize_connectivity.py b/scripts/legacy/scil_normalize_connectivity.py deleted file mode 100755 index 72a7b0e80..000000000 --- a/scripts/legacy/scil_normalize_connectivity.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_connectivity_normalize import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_connectivity_normalize.py. -All our scripts regarding connectivity now start with scil_connectivity_...! - -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_normalize_connectivity.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_outlier_rejection.py b/scripts/legacy/scil_outlier_rejection.py deleted file mode 100755 index 9d35fa107..000000000 --- a/scripts/legacy/scil_outlier_rejection.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_bundle_reject_outliers import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_bundle_reject_outliers.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_outlier_rejection.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_perform_majority_vote.py b/scripts/legacy/scil_perform_majority_vote.py deleted file mode 100755 index 8029fdfe4..000000000 --- a/scripts/legacy/scil_perform_majority_vote.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_bundle_filter_by_occurence import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_bundle_filter_by_occurence.py. - -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_perform_majority_vote.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_plot_mean_std_per_point.py b/scripts/legacy/scil_plot_mean_std_per_point.py deleted file mode 100755 index e288e119f..000000000 --- a/scripts/legacy/scil_plot_mean_std_per_point.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_plot_stats_per_point import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_plot_stats_per_point.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_plot_mean_std_per_point.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_prepare_eddy_command.py b/scripts/legacy/scil_prepare_eddy_command.py deleted file mode 100755 index d14a6b97e..000000000 --- a/scripts/legacy/scil_prepare_eddy_command.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_dwi_prepare_eddy_command import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_dwi_prepare_eddy_command.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_prepare_eddy_command.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_prepare_topup_command.py b/scripts/legacy/scil_prepare_topup_command.py deleted file mode 100755 index 2e2c7fb78..000000000 --- a/scripts/legacy/scil_prepare_topup_command.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_dwi_prepare_topup_command import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_dwi_prepare_topup_command.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_prepare_topup_command.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_print_connectivity_filenames.py b/scripts/legacy/scil_print_connectivity_filenames.py deleted file mode 100755 index 351588d1c..000000000 --- a/scripts/legacy/scil_print_connectivity_filenames.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_connectivity_print_filenames import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_connectivity_print_filenames.py. -All our scripts regarding connectivity now start with scil_connectivity_...! - -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_print_connectivity_filenames.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_print_header.py b/scripts/legacy/scil_print_header.py deleted file mode 100755 index 9c7e26a49..000000000 --- a/scripts/legacy/scil_print_header.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_header_print_info import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_header_print_info.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_print_header.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_project_streamlines_to_map.py b/scripts/legacy/scil_project_streamlines_to_map.py deleted file mode 100755 index 457db1eca..000000000 --- a/scripts/legacy/scil_project_streamlines_to_map.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_project_streamlines_to_map import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_project_streamlines_to_map.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_project_streamlines_to_map.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_recognize_multi_bundles.py b/scripts/legacy/scil_recognize_multi_bundles.py deleted file mode 100755 index 9f3707a0e..000000000 --- a/scripts/legacy/scil_recognize_multi_bundles.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_segment_with_bundleseg import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_segment_with_bundleseg.py. Please -change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_recognize_multi_bundles.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_recognize_single_bundle.py b/scripts/legacy/scil_recognize_single_bundle.py deleted file mode 100755 index 6be0a8138..000000000 --- a/scripts/legacy/scil_recognize_single_bundle.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_segment_with_recobundles import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_segment_with_recobundles.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_recognize_single_bundle.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_register_tractogram.py b/scripts/legacy/scil_register_tractogram.py deleted file mode 100755 index ebec29c8b..000000000 --- a/scripts/legacy/scil_register_tractogram.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_register import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_register.py. Please change -your existing pipelines accordingly. - -""" - - -@deprecate_script("scil_register_tractogram.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_remove_invalid_streamlines.py b/scripts/legacy/scil_remove_invalid_streamlines.py deleted file mode 100755 index f372ee5fa..000000000 --- a/scripts/legacy/scil_remove_invalid_streamlines.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_remove_invalid import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_remove_invalid.py. Please change -your existing pipelines accordingly. - -""" - - -@deprecate_script("scil_remove_invalid_streamlines.py", DEPRECATION_MSG, - '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_remove_labels.py b/scripts/legacy/scil_remove_labels.py deleted file mode 100755 index 8d4d6f4bc..000000000 --- a/scripts/legacy/scil_remove_labels.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_labels_remove import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_labels_remove.py. -Now, all our scripts using labels start with scil_labels_...! - -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_remove_labels.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_remove_outliers_ransac.py b/scripts/legacy/scil_remove_outliers_ransac.py deleted file mode 100755 index e35ae01cb..000000000 --- a/scripts/legacy/scil_remove_outliers_ransac.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_volume_remove_outliers_ransac import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_volume_remove_outliers_ransac.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_remove_outliers_ransac.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_reorder_connectivity.py b/scripts/legacy/scil_reorder_connectivity.py deleted file mode 100755 index 85911ac39..000000000 --- a/scripts/legacy/scil_reorder_connectivity.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_connectivity_reorder_rois import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_connectivity_reorder_rois.py. -All our scripts regarding connectivity now start with scil_connectivity_...! - -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_reorder_connectivity.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_reorder_dwi_philips.py b/scripts/legacy/scil_reorder_dwi_philips.py deleted file mode 100755 index 617543c8c..000000000 --- a/scripts/legacy/scil_reorder_dwi_philips.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_dwi_reorder_philips import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_dwi_reorder_philips.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_reorder_dwi_philips.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_resample_bvals.py b/scripts/legacy/scil_resample_bvals.py deleted file mode 100755 index 77c92bf75..000000000 --- a/scripts/legacy/scil_resample_bvals.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_gradients_round_bvals import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_gradients_round_bvals_to_shells.py. -Please change your existing pipelines accordingly. Please note that options -have changed, too. -""" - - -@deprecate_script("scil_resample_bvals.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_resample_streamlines.py b/scripts/legacy/scil_resample_streamlines.py deleted file mode 100755 index 3b7f24144..000000000 --- a/scripts/legacy/scil_resample_streamlines.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_resample_nb_points import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_resample_nb_points.py. Please -change your existing pipelines accordingly. - -""" - - -@deprecate_script("scil_resample_streamlines.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_resample_tractogram.py b/scripts/legacy/scil_resample_tractogram.py deleted file mode 100755 index 641d4efd5..000000000 --- a/scripts/legacy/scil_resample_tractogram.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_resample import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_resample.py. Please change -your existing pipelines accordingly. - -""" - - -@deprecate_script("scil_resample_tractogram.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_resample_volume.py b/scripts/legacy/scil_resample_volume.py deleted file mode 100755 index 4356e179f..000000000 --- a/scripts/legacy/scil_resample_volume.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_volume_resample import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_volume_resample.py. Please change -your existing pipelines accordingly. - -""" - - -@deprecate_script("scil_resample_volume.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_reshape_to_reference.py b/scripts/legacy/scil_reshape_to_reference.py deleted file mode 100755 index f460081c8..000000000 --- a/scripts/legacy/scil_reshape_to_reference.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_volume_reslice_to_reference import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_volume_reslice_to_reference.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_reshape_to_reference.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_run_commit.py b/scripts/legacy/scil_run_commit.py deleted file mode 100755 index 1692ebbf7..000000000 --- a/scripts/legacy/scil_run_commit.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_commit import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_commit.py. Please change -your existing pipelines accordingly. -""" - - -@deprecate_script("scil_run_commit.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_run_nlmeans.py b/scripts/legacy/scil_run_nlmeans.py deleted file mode 100755 index 98ca7c2fb..000000000 --- a/scripts/legacy/scil_run_nlmeans.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_denoising_nlmeans import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_denoising_nlmeans.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_run_nlmeans.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_save_connections_from_hdf5.py b/scripts/legacy/scil_save_connections_from_hdf5.py deleted file mode 100755 index 0cbadfe45..000000000 --- a/scripts/legacy/scil_save_connections_from_hdf5.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_convert_hdf5_to_trk import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_convert_hdf5_to_trk.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_save_connections_from_hdf5.py", DEPRECATION_MSG, - '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_score_bundles.py b/scripts/legacy/scil_score_bundles.py deleted file mode 100755 index 75a1c2821..000000000 --- a/scripts/legacy/scil_score_bundles.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_bundle_score_many_bundles_one_tractogram import \ - main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_bundle_score_many_bundles_one_tractogram.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_score_bundles.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_score_tractogram.py b/scripts/legacy/scil_score_tractogram.py deleted file mode 100755 index 5b3d1ba2c..000000000 --- a/scripts/legacy/scil_score_tractogram.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_segment_with_ROI_and_score import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_segment_with_ROI_and_score.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_score_tractogram.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_screenshot_bundle.py b/scripts/legacy/scil_screenshot_bundle.py deleted file mode 100755 index f6189e3b0..000000000 --- a/scripts/legacy/scil_screenshot_bundle.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_viz_bundle_screenshot_mni import main as new_main - - -DEPRECATION_MSG = ''' -This script has been renamed scil_viz_bundle_screenshot_mni.py. Please change -your existing pipelines accordingly. -''' - - -@deprecate_script("scil_screenshot_bundle.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_screenshot_dti.py b/scripts/legacy/scil_screenshot_dti.py deleted file mode 100755 index 0f737a0b8..000000000 --- a/scripts/legacy/scil_screenshot_dti.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_viz_dti_screenshot import main as new_main - - -DEPRECATION_MSG = ''' -This script has been renamed scil_viz_dti_screenshot.py. Please change -your existing pipelines accordingly. -''' - - -@deprecate_script("scil_screenshot_dti.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_screenshot_volume.py b/scripts/legacy/scil_screenshot_volume.py deleted file mode 100755 index 8feb5e346..000000000 --- a/scripts/legacy/scil_screenshot_volume.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_viz_volume_screenshot import main as new_main - - -DEPRECATION_MSG = ''' -This script has been renamed scil_viz_volume_screenshot.py. Please change -your existing pipelines accordingly. -''' - - -@deprecate_script("scil_screenshot_volume.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_screenshot_volume_mosaic_overlap.py b/scripts/legacy/scil_screenshot_volume_mosaic_overlap.py deleted file mode 100755 index 94d0ca60f..000000000 --- a/scripts/legacy/scil_screenshot_volume_mosaic_overlap.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_viz_volume_screenshot_mosaic import main as new_main - - -DEPRECATION_MSG = ''' -This script has been renamed scil_viz_volume_screenshot_mosaic.py. Please -change your existing pipelines accordingly. -''' - - -@deprecate_script("scil_screenshot_volume_mosaic_overlap.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_set_response_function.py b/scripts/legacy/scil_set_response_function.py deleted file mode 100755 index e305ee7b0..000000000 --- a/scripts/legacy/scil_set_response_function.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_frf_set_diffusivities import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_frf_set_diffusivities.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_set_response_function.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_shuffle_streamlines.py b/scripts/legacy/scil_shuffle_streamlines.py deleted file mode 100755 index 980cfbf86..000000000 --- a/scripts/legacy/scil_shuffle_streamlines.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_shuffle import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_shuffle.py. Please change -your existing pipelines accordingly. -""" - - -@deprecate_script("scil_shuffle_streamlines.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_smooth_streamlines.py b/scripts/legacy/scil_smooth_streamlines.py deleted file mode 100755 index dd8f7378d..000000000 --- a/scripts/legacy/scil_smooth_streamlines.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_smooth import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_smooth.py. Please change -your existing pipelines accordingly. -""" - - -@deprecate_script("scil_smooth_streamlines.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_smooth_surface.py b/scripts/legacy/scil_smooth_surface.py deleted file mode 100755 index 0fb0fab5b..000000000 --- a/scripts/legacy/scil_smooth_surface.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_surface_smooth import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_surface_smooth.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_smooth_surface.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_snr_in_roi.py b/scripts/legacy/scil_snr_in_roi.py deleted file mode 100755 index a3bdcc7a5..000000000 --- a/scripts/legacy/scil_snr_in_roi.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_dwi_compute_snr import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_dwi_compute_snr.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_snr_in_roi.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_split_image.py b/scripts/legacy/scil_split_image.py deleted file mode 100755 index 20cb37d31..000000000 --- a/scripts/legacy/scil_split_image.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_dwi_split_by_indices import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_dwi_split_by_indices.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_split_image.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_split_tractogram.py b/scripts/legacy/scil_split_tractogram.py deleted file mode 100755 index 0fafcbd2d..000000000 --- a/scripts/legacy/scil_split_tractogram.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_split import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_split.py. Please change -your existing pipelines accordingly. -""" - - -@deprecate_script("scil_split_tractogram.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_split_volume_by_ids.py b/scripts/legacy/scil_split_volume_by_ids.py deleted file mode 100755 index cf0a45879..000000000 --- a/scripts/legacy/scil_split_volume_by_ids.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_labels_split_volume_by_ids import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_labels_split_volume_by_ids.py. -Now, all our scripts using labels start with scil_labels_...! - -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_split_volume_by_ids.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_split_volume_by_labels.py b/scripts/legacy/scil_split_volume_by_labels.py deleted file mode 100755 index b25890433..000000000 --- a/scripts/legacy/scil_split_volume_by_labels.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_labels_split_volume_from_lut import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_labels_split_volume_from_lut. -Now, all our scripts using labels start with scil_labels_...! - -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_split_volume_by_labels.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_streamlines_math.py b/scripts/legacy/scil_streamlines_math.py deleted file mode 100755 index 86d92211c..000000000 --- a/scripts/legacy/scil_streamlines_math.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_tractogram_math import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_tractogram_math.py. Please change -your existing pipelines accordingly. -""" - - -@deprecate_script("scil_streamlines_math.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_swap_gradient_axis.py b/scripts/legacy/scil_swap_gradient_axis.py deleted file mode 100755 index 2b8686e79..000000000 --- a/scripts/legacy/scil_swap_gradient_axis.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_gradients_modify_axes import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_gradients_modify_axes.py. -Please change your existing pipelines accordingly. Please note that options -have changed, too. -""" - - -@deprecate_script("scil_swap_gradient_axis.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_uniformize_streamlines_endpoints.py b/scripts/legacy/scil_uniformize_streamlines_endpoints.py deleted file mode 100755 index 8943896be..000000000 --- a/scripts/legacy/scil_uniformize_streamlines_endpoints.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_bundle_uniformize_endpoints import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_bundle_uniformize_endpoints.py. Please -change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_uniformize_streamlines_endpoints.py", DEPRECATION_MSG, - '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_validate_and_correct_bvecs.py b/scripts/legacy/scil_validate_and_correct_bvecs.py deleted file mode 100755 index 72fc36061..000000000 --- a/scripts/legacy/scil_validate_and_correct_bvecs.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_gradients_validate_correct import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_gradients_validate_correct.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_validate_and_correct_bvecs.py", DEPRECATION_MSG, - '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_validate_and_correct_eddy_gradients.py b/scripts/legacy/scil_validate_and_correct_eddy_gradients.py deleted file mode 100755 index a8065504b..000000000 --- a/scripts/legacy/scil_validate_and_correct_eddy_gradients.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_gradients_validate_correct_eddy import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_gradients_validate_correct_eddy.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_validate_and_correct_eddy_gradients.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_validate_bids.py b/scripts/legacy/scil_validate_bids.py deleted file mode 100755 index f4b0392bf..000000000 --- a/scripts/legacy/scil_validate_bids.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_bids_validate import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_bids_validate.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_validate_bids.py", DEPRECATION_MSG, - '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_verify_space_attributes_compatibility.py b/scripts/legacy/scil_verify_space_attributes_compatibility.py deleted file mode 100755 index ba4ca3007..000000000 --- a/scripts/legacy/scil_verify_space_attributes_compatibility.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_header_validate_compatibility import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_header_validate_compatibility.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_verify_space_attributes_compatibility.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_visualize_bingham_fit.py b/scripts/legacy/scil_visualize_bingham_fit.py deleted file mode 100755 index b43921ad1..000000000 --- a/scripts/legacy/scil_visualize_bingham_fit.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_viz_bingham_fit import main as new_main - - -DEPRECATION_MSG = ''' -This script has been renamed scil_viz_bingham_fit.py. Please change -your existing pipelines accordingly. -''' - - -@deprecate_script("scil_visualize_bingham_fit.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_visualize_bundles.py b/scripts/legacy/scil_visualize_bundles.py deleted file mode 100755 index 5f3d3d746..000000000 --- a/scripts/legacy/scil_visualize_bundles.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_viz_bundle import main as new_main - - -DEPRECATION_MSG = ''' -This script has been renamed scil_viz_bundle.py. Please change -your existing pipelines accordingly. -''' - - -@deprecate_script("scil_visualize_bundles.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_visualize_bundles_mosaic.py b/scripts/legacy/scil_visualize_bundles_mosaic.py deleted file mode 100755 index 881ab34ea..000000000 --- a/scripts/legacy/scil_visualize_bundles_mosaic.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_viz_bundle_screenshot_mosaic import main as new_main - - -DEPRECATION_MSG = ''' -This script has been renamed scil_viz_bundle_screenshot_mosaic.py. Please -change your existing pipelines accordingly. -''' - - -@deprecate_script("scil_visualize_bundles_mosaic.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_visualize_connectivity.py b/scripts/legacy/scil_visualize_connectivity.py deleted file mode 100755 index c713f0322..000000000 --- a/scripts/legacy/scil_visualize_connectivity.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_viz_connectivity import main as new_main - - -DEPRECATION_MSG = ''' -This script has been renamed scil_viz_connectivity.py. Please change -your existing pipelines accordingly. -''' - - -@deprecate_script("scil_visualize_connectivity.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_visualize_fodf.py b/scripts/legacy/scil_visualize_fodf.py deleted file mode 100755 index 50d37668b..000000000 --- a/scripts/legacy/scil_visualize_fodf.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_viz_fodf import main as new_main - - -DEPRECATION_MSG = ''' -This script has been renamed scil_viz_fodf.py. Please change -your existing pipelines accordingly. -''' - - -@deprecate_script("scil_visualize_fodf.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_visualize_gradients.py b/scripts/legacy/scil_visualize_gradients.py deleted file mode 100755 index 705d726de..000000000 --- a/scripts/legacy/scil_visualize_gradients.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_viz_gradients_screenshot import main as new_main - - -DEPRECATION_MSG = ''' -This script has been renamed scil_viz_gradients_screenshot.py. Please change -your existing pipelines accordingly. -''' - - -@deprecate_script("scil_visualize_gradients.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_visualize_histogram.py b/scripts/legacy/scil_visualize_histogram.py deleted file mode 100755 index 7e248f705..000000000 --- a/scripts/legacy/scil_visualize_histogram.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_viz_volume_histogram import main as new_main - - -DEPRECATION_MSG = ''' -This script has been renamed scil_viz_volume_histogram.py. Please change -your existing pipelines accordingly. -''' - - -@deprecate_script("scil_visualize_histogram.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_visualize_scatterplot.py b/scripts/legacy/scil_visualize_scatterplot.py deleted file mode 100755 index f73d5b4c7..000000000 --- a/scripts/legacy/scil_visualize_scatterplot.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_viz_volume_scatterplot import main as new_main - - -DEPRECATION_MSG = ''' -This script has been renamed scil_viz_volume_scatterplot.py. Please change -your existing pipelines accordingly. -''' - - -@deprecate_script("scil_visualize_scatterplot.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_visualize_seeds.py b/scripts/legacy/scil_visualize_seeds.py deleted file mode 100755 index 63662be54..000000000 --- a/scripts/legacy/scil_visualize_seeds.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_viz_tractogram_seeds import main as new_main - - -DEPRECATION_MSG = ''' -This script has been renamed scil_viz_tractogram_seeds.py. Please change -your existing pipelines accordingly. -''' - - -@deprecate_script("scil_visualize_seeds.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_visualize_seeds_3d.py b/scripts/legacy/scil_visualize_seeds_3d.py deleted file mode 100755 index e67acd0fa..000000000 --- a/scripts/legacy/scil_visualize_seeds_3d.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_viz_tractogram_seeds_3d import main as new_main - - -DEPRECATION_MSG = ''' -This script has been renamed scil_viz_tractogram_seeds_3d.py. Please -change your existing pipelines accordingly. -''' - - -@deprecate_script("scil_visualize_seeds_3d.py", DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/scil_volume_reshape_to_reference.py b/scripts/legacy/scil_volume_reshape_to_reference.py deleted file mode 100755 index 1df623cf2..000000000 --- a/scripts/legacy/scil_volume_reshape_to_reference.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from scilpy.io.deprecator import deprecate_script -from scripts.scil_volume_reslice_to_reference import main as new_main - - -DEPRECATION_MSG = """ -This script has been renamed scil_volume_reslice_to_reference.py. -Please change your existing pipelines accordingly. -""" - - -@deprecate_script("scil_volume_reshape_to_reference.py", - DEPRECATION_MSG, '2.0.0') -def main(): - new_main() - - -if __name__ == "__main__": - main() diff --git a/scripts/legacy/tests/test_legacy_scripts.py b/scripts/legacy/tests/test_legacy_scripts.py deleted file mode 100644 index 467bcf63b..000000000 --- a/scripts/legacy/tests/test_legacy_scripts.py +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -import pytest - -legacy_scripts_list_tag_1_6_0 = [ - "scil_add_tracking_mask_to_pft_maps.py", - "scil_analyse_lesions_load.py", - "scil_apply_bias_field_on_dwi.py", - "scil_apply_transform_to_bvecs.py", - "scil_apply_transform_to_hdf5.py", - "scil_apply_transform_to_image.py", - "scil_apply_transform_to_surface.py", - "scil_apply_transform_to_tractogram.py", - "scil_assign_custom_color_to_tractogram.py", - "scil_assign_uniform_color_to_tractograms.py", - "scil_clean_qbx_clusters.py", - "scil_combine_labels.py", - "scil_compare_connectivity.py", - "scil_compress_streamlines.py", - "scil_compute_asym_odf_metrics.py", - "scil_compute_bundle_mean_std_per_point.py", - "scil_compute_bundle_mean_std.py", - "scil_compute_bundle_volume_per_label.py", - "scil_compute_bundle_volume.py", - "scil_compute_bundle_voxel_label_map.py", - "scil_compute_centroid.py", - "scil_compute_connectivity.py", - "scil_compute_divide.py", - "scil_compute_dti_metrics.py", - "scil_compute_endpoints_map.py", - "scil_compute_fodf_max_in_ventricles.py", - "scil_compute_fodf_metrics.py", - "scil_compute_freewater.py", - "scil_compute_hdf5_average_density_map.py", - "scil_compute_ihMT_maps.py", - "scil_compute_kurtosis_metrics.py", - "scil_compute_lobe_specific_fodf_metrics.py", - "scil_compute_local_tracking_dev.py", - "scil_compute_local_tracking.py", - "scil_compute_maps_for_particle_filter_tracking.py", - "scil_compute_mean_fixel_afd_from_bundles.py", - "scil_compute_mean_fixel_afd_from_hdf5.py", - "scil_compute_mean_fixel_lobe_metric_from_bundles.py", - "scil_compute_mean_frf.py", - "scil_compute_memsmt_fodf.py", - "scil_compute_memsmt_frf.py", - "scil_compute_metrics_stats_in_ROI.py", - "scil_compute_msmt_fodf.py", - "scil_compute_msmt_frf.py", - "scil_compute_MT_maps.py", - "scil_compute_NODDI_priors.py", - "scil_compute_NODDI.py", - "scil_compute_pca.py", - "scil_compute_pft.py", - "scil_compute_powder_average.py", - "scil_compute_qball_metrics.py", - "scil_compute_qbx.py", - "scil_compute_rish_from_sh.py", - "scil_compute_seed_by_labels.py", - "scil_compute_seed_density_map.py", - "scil_compute_sf_from_sh.py", - "scil_compute_sh_from_signal.py", - "scil_compute_ssst_fodf.py", - "scil_compute_ssst_frf.py", - "scil_compute_streamlines_density_map.py", - "scil_compute_streamlines_length_stats.py", - "scil_compute_todi.py", - "scil_concatenate_dwi.py", - "scil_connectivity_math.py", - "scil_convert_gradients_fsl_to_mrtrix.py", - "scil_convert_gradients_mrtrix_to_fsl.py", - "scil_convert_fdf.py", - "scil_convert_json_to_xlsx.py", - "scil_convert_rgb.py", - "scil_convert_sh_basis.py", - "scil_convert_surface.py", - "scil_convert_tensors.py", - "scil_convert_tractogram.py", - "scil_count_non_zero_voxels.py", - "scil_count_streamlines.py", - "scil_crop_volume.py", - "scil_cut_streamlines.py", - "scil_decompose_connectivity.py", - "scil_detect_dwi_volume_outliers.py", - "scil_detect_streamlines_loops.py", - "scil_dilate_labels.py", - "scil_estimate_bundles_diameter.py", - "scil_evaluate_bundles_binary_classification_measures.py", - "scil_evaluate_bundles_individual_measures.py", - "scil_evaluate_bundles_pairwise_agreement_measures.py", - "scil_evaluate_connectivity_graph_measures.py", - "scil_evaluate_connectivity_pairwise_agreement_measures.py", - "scil_execute_angle_aware_bilateral_filtering.py", - "scil_execute_asymmetric_filtering.py", - "scil_extract_b0.py", - "scil_extract_dwi_shell.py", - "scil_extract_ushape.py", - "scil_filter_connectivity.py", - "scil_filter_streamlines_by_length.py", - "scil_filter_streamlines_by_orientation.py", - "scil_filter_tractogram_anatomically.py", - "scil_filter_tractogram.py", - "scil_fit_bingham_to_fodf.py", - "scil_flip_gradients.py", - "scil_flip_streamlines.py", - "scil_flip_surface.py", - "scil_flip_volume.py", - "scil_generate_gradient_sampling.py", - "scil_generate_priors_from_bundle.py", - "scil_get_version.py", - "scil_group_comparison.py", - "scil_harmonize_json.py", - "scil_image_math.py", - "scil_merge_json.py", - "scil_merge_sh.py", - "scil_normalize_connectivity.py", - "scil_outlier_rejection.py", - "scil_perform_majority_vote.py", - "scil_plot_mean_std_per_point.py", - "scil_prepare_eddy_command.py", - "scil_prepare_topup_command.py", - "scil_print_connectivity_filenames.py", - "scil_print_header.py", - "scil_tractogram_project_streamlines_to_map.py", - "scil_recognize_multi_bundles.py", - "scil_recognize_single_bundle.py", - "scil_register_tractogram.py", - "scil_remove_invalid_streamlines.py", - "scil_remove_labels.py", - "scil_remove_outliers_ransac.py", - "scil_reorder_connectivity.py", - "scil_reorder_dwi_philips.py", - "scil_resample_bvals.py", - "scil_resample_streamlines.py", - "scil_resample_tractogram.py", - "scil_resample_volume.py", - "scil_reshape_to_reference.py", - "scil_run_commit.py", - "scil_run_nlmeans.py", - "scil_save_connections_from_hdf5.py", - "scil_score_bundles.py", - "scil_score_tractogram.py", - "scil_screenshot_bundle.py", - "scil_screenshot_dti.py", - "scil_screenshot_volume_mosaic_overlap.py", - "scil_screenshot_volume.py", - "scil_search_keywords.py", - "scil_set_response_function.py", - "scil_shuffle_streamlines.py", - "scil_smooth_streamlines.py", - "scil_smooth_surface.py", - "scil_snr_in_roi.py", - "scil_split_image.py", - "scil_split_tractogram.py", - "scil_split_volume_by_ids.py", - "scil_split_volume_by_labels.py", - "scil_streamlines_math.py", - "scil_swap_gradient_axis.py", - "scil_tractogram_math.py", - "scil_uniformize_streamlines_endpoints.py", - "scil_validate_and_correct_bvecs.py", - "scil_validate_and_correct_eddy_gradients.py", - "scil_validate_bids.py", - "scil_verify_space_attributes_compatibility.py", - "scil_visualize_bingham_fit.py", - "scil_visualize_bundles_mosaic.py", - "scil_visualize_bundles.py", - "scil_visualize_connectivity.py", - "scil_visualize_fodf.py", - "scil_visualize_gradients.py", - "scil_visualize_histogram.py", - "scil_visualize_scatterplot.py", - "scil_visualize_seeds_3d.py", - "scil_visualize_seeds.py"] - - -# test that all scripts available in scilpy 1.6.0 can be called -@pytest.mark.filterwarnings("ignore") -def test_help_option(script_runner): - for script in legacy_scripts_list_tag_1_6_0: - ret = script_runner.run(script, '--help') - assert ret.success diff --git a/scripts/tests/test_bundle_explore_bundleseg.py b/scripts/tests/test_bundle_explore_bundleseg.py deleted file mode 100644 index 397d593ed..000000000 --- a/scripts/tests/test_bundle_explore_bundleseg.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - - -def test_help_option(script_runner): - ret = script_runner.run('scil_viz_bundle_screenshot_mni.py', '--help') - assert ret.success diff --git a/scripts/tests/test_bundle_mean_fixel_mrds_metric.py b/scripts/tests/test_bundle_mean_fixel_mrds_metric.py deleted file mode 100644 index efe916c2e..000000000 --- a/scripts/tests/test_bundle_mean_fixel_mrds_metric.py +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -def test_help_option(script_runner): - ret = script_runner.run( - 'scil_bundle_mean_fixel_mrds_metric.py', '--help') - - assert ret.success diff --git a/scripts/tests/test_dwi_prepare_topup_command.py b/scripts/tests/test_dwi_prepare_topup_command.py deleted file mode 100644 index e8380bbca..000000000 --- a/scripts/tests/test_dwi_prepare_topup_command.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - - -def test_help_option(script_runner): - ret = script_runner.run('scil_dwi_prepare_topup_command.py', '--help') - assert ret.success diff --git a/scripts/tests/test_fibertube_tracking.py b/scripts/tests/test_fibertube_tracking.py deleted file mode 100644 index cedcb9384..000000000 --- a/scripts/tests/test_fibertube_tracking.py +++ /dev/null @@ -1,151 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -import os -import tempfile -import numpy as np -import nibabel as nib - -from scilpy.io.streamlines import save_tractogram -from dipy.io.stateful_tractogram import StatefulTractogram, Space, Origin - -tmp_dir = tempfile.TemporaryDirectory() - - -def init_data(): - streamlines = [[[5., 1., 5.], [5., 5., 9.], [7., 9., 9.], [13., 11., 9.], - [5., 7., 7.]], [[7., 7., 7.], [9., 9., 9.]]] - - mask = np.ones((15, 15, 15)) - affine = np.eye(4) - header = nib.nifti2.Nifti2Header() - extra = { - 'affine': affine, - 'dimensions': (15, 15, 15), - 'voxel_size': 1., - 'voxel_order': "RAS" - } - mask_img = nib.nifti2.Nifti2Image(mask, affine, header, extra) - - sft = StatefulTractogram(streamlines, mask_img, - space=Space.VOX, - origin=Origin.NIFTI) - sft.data_per_streamline = { - "diameters": [0.002, 0.001] - } - - save_tractogram(sft, 'tractogram.trk', True) - - -def test_help_option(script_runner): - ret = script_runner.run('scil_fibertube_tracking.py', '--help') - assert ret.success - - -def test_execution(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - init_data() - ret = script_runner.run('scil_fibertube_tracking.py', - 'tractogram.trk', 'tracking.trk', - '--min_length', '0', '-f') - assert ret.success - - -def test_execution_rk(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - init_data() - ret = script_runner.run('scil_fibertube_tracking.py', - 'tractogram.trk', 'tracking.trk', - '--rk_order', '2', '--min_length', '0', '-f') - assert ret.success - - -def test_execution_config(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - init_data() - ret = script_runner.run('scil_fibertube_tracking.py', - 'tractogram.trk', 'tracking.trk', - '--blur_radius', '0.3', - '--step_size', '0.1', - '--out_config', 'config.json', - '--min_length', '0', '-f') - assert ret.success - - -def test_execution_seeding(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - init_data() - ret = script_runner.run('scil_fibertube_tracking.py', - 'tractogram.trk', 'tracking.trk', - '--nb_fibertubes', '1', - '--nb_seeds_per_fibertube', '3', '--skip', '3', - '--local_seeding', 'center', - '--min_length', '0', '-f') - assert ret.success - - -def test_execution_FTODF(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - init_data() - ret = script_runner.run('scil_fibertube_tracking.py', - 'tractogram.trk', 'tracking.trk', '--use_ftODF', - '--min_length', '0', '-f') - assert ret.success - - -def test_execution_FTODF_rk(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - init_data() - ret = script_runner.run('scil_fibertube_tracking.py', - 'tractogram.trk', 'tracking.trk', '--use_ftODF', - '--rk_order', '2', '--min_length', '0', '-f') - assert ret.success - - -def test_execution_FTODF_config(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - init_data() - ret = script_runner.run('scil_fibertube_tracking.py', - 'tractogram.trk', 'tracking.trk', '--use_ftODF', - '--blur_radius', '0.3', - '--step_size', '0.1', - '--out_config', 'config.json', - '--min_length', '0', '-f') - assert ret.success - - -def test_execution_FTODF_seeding(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - init_data() - ret = script_runner.run('scil_fibertube_tracking.py', - 'tractogram.trk', 'tracking.trk', '--use_ftODF', - '--nb_fibertubes', '1', - '--nb_seeds_per_fibertube', '3', '--skip', '3', - '--local_seeding', 'center', - '--min_length', '0', '-f') - assert ret.success - - -def test_execution_FTODF_sphere(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - init_data() - ret = script_runner.run('scil_fibertube_tracking.py', - 'tractogram.trk', 'tracking.trk', '--use_ftODF', - '--sh_order', '4', - '--sphere', 'symmetric362', - '--sh_basis', 'tournier07', - '--sub_sphere', '0', - '--sfthres', '0.05', - '--sfthres_init', '0.4', - '--min_length', '0', '-f') - assert ret.success - - -def test_execution_FTODF_det(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - init_data() - ret = script_runner.run('scil_fibertube_tracking.py', - 'tractogram.trk', 'tracking.trk', '--use_ftODF', - '--algo', 'det', - '--min_length', '0', '-f') - assert ret.success diff --git a/scripts/tests/test_json_harmonize_entries.py b/scripts/tests/test_json_harmonize_entries.py deleted file mode 100644 index 42be74118..000000000 --- a/scripts/tests/test_json_harmonize_entries.py +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -def test_help_option(script_runner): - ret = script_runner.run('scil_json_harmonize_entries.py', '--help') - assert ret.success diff --git a/scripts/tests/test_mti_maps_MT.py b/scripts/tests/test_mti_maps_MT.py deleted file mode 100644 index 3c893bd37..000000000 --- a/scripts/tests/test_mti_maps_MT.py +++ /dev/null @@ -1,255 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -import os -import tempfile - -from scilpy import SCILPY_HOME -from scilpy.io.fetcher import fetch_data, get_testing_files_dict - -# If they already exist, this only takes 5 seconds (check md5sum) -fetch_data(get_testing_files_dict(), keys=['MT.zip']) -tmp_dir = tempfile.TemporaryDirectory() - - -# Preparing once the filenames. -in_mask = os.path.join(SCILPY_HOME, 'MT', 'mask.nii.gz') - -in_mtoff_json = os.path.join(SCILPY_HOME, - 'MT', 'sub-001_echo-1_acq-mtoff_mtsat.json') -in_t1w_json = os.path.join(SCILPY_HOME, - 'MT', 'sub-001_echo-1_acq-t1w_mtsat.json') - -in_e1_mtoff = os.path.join(SCILPY_HOME, - 'MT', 'sub-001_echo-1_acq-mtoff_mtsat.nii.gz') -in_e2_mtoff = os.path.join(SCILPY_HOME, - 'MT', 'sub-001_echo-2_acq-mtoff_mtsat.nii.gz') -in_e3_mtoff = os.path.join(SCILPY_HOME, - 'MT', 'sub-001_echo-3_acq-mtoff_mtsat.nii.gz') -in_e4_mtoff = os.path.join(SCILPY_HOME, - 'MT', 'sub-001_echo-4_acq-mtoff_mtsat.nii.gz') -in_e5_mtoff = os.path.join(SCILPY_HOME, - 'MT', 'sub-001_echo-5_acq-mtoff_mtsat.nii.gz') - -in_e1_mton = os.path.join(SCILPY_HOME, - 'MT', 'sub-001_echo-1_acq-mton_mtsat.nii.gz') -in_e2_mton = os.path.join(SCILPY_HOME, - 'MT', 'sub-001_echo-2_acq-mton_mtsat.nii.gz') -in_e3_mton = os.path.join(SCILPY_HOME, - 'MT', 'sub-001_echo-3_acq-mton_mtsat.nii.gz') -in_e4_mton = os.path.join(SCILPY_HOME, - 'MT', 'sub-001_echo-4_acq-mton_mtsat.nii.gz') -in_e5_mton = os.path.join(SCILPY_HOME, - 'MT', 'sub-001_echo-5_acq-mton_mtsat.nii.gz') - -in_e1_t1w = os.path.join(SCILPY_HOME, - 'MT', 'sub-001_echo-1_acq-t1w_mtsat.nii.gz') -in_e2_t1w = os.path.join(SCILPY_HOME, - 'MT', 'sub-001_echo-2_acq-t1w_mtsat.nii.gz') -in_e3_t1w = os.path.join(SCILPY_HOME, - 'MT', 'sub-001_echo-3_acq-t1w_mtsat.nii.gz') -in_e4_t1w = os.path.join(SCILPY_HOME, - 'MT', 'sub-001_echo-4_acq-t1w_mtsat.nii.gz') -in_e5_t1w = os.path.join(SCILPY_HOME, - 'MT', 'sub-001_echo-5_acq-t1w_mtsat.nii.gz') - -in_b1_map = os.path.join(SCILPY_HOME, 'MT', 'sub-001_run-01_B1map.nii.gz') -in_b1_json = os.path.join(SCILPY_HOME, 'MT', 'sub-001_run-01_B1map.json') - - -def test_help_option(script_runner): - ret = script_runner.run('scil_mti_maps_MT.py', '--help') - assert ret.success - - -def test_execution_MT_no_option(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - # no option - ret = script_runner.run('scil_mti_maps_MT.py', tmp_dir.name, - '--mask', in_mask, - '--in_mtoff_pd', in_e1_mtoff, in_e2_mtoff, - in_e3_mtoff, in_e4_mtoff, in_e5_mtoff, - '--in_positive', in_e1_mton, in_e2_mton, - in_e3_mton, in_e4_mton, in_e5_mton, - '--in_mtoff_t1', in_e1_t1w, in_e2_t1w, in_e3_t1w, - in_e4_t1w, in_e5_t1w, - '--in_jsons', in_mtoff_json, in_t1w_json, - '-f') - assert ret.success - - -def test_execution_MT_prefix(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - # --out_prefix - ret = script_runner.run('scil_mti_maps_MT.py', tmp_dir.name, - '--mask', in_mask, - '--in_mtoff_pd', in_e1_mtoff, in_e2_mtoff, - in_e3_mtoff, in_e4_mtoff, in_e5_mtoff, - '--in_positive', in_e1_mton, in_e2_mton, - in_e3_mton, in_e4_mton, in_e5_mton, - '--in_mtoff_t1', in_e1_t1w, in_e2_t1w, in_e3_t1w, - in_e4_t1w, in_e5_t1w, - '--in_jsons', in_mtoff_json, in_t1w_json, - '--out_prefix', 'sub_01', - '-f') - assert ret.success - - -def test_execution_MT_extended(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - # --extended - ret = script_runner.run('scil_mti_maps_MT.py', tmp_dir.name, - '--mask', in_mask, - '--in_mtoff_pd', in_e1_mtoff, in_e2_mtoff, - in_e3_mtoff, in_e4_mtoff, in_e5_mtoff, - '--in_positive', in_e1_mton, in_e2_mton, - in_e3_mton, in_e4_mton, in_e5_mton, - '--in_mtoff_t1', in_e1_t1w, in_e2_t1w, in_e3_t1w, - in_e4_t1w, in_e5_t1w, - '--in_jsons', in_mtoff_json, in_t1w_json, - '--extended', - '-f') - assert ret.success - - -def test_execution_MT_filtering(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - # --filtering - ret = script_runner.run('scil_mti_maps_MT.py', tmp_dir.name, - '--mask', in_mask, - '--in_mtoff_pd', in_e1_mtoff, in_e2_mtoff, - in_e3_mtoff, in_e4_mtoff, in_e5_mtoff, - '--in_positive', in_e1_mton, in_e2_mton, - in_e3_mton, in_e4_mton, in_e5_mton, - '--in_mtoff_t1', in_e1_t1w, in_e2_t1w, in_e3_t1w, - in_e4_t1w, in_e5_t1w, - '--in_jsons', in_mtoff_json, in_t1w_json, - '--filtering', - '-f') - assert ret.success - - -def test_execution_MT_B1_map(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - out_b1_map = tmp_dir.name + '/B1map.nii.gz' - - # Temporary trick to have the B1 map with proper header. - ret = script_runner.run('scil_mti_adjust_B1_header.py', in_b1_map, - out_b1_map, in_b1_json, '-f') - - # --in_B1_map - ret = script_runner.run('scil_mti_maps_MT.py', tmp_dir.name, - '--mask', in_mask, - '--in_mtoff_pd', in_e1_mtoff, in_e2_mtoff, - in_e3_mtoff, in_e4_mtoff, in_e5_mtoff, - '--in_positive', in_e1_mton, in_e2_mton, - in_e3_mton, in_e4_mton, in_e5_mton, - '--in_negative', in_e1_mton, in_e2_mton, - in_e3_mton, in_e4_mton, in_e5_mton, - '--in_mtoff_t1', in_e1_t1w, in_e2_t1w, in_e3_t1w, - in_e4_t1w, in_e5_t1w, - '--in_jsons', in_mtoff_json, in_t1w_json, - '--in_B1_map', out_b1_map, - '--B1_correction_method', 'empiric', - '--out_prefix', 'sub-01', - '-f') - assert ret.success - - -def test_execution_MT_wrong_echoes(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - # Wrong number of echoes for negative - ret = script_runner.run('scil_mti_maps_MT.py', tmp_dir.name, - '--mask', in_mask, - '--in_mtoff_pd', in_e1_mtoff, in_e2_mtoff, - in_e3_mtoff, in_e4_mtoff, in_e5_mtoff, - '--in_positive', in_e1_mton, in_e2_mton, - in_e3_mton, in_e4_mton, in_e5_mton, - '--in_negative', in_e1_mton, in_e2_mton, - in_e3_mton, in_e4_mton, - '--in_mtoff_t1', in_e1_t1w, in_e2_t1w, in_e3_t1w, - in_e4_t1w, in_e5_t1w, - '--in_jsons', in_mtoff_json, in_t1w_json, - '-f') - assert (not ret.success) - - -def test_execution_MT_single_echoe(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - # Single echoe - ret = script_runner.run('scil_mti_maps_MT.py', tmp_dir.name, - '--mask', in_mask, - '--in_mtoff_pd', in_e1_mtoff, - '--in_positive', in_e1_mton, - '--in_negative', in_e1_mton, - '--in_mtoff_t1', in_e1_t1w, - '--in_jsons', in_mtoff_json, in_t1w_json, - '-f') - assert ret.success - - -def test_execution_MT_B1_not_T1(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - out_b1_map = tmp_dir.name + '/B1map.nii.gz' - - # Temporary trick to have the B1 map with proper header. - ret = script_runner.run('scil_mti_adjust_B1_header.py', in_b1_map, - out_b1_map, in_b1_json, '-f') - - # B1 no T1 should raise warning. - ret = script_runner.run('scil_mti_maps_MT.py', tmp_dir.name, - '--mask', in_mask, - '--in_mtoff_pd', in_e1_mtoff, - '--in_positive', in_e1_mton, - '--in_negative', in_e1_mton, - '--in_jsons', in_mtoff_json, in_t1w_json, - '--in_B1_map', out_b1_map, - '--B1_correction_method', 'empiric', - '-f') - assert ret.success - - -def test_execution_MT_B1_no_fit(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - out_b1_map = tmp_dir.name + '/B1map.nii.gz' - - # Temporary trick to have the B1 map with proper header. - ret = script_runner.run('scil_mti_adjust_B1_header.py', in_b1_map, - out_b1_map, in_b1_json, '-f') - - # B1 model_based but no fit values - ret = script_runner.run('scil_mti_maps_MT.py', tmp_dir.name, - '--mask', in_mask, - '--in_mtoff_pd', in_e1_mtoff, - '--in_positive', in_e1_mton, - '--in_negative', in_e1_mton, - '--in_mtoff_t1', in_e1_t1w, - '--in_jsons', in_mtoff_json, in_t1w_json, - '--in_B1_map', out_b1_map, - '--B1_correction_method', 'model_based', - '-f') - assert (not ret.success) - - -def test_execution_MT_acq_params(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - # Acquisition parameters - ret = script_runner.run('scil_mti_maps_MT.py', tmp_dir.name, - '--mask', in_mask, - '--in_mtoff_pd', in_e1_mtoff, - '--in_positive', in_e1_mton, - '--in_negative', in_e1_mton, - '--in_mtoff_t1', in_e1_t1w, - '--in_acq_parameters', "15", "15", "0.1", "0.1", - '-f') - assert ret.success diff --git a/scripts/tests/test_mti_maps_ihMT.py b/scripts/tests/test_mti_maps_ihMT.py deleted file mode 100644 index 27476dd23..000000000 --- a/scripts/tests/test_mti_maps_ihMT.py +++ /dev/null @@ -1,308 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -import os -import tempfile - -from scilpy import SCILPY_HOME -from scilpy.io.fetcher import fetch_data, get_testing_files_dict - -# If they already exist, this only takes 5 seconds (check md5sum) -fetch_data(get_testing_files_dict(), keys=['ihMT.zip']) -tmp_dir = tempfile.TemporaryDirectory() - -# Preparing once the filenames. - -in_mask = os.path.join(SCILPY_HOME, 'ihMT', 'mask_resample.nii.gz') - -in_mtoff_pd_json = os.path.join(SCILPY_HOME, - 'ihMT', 'echo-1_acq-mtoff_ihmt.json') -in_mtoff_t1_json = os.path.join(SCILPY_HOME, - 'ihMT', 'echo-1_acq-T1w_ihmt.json') - -in_e1_altnp = os.path.join(SCILPY_HOME, - 'ihMT', 'echo-1_acq-altnp_ihmt.nii.gz') -in_e2_altnp = os.path.join(SCILPY_HOME, - 'ihMT', 'echo-2_acq-altnp_ihmt.nii.gz') -in_e3_altnp = os.path.join(SCILPY_HOME, - 'ihMT', 'echo-3_acq-altnp_ihmt.nii.gz') - -in_e1_altpn = os.path.join(SCILPY_HOME, - 'ihMT', 'echo-1_acq-altpn_ihmt.nii.gz') -in_e2_altpn = os.path.join(SCILPY_HOME, - 'ihMT', 'echo-2_acq-altpn_ihmt.nii.gz') -in_e3_altpn = os.path.join(SCILPY_HOME, - 'ihMT', 'echo-3_acq-altpn_ihmt.nii.gz') - -in_e1_mtoff_pd = os.path.join(SCILPY_HOME, - 'ihMT', 'echo-1_acq-mtoff_ihmt.nii.gz') -in_e2_mtoff_pd = os.path.join(SCILPY_HOME, - 'ihMT', 'echo-2_acq-mtoff_ihmt.nii.gz') -in_e3_mtoff_pd = os.path.join(SCILPY_HOME, - 'ihMT', 'echo-3_acq-mtoff_ihmt.nii.gz') - -in_e1_neg = os.path.join(SCILPY_HOME, - 'ihMT', 'echo-1_acq-neg_ihmt.nii.gz') -in_e2_neg = os.path.join(SCILPY_HOME, - 'ihMT', 'echo-2_acq-neg_ihmt.nii.gz') -in_e3_neg = os.path.join(SCILPY_HOME, - 'ihMT', 'echo-3_acq-neg_ihmt.nii.gz') - -in_e1_pos = os.path.join(SCILPY_HOME, - 'ihMT', 'echo-1_acq-pos_ihmt.nii.gz') -in_e2_pos = os.path.join(SCILPY_HOME, - 'ihMT', 'echo-2_acq-pos_ihmt.nii.gz') -in_e3_pos = os.path.join(SCILPY_HOME, - 'ihMT', 'echo-3_acq-pos_ihmt.nii.gz') - -in_e1_mtoff_t1 = os.path.join(SCILPY_HOME, - 'ihMT', 'echo-1_acq-T1w_ihmt.nii.gz') -in_e2_mtoff_t1 = os.path.join(SCILPY_HOME, - 'ihMT', 'echo-2_acq-T1w_ihmt.nii.gz') -in_e3_mtoff_t1 = os.path.join(SCILPY_HOME, - 'ihMT', 'echo-3_acq-T1w_ihmt.nii.gz') - -in_b1_map = os.path.join(SCILPY_HOME, 'ihMT', 'B1map.nii.gz') -in_b1_json = os.path.join(SCILPY_HOME, 'MT', 'sub-001_run-01_B1map.json') - - -def test_help_option(script_runner): - ret = script_runner.run('scil_mti_maps_ihMT.py', '--help') - assert ret.success - - -def test_execution_ihMT_no_option(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - # no option - ret = script_runner.run('scil_mti_maps_ihMT.py', tmp_dir.name, - '--mask', in_mask, - '--in_altnp', in_e1_altnp, in_e2_altnp, - in_e3_altnp, - '--in_altpn', in_e1_altpn, in_e2_altpn, - in_e3_altpn, - '--in_mtoff_pd', in_e1_mtoff_pd, in_e2_mtoff_pd, - in_e3_mtoff_pd, - '--in_negative', in_e1_neg, in_e2_neg, in_e3_neg, - '--in_positive', in_e1_pos, in_e2_pos, in_e3_pos, - '--in_mtoff_t1', in_e1_mtoff_t1, in_e2_mtoff_t1, - in_e3_mtoff_t1, - '--in_jsons', in_mtoff_pd_json, - in_mtoff_t1_json, - '-f') - assert ret.success - - -def test_execution_ihMT_prefix(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - # --out_prefix - ret = script_runner.run('scil_mti_maps_ihMT.py', tmp_dir.name, - '--mask', in_mask, - '--in_altnp', in_e1_altnp, in_e2_altnp, - in_e3_altnp, - '--in_altpn', in_e1_altpn, in_e2_altpn, - in_e3_altpn, - '--in_mtoff_pd', in_e1_mtoff_pd, in_e2_mtoff_pd, - in_e3_mtoff_pd, - '--in_negative', in_e1_neg, in_e2_neg, - in_e3_neg, - '--in_positive', in_e1_pos, in_e2_pos, - in_e3_pos, - '--in_mtoff_t1', in_e1_mtoff_t1, in_e2_mtoff_t1, - in_e3_mtoff_t1, - '--in_jsons', in_mtoff_pd_json, - in_mtoff_t1_json, - '--out_prefix', 'sub_01', - '-f') - assert ret.success - - -def test_execution_ihMT_extended(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - # --extended - ret = script_runner.run('scil_mti_maps_ihMT.py', tmp_dir.name, - '--mask', in_mask, - '--in_altnp', in_e1_altnp, in_e2_altnp, - in_e3_altnp, - '--in_altpn', in_e1_altpn, in_e2_altpn, - in_e3_altpn, - '--in_mtoff_pd', in_e1_mtoff_pd, in_e2_mtoff_pd, - in_e3_mtoff_pd, - '--in_negative', in_e1_neg, in_e2_neg, - in_e3_neg, - '--in_positive', in_e1_pos, in_e2_pos, - in_e3_pos, - '--in_mtoff_t1', in_e1_mtoff_t1, in_e2_mtoff_t1, - in_e3_mtoff_t1, - '--in_jsons', in_mtoff_pd_json, - in_mtoff_t1_json, - '--extended', - '-f') - assert ret.success - - -def test_execution_ihMT_filtering(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - # --filtering - ret = script_runner.run('scil_mti_maps_ihMT.py', tmp_dir.name, - '--mask', in_mask, - '--in_altnp', in_e1_altnp, in_e2_altnp, - in_e3_altnp, - '--in_altpn', in_e1_altpn, in_e2_altpn, - in_e3_altpn, - '--in_mtoff_pd', in_e1_mtoff_pd, in_e2_mtoff_pd, - in_e3_mtoff_pd, - '--in_negative', in_e1_neg, in_e2_neg, in_e3_neg, - '--in_positive', in_e1_pos, in_e2_pos, in_e3_pos, - '--in_mtoff_t1', in_e1_mtoff_t1, in_e2_mtoff_t1, - in_e3_mtoff_t1, - '--in_jsons', in_mtoff_pd_json, - in_mtoff_t1_json, - '--out_prefix', 'sub-01', - '--filtering', - '-f') - assert ret.success - - -def test_execution_ihMT_B1_map(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - out_b1_map = tmp_dir.name + '/B1map.nii.gz' - - # Temporary trick to have the B1 map with proper header. - ret = script_runner.run('scil_mti_adjust_B1_header.py', in_b1_map, - out_b1_map, in_b1_json, '-f') - - ret = script_runner.run('scil_mti_maps_ihMT.py', tmp_dir.name, - '--mask', in_mask, - '--in_altnp', in_e1_altnp, in_e2_altnp, - in_e3_altnp, - '--in_altpn', in_e1_altpn, in_e2_altpn, - in_e3_altpn, - '--in_mtoff_pd', in_e1_mtoff_pd, in_e2_mtoff_pd, - in_e3_mtoff_pd, - '--in_negative', in_e1_neg, in_e2_neg, in_e3_neg, - '--in_positive', in_e1_pos, in_e2_pos, in_e3_pos, - '--in_mtoff_t1', in_e1_mtoff_t1, in_e2_mtoff_t1, - in_e3_mtoff_t1, - '--out_prefix', 'sub-01', - '--in_B1_map', out_b1_map, - '--B1_correction_method', 'empiric', - '--in_jsons', in_mtoff_pd_json, - in_mtoff_t1_json, - '-f') - assert ret.success - - -def test_execution_ihMT_B1_no_T1(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - out_b1_map = tmp_dir.name + '/B1map.nii.gz' - - # Temporary trick to have the B1 map with proper header. - ret = script_runner.run('scil_mti_adjust_B1_header.py', in_b1_map, - out_b1_map, in_b1_json, '-f') - - ret = script_runner.run('scil_mti_maps_ihMT.py', tmp_dir.name, - '--mask', in_mask, - '--in_altnp', in_e1_altnp, in_e2_altnp, - in_e3_altnp, - '--in_altpn', in_e1_altpn, in_e2_altpn, - in_e3_altpn, - '--in_mtoff_pd', in_e1_mtoff_pd, in_e2_mtoff_pd, - in_e3_mtoff_pd, - '--in_negative', in_e1_neg, in_e2_neg, in_e3_neg, - '--in_positive', in_e1_pos, in_e2_pos, in_e3_pos, - '--in_B1_map', out_b1_map, - '--B1_correction_method', 'empiric', - '--in_jsons', in_mtoff_pd_json, - in_mtoff_t1_json, - '-f') - assert ret.success - - -def test_execution_ihMT_wrong_echoes(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - ret = script_runner.run('scil_mti_maps_ihMT.py', tmp_dir.name, - '--mask', in_mask, - '--in_altnp', in_e1_altnp, in_e2_altnp, - in_e3_altnp, - '--in_altpn', in_e1_altpn, in_e2_altpn, - in_e3_altpn, - '--in_mtoff_pd', in_e1_mtoff_pd, in_e2_mtoff_pd, - in_e3_mtoff_pd, - '--in_negative', in_e1_neg, in_e2_neg, in_e3_neg, - '--in_positive', in_e1_pos, in_e2_pos, in_e3_pos, - '--in_mtoff_t1', in_e1_mtoff_t1, in_e2_mtoff_t1, - '--in_jsons', in_mtoff_pd_json, - in_mtoff_t1_json, - '-f') - assert (not ret.success) - - -def test_execution_ihMT_B1_no_fit(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - out_b1_map = tmp_dir.name + '/B1map.nii.gz' - - # Temporary trick to have the B1 map with proper header. - ret = script_runner.run('scil_mti_adjust_B1_header.py', in_b1_map, - out_b1_map, in_b1_json, '-f') - - ret = script_runner.run('scil_mti_maps_ihMT.py', tmp_dir.name, - '--mask', in_mask, - '--in_altnp', in_e1_altnp, in_e2_altnp, - in_e3_altnp, - '--in_altpn', in_e1_altpn, in_e2_altpn, - in_e3_altpn, - '--in_mtoff_pd', in_e1_mtoff_pd, in_e2_mtoff_pd, - in_e3_mtoff_pd, - '--in_negative', in_e1_neg, in_e2_neg, in_e3_neg, - '--in_positive', in_e1_pos, in_e2_pos, in_e3_pos, - '--in_mtoff_t1', in_e1_mtoff_t1, in_e2_mtoff_t1, - in_e3_mtoff_t1, - '--out_prefix', 'sub-01', - '--in_B1_map', out_b1_map, - '--B1_correction_method', 'model_based', - '--in_jsons', in_mtoff_pd_json, - in_mtoff_t1_json, - '-f') - assert (not ret.success) - - -def test_execution_ihMT_single_echo(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - ret = script_runner.run('scil_mti_maps_ihMT.py', tmp_dir.name, - '--mask', in_mask, - '--in_altnp', in_e1_altnp, - '--in_altpn', in_e1_altpn, - '--in_mtoff_pd', in_e1_mtoff_pd, - '--in_negative', in_e1_neg, - '--in_positive', in_e1_pos, - '--in_mtoff_t1', in_e1_mtoff_t1, - '--out_prefix', 'sub_01', - '--in_jsons', in_mtoff_pd_json, - in_mtoff_t1_json, '-f') - assert ret.success - - -def test_execution_ihMT_acq_params(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - ret = script_runner.run('scil_mti_maps_ihMT.py', tmp_dir.name, - '--mask', in_mask, - '--in_altnp', in_e1_altnp, - '--in_altpn', in_e1_altpn, - '--in_mtoff_pd', in_e1_mtoff_pd, - '--in_negative', in_e1_neg, - '--in_positive', in_e1_pos, - '--in_mtoff_t1', in_e1_mtoff_t1, - '--out_prefix', 'sub_01', - '--in_acq_parameters', '15', '15', '0.1', '0.1', - '-f') - assert ret.success diff --git a/scripts/tests/test_surface_create.py b/scripts/tests/test_surface_create.py deleted file mode 100644 index fe15cb64f..000000000 --- a/scripts/tests/test_surface_create.py +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -import os -import tempfile - -from scilpy import SCILPY_HOME -from scilpy.io.fetcher import fetch_data, get_testing_files_dict - -# If they already exist, this only takes 5 seconds (check md5sum) -fetch_data(get_testing_files_dict(), keys=['atlas.zip']) -fetch_data(get_testing_files_dict(), keys=['others.zip']) -tmp_dir = tempfile.TemporaryDirectory() - - -def test_help_option(script_runner): - ret = script_runner.run('scil_surface_create.py', '--help') - assert ret.success - - -def test_execution_atlas(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - in_atlas = os.path.join(SCILPY_HOME, 'atlas', - 'atlas_freesurfer_v2.nii.gz') - ret = script_runner.run('scil_surface_create.py', - '--in_labels', in_atlas, - 'surface.vtk', - '--list_indices', '2024:2035 1024', - '--fill', - '--smooth', '1', - '--erosion', '1', - '--dilation', '1', - '--opening', '1', - '--closing', '1', '-f') - assert ret.success - - -def test_execution_atlas_each_index(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - in_atlas = os.path.join(SCILPY_HOME, 'atlas', - 'atlas_freesurfer_v2.nii.gz') - ret = script_runner.run('scil_surface_create.py', - '--in_labels', in_atlas, - 'surface.vtk', - '--each_index', - '--fill', - '--smooth', '1', - '--erosion', '1', - '--dilation', '1', - '--opening', '1', - '--closing', '1', - '--vtk2vox', '-f') - assert ret.success - - -def test_execution_atlas_no_index(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - in_atlas = os.path.join(SCILPY_HOME, 'atlas', - 'atlas_freesurfer_v2.nii.gz') - ret = script_runner.run('scil_surface_create.py', - '--in_labels', in_atlas, - 'surface.vtk', - '--fill', - '--smooth', '1', - '--erosion', '1', - '--dilation', '1', - '--opening', '1', - '--closing', '1', '-f') - assert ret.success - - -def test_execution_mask(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - in_mask = os.path.join(SCILPY_HOME, 'atlas', - 'brainstem_bin.nii.gz') - ret = script_runner.run('scil_surface_create.py', - '--in_mask', in_mask, - 'surface.vtk', '-f') - assert ret.success - - -def test_execution_volume(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - in_t1 = os.path.join(SCILPY_HOME, 'others', - 't1.nii.gz') - ret = script_runner.run('scil_surface_create.py', - '--in_volume', in_t1, - '--value', '0.2', - 'surface.vtk', '-f') - assert ret.success diff --git a/scripts/tests/test_tractogram_filter_by_anatomy.py b/scripts/tests/test_tractogram_filter_by_anatomy.py deleted file mode 100644 index 2b8e04d8c..000000000 --- a/scripts/tests/test_tractogram_filter_by_anatomy.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -import os -import tempfile - -from scilpy import SCILPY_HOME -from scilpy.io.fetcher import fetch_data, get_testing_files_dict - -# If they already exist, this only takes 5 seconds (check md5sum) -fetch_data(get_testing_files_dict(), keys=['anatomical_filtering.zip']) -tmp_dir = tempfile.TemporaryDirectory() - - -def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_filter_by_anatomy.py', - '--help') - assert ret.success - - -def test_execution_filtering_all_options(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - in_tractogram = os.path.join(SCILPY_HOME, 'anatomical_filtering', - 'tractogram_filter_ana.trk') - in_wmparc = os.path.join(SCILPY_HOME, 'anatomical_filtering', - 'wmparc_filter_ana.nii.gz') - ret = script_runner.run('scil_tractogram_filter_by_anatomy.py', - in_tractogram, in_wmparc, - os.path.expanduser(tmp_dir.name), - '--minL', '40', '--maxL', '200', '--angle', '300', - '--processes', '1', '--save_volumes', - '--dilate_ctx', '2', - '--save_intermediate_tractograms', - '--save_counts', - '--save_rejected', - '-f') - assert ret.success - - -def test_execution_filtering_rejected(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - in_tractogram = os.path.join(SCILPY_HOME, 'anatomical_filtering', - 'tractogram_filter_ana.trk') - in_wmparc = os.path.join(SCILPY_HOME, 'anatomical_filtering', - 'wmparc_filter_ana.nii.gz') - ret = script_runner.run('scil_tractogram_filter_by_anatomy.py', - in_tractogram, in_wmparc, - os.path.expanduser(tmp_dir.name), - '--minL', '40', '--maxL', '200', '--angle', '300', - '--processes', '1', '--save_volumes', - '--dilate_ctx', '2', - '--save_counts', - '--save_rejected', - '-f') - assert ret.success - - -def test_execution_filtering_save_intermediate(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - in_tractogram = os.path.join(SCILPY_HOME, 'anatomical_filtering', - 'tractogram_filter_ana.trk') - in_wmparc = os.path.join(SCILPY_HOME, 'anatomical_filtering', - 'wmparc_filter_ana.nii.gz') - ret = script_runner.run('scil_tractogram_filter_by_anatomy.py', - in_tractogram, in_wmparc, - os.path.expanduser(tmp_dir.name), - '--minL', '40', '--maxL', '200', '--angle', '300', - '--processes', '1', '--save_volumes', - '--dilate_ctx', '2', - '--save_intermediate_tractograms', - '-f') - assert ret.success diff --git a/scripts/tests/test_tractogram_filter_by_roi.py b/scripts/tests/test_tractogram_filter_by_roi.py deleted file mode 100644 index 52470a943..000000000 --- a/scripts/tests/test_tractogram_filter_by_roi.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -import os -import tempfile - -from scilpy import SCILPY_HOME -from scilpy.io.fetcher import fetch_data, get_testing_files_dict - -# If they already exist, this only takes 5 seconds (check md5sum) -fetch_data(get_testing_files_dict(), keys=['filtering.zip']) -tmp_dir = tempfile.TemporaryDirectory() - -# toDo. Add an atlas and test option --atlas_roi -in_tractogram = os.path.join(SCILPY_HOME, 'filtering', - 'bundle_all_1mm_inliers.trk') -in_roi = os.path.join(SCILPY_HOME, 'filtering', 'mask.nii.gz') -in_bdo = os.path.join(SCILPY_HOME, 'filtering', 'sc.bdo') - - -def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_filter_by_roi.py', '--help') - assert ret.success - - -def test_execution_filtering(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - ret = script_runner.run('scil_tractogram_filter_by_roi.py', in_tractogram, - 'bundle_1.trk', '--display_counts', - '--drawn_roi', in_roi, 'any', 'include', - '--bdo', in_bdo, 'any', 'include', - '--x_plane', '0', 'either_end', 'exclude', - '--y_plane', '0', 'all', 'exclude', '0', - '--z_plane', '0', 'either_end', 'exclude', '1', - '--save_rejected', 'bundle_1_rejected.trk') - assert ret.success - - -def test_execution_filtering_overwrite_distance(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - ret = script_runner.run('scil_tractogram_filter_by_roi.py', in_tractogram, - 'bundle_2.trk', '--display_counts', - '--drawn_roi', in_roi, 'any', 'include', '2', - '--overwrite_distance', 'any', 'include', '4') - assert ret.success - - -def test_execution_filtering_list(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - # Write a list of options - filelist = 'my_filelist.txt' - with open(filelist, 'w') as f: - f.write('drawn_roi {} any include\n'.format(in_roi)) - f.write('bdo {} "any" "include"\n'.format(in_bdo)) - f.write("bdo {} 'any' include".format(in_bdo)) - - ret = script_runner.run('scil_tractogram_filter_by_roi.py', in_tractogram, - 'bundle_3.trk', '--display_counts', - '--filtering_list', filelist) - assert ret.success diff --git a/scripts/tests/test_tractogram_project_map_to_streamlines.py b/scripts/tests/test_tractogram_project_map_to_streamlines.py deleted file mode 100644 index 2567601e1..000000000 --- a/scripts/tests/test_tractogram_project_map_to_streamlines.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -import os -import tempfile - -from scilpy import SCILPY_HOME -from scilpy.io.fetcher import fetch_data, get_testing_files_dict - -# If they already exist, this only takes 5 seconds (check md5sum) -fetch_data(get_testing_files_dict(), keys=['others.zip']) -tmp_dir = tempfile.TemporaryDirectory() - -in_tracto_1 = os.path.join(SCILPY_HOME, 'tracking', 'local_split_0.trk') -in_3d_map = os.path.join(SCILPY_HOME, 'tracking', 'fa.nii.gz') -in_4d_map = os.path.join(SCILPY_HOME, 'tracking', 'peaks.nii.gz') - - -def test_help_option(script_runner): - ret = script_runner.run( - 'scil_tractogram_project_map_to_streamlines.py', '--help') - assert ret.success - - -def test_execution_3D_map(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - ret = script_runner.run('scil_tractogram_project_map_to_streamlines.py', - in_tracto_1, 't1_on_streamlines.trk', - '--in_maps', in_3d_map, - '--out_dpp_name', 't1') - assert ret.success - - -def test_execution_4D_map(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - ret = script_runner.run('scil_tractogram_project_map_to_streamlines.py', - in_tracto_1, 'rgb_on_streamlines.trk', - '--in_maps', in_4d_map, - '--out_dpp_name', 'rgb') - assert ret.success - - -def test_execution_3D_map_endpoints_only(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - ret = script_runner.run('scil_tractogram_project_map_to_streamlines.py', - in_tracto_1, - 't1_on_streamlines_endpoints.trk', - '--in_maps', in_3d_map, - '--out_dpp_name', 't1', - '--endpoints_only') - assert ret.success - - -def test_execution_4D_map_endpoints_only(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - ret = script_runner.run('scil_tractogram_project_map_to_streamlines.py', - in_tracto_1, - 'rgb_on_streamlines_endpoints.trk', - '--in_maps', in_4d_map, - '--out_dpp_name', 'rgb', - '--endpoints_only') - assert ret.success - - -def test_execution_3D_map_trilinear(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - ret = script_runner.run('scil_tractogram_project_map_to_streamlines.py', - in_tracto_1, - 't1_on_streamlines_trilinear.trk', - '--in_maps', in_3d_map, - '--out_dpp_name', 't1', - '--trilinear') - assert ret.success diff --git a/scripts/tests/test_tractogram_project_streamlines_to_map.py b/scripts/tests/test_tractogram_project_streamlines_to_map.py deleted file mode 100644 index bd2aded71..000000000 --- a/scripts/tests/test_tractogram_project_streamlines_to_map.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -import os -import tempfile - -from scilpy import SCILPY_HOME -from scilpy.io.fetcher import fetch_data, get_testing_files_dict - -# If they already exist, this only takes 5 seconds (check md5sum) -fetch_data(get_testing_files_dict(), keys=['tractometry.zip']) -tmp_dir = tempfile.TemporaryDirectory() - -# toDo. For more coverage, save some DPS and DPP in a text file, and test -# options --load_dpp, --load_dps. - - -def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_project_streamlines_to_map.py', - '--help') - assert ret.success - - -def test_execution_dpp(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - in_bundle = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM_uni.trk') - in_mni = os.path.join(SCILPY_HOME, 'tractometry', 'mni_masked.nii.gz') - in_bundle_with_dpp = 'IFGWM_uni_with_dpp.trk' - - # Create our test data with dpp: add metrics as dpp. - # Or get a tractogram that already as some dpp in the test data. - script_runner.run('scil_tractogram_project_map_to_streamlines.py', - in_bundle, in_bundle_with_dpp, '-f', - '--in_maps', in_mni, '--out_dpp_name', 'some_metric') - - # Tests with dpp. - ret = script_runner.run('scil_tractogram_project_streamlines_to_map.py', - in_bundle_with_dpp, 'project_dpp_', - '--use_dpp', 'some_metric', '--point_by_point', - '--to_endpoints') - assert ret.success - - ret = script_runner.run('scil_tractogram_project_streamlines_to_map.py', - in_bundle_with_dpp, 'project_mean_to_endpoints_', - '--use_dpp', 'some_metric', '--mean_streamline', - '--to_endpoints') - assert ret.success - - ret = script_runner.run('scil_tractogram_project_streamlines_to_map.py', - in_bundle_with_dpp, 'project_end_to_wm', - '--use_dpp', 'some_metric', '--mean_endpoints', - '--to_wm') - assert ret.success - - -def test_execution_dps(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - in_bundle = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM_uni.trk') - in_mni = os.path.join(SCILPY_HOME, 'tractometry', 'mni_masked.nii.gz') - in_bundle_with_dpp = 'IFGWM_uni_with_dpp.trk' - in_bundle_with_dps = 'IFGWM_uni_with_dps.trk' - - # Create our test data with dps: add metrics as dps. - # Or get a tractogram that already as some dps in the test data. - script_runner.run('scil_tractogram_project_map_to_streamlines.py', - in_bundle, in_bundle_with_dpp, '-f', - '--in_maps', in_mni, '--out_dpp_name', 'some_metric') - script_runner.run('scil_tractogram_dpp_math.py', 'min', in_bundle_with_dpp, - in_bundle_with_dps, '--in_dpp_name', 'some_metric', - '--out_keys', 'some_metric_dps', '--mode', 'dps', - '--keep_all') - - # Tests with dps. - ret = script_runner.run('scil_tractogram_project_streamlines_to_map.py', - in_bundle_with_dps, 'project_dps_', - '--use_dps', 'some_metric_dps', '--point_by_point', - '--to_wm') - assert ret.success diff --git a/scripts/tests/test_viz_bingham_fit.py b/scripts/tests/test_viz_bingham_fit.py deleted file mode 100644 index 8b14b4cae..000000000 --- a/scripts/tests/test_viz_bingham_fit.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -import os -import tempfile - -from scilpy import SCILPY_HOME -from scilpy.io.fetcher import fetch_data, get_testing_files_dict - -fetch_data(get_testing_files_dict(), keys=['tracking.zip']) -tmp_dir = tempfile.TemporaryDirectory() - - -def test_help_option(script_runner): - ret = script_runner.run('scil_viz_bingham_fit.py', '--help') - assert ret.success - - -def test_silent_without_output(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - - # dummy dataset (the script should raise an error before using it) - in_dummy = os.path.join(SCILPY_HOME, 'tracking', 'fodf.nii.gz') - - ret = script_runner.run('scil_viz_bingham_fit.py', in_dummy, - '--silent') - - assert (not ret.success) diff --git a/scripts/tests/test_viz_bundle_screenshot_mni.py b/scripts/tests/test_viz_bundle_screenshot_mni.py deleted file mode 100644 index 397d593ed..000000000 --- a/scripts/tests/test_viz_bundle_screenshot_mni.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - - -def test_help_option(script_runner): - ret = script_runner.run('scil_viz_bundle_screenshot_mni.py', '--help') - assert ret.success diff --git a/scripts/tests/test_viz_bundle_screenshot_mosaic.py b/scripts/tests/test_viz_bundle_screenshot_mosaic.py deleted file mode 100644 index 26509532a..000000000 --- a/scripts/tests/test_viz_bundle_screenshot_mosaic.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - - -def test_help_option(script_runner): - ret = script_runner.run('scil_viz_bundle_screenshot_mosaic.py', '--help') - assert ret.success diff --git a/scripts/tests/test_viz_fodf.py b/scripts/tests/test_viz_fodf.py deleted file mode 100644 index c033143f3..000000000 --- a/scripts/tests/test_viz_fodf.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -import os -import tempfile - -from scilpy import SCILPY_HOME -from scilpy.io.fetcher import fetch_data, get_testing_files_dict - -fetch_data(get_testing_files_dict(), keys=['tracking.zip']) -tmp_dir = tempfile.TemporaryDirectory() - - -def test_help_option(script_runner): - ret = script_runner.run('scil_viz_fodf.py', '--help') - assert ret.success - - -def test_silent_without_output(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - in_fodf = os.path.join(SCILPY_HOME, 'tracking', 'fodf.nii.gz') - - ret = script_runner.run('scil_viz_fodf.py', in_fodf, '--silent') - - # Should say that requires an output with --silent mode - assert (not ret.success) - - -def test_run(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - in_fodf = os.path.join(SCILPY_HOME, 'tracking', 'fodf.nii.gz') - in_mask = os.path.join(SCILPY_HOME, 'tracking', 'seeding_mask.nii.gz') - out_name = os.path.join(tmp_dir.name, 'out.png') - ret = script_runner.run('scil_viz_fodf.py', in_fodf, '--silent', - '--in_transparency_mask', in_mask, - '--output', out_name) - - assert ret.success diff --git a/scripts/tests/test_viz_gradients_screenshot.py b/scripts/tests/test_viz_gradients_screenshot.py deleted file mode 100644 index 3d4886c47..000000000 --- a/scripts/tests/test_viz_gradients_screenshot.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - - -def test_help_option(script_runner): - ret = script_runner.run('scil_viz_gradients_screenshot.py', '--help') - assert ret.success diff --git a/scripts/tests/test_viz_tractogram_collisions.py b/scripts/tests/test_viz_tractogram_collisions.py deleted file mode 100644 index 2d8819039..000000000 --- a/scripts/tests/test_viz_tractogram_collisions.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - - -def test_help_option(script_runner): - ret = script_runner.run('scil_viz_tractogram_collisions.py', '--help') - assert ret.success diff --git a/scripts/tests/test_viz_tractogram_seeds_3d.py b/scripts/tests/test_viz_tractogram_seeds_3d.py deleted file mode 100644 index 688743270..000000000 --- a/scripts/tests/test_viz_tractogram_seeds_3d.py +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -def test_help_option(script_runner): - ret = script_runner.run('scil_viz_tractogram_seeds_3d.py', '--help') - assert ret.success diff --git a/scripts/tests/test_viz_volume_screenshot_mosaic.py b/scripts/tests/test_viz_volume_screenshot_mosaic.py deleted file mode 100644 index bd42089af..000000000 --- a/scripts/tests/test_viz_volume_screenshot_mosaic.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - - -def test_help_option(script_runner): - ret = script_runner.run("scil_viz_volume_screenshot_mosaic.py", "--help") - assert ret.success diff --git a/setup.py b/setup.py index bed21c838..acd3dd7e2 100644 --- a/setup.py +++ b/setup.py @@ -1,103 +1,29 @@ -import os - -from setuptools import setup, find_packages, Extension -from setuptools.command.build_ext import build_ext - -with open('requirements.txt') as f: - required_dependencies = f.read().splitlines() - external_dependencies = [] - for dependency in required_dependencies: - if dependency[0:2] == '-e': - repo_name = dependency.split('=')[-1] - repo_url = dependency[3:] - external_dependencies.append('{} @ {}'.format(repo_name, repo_url)) - else: - external_dependencies.append(dependency) - - -def get_extensions(): - define_macros = [('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')] - uncompress = Extension('scilpy.tractograms.uncompress', - ['scilpy/tractograms/uncompress.pyx'], - define_macros=define_macros) - voxel_boundary_intersection =\ - Extension('scilpy.tractanalysis.voxel_boundary_intersection', - ['scilpy/tractanalysis/voxel_boundary_intersection.pyx'], - define_macros=define_macros) - streamlines_metrics =\ - Extension('scilpy.tractanalysis.streamlines_metrics', - ['scilpy/tractanalysis/streamlines_metrics.pyx'], - define_macros=define_macros) - return [uncompress, voxel_boundary_intersection, streamlines_metrics] - - -class CustomBuildExtCommand(build_ext): - """ build_ext command to use when numpy headers are needed. """ - - def run(self): - # Now that the requirements are installed, get everything from numpy - from Cython.Build import cythonize - from numpy import get_include - - # Add everything requires for build - self.swig_opts = None - self.include_dirs = [get_include()] - self.distribution.ext_modules[:] = cythonize( - self.distribution.ext_modules) - - # Call original build_ext command - build_ext.finalize_options(self) - build_ext.run(self) - - -# Get the requiered python version -PYTHON_VERSION = "" -with open('.python-version') as f: - f.readline() - PYTHON_VERSION = f.readline().strip("\n") - -# Get version and release info, which is all stored in scilpy/version.py -ver_file = os.path.join('scilpy', 'version.py') -with open(ver_file) as f: - exec(f.read()) - -entry_point_legacy = [] -if os.getenv('SCILPY_LEGACY') != 'False': - entry_point_legacy = ["{}=scripts.legacy.{}:main".format( - os.path.basename(s), - os.path.basename(s).split(".")[0]) for s in LEGACY_SCRIPTS] - -opts = dict(name=NAME, - maintainer=MAINTAINER, - maintainer_email=MAINTAINER_EMAIL, - description=DESCRIPTION, - long_description=LONG_DESCRIPTION, - url=URL, - download_url=DOWNLOAD_URL, - license=LICENSE, - classifiers=CLASSIFIERS, - author=AUTHOR, - author_email=AUTHOR_EMAIL, - platforms=PLATFORMS, - version=VERSION, - packages=find_packages(), - cmdclass={ - 'build_ext': CustomBuildExtCommand - }, - ext_modules=get_extensions(), - python_requires=PYTHON_VERSION, - setup_requires=[], # replaced by PEP518 (pyproject.toml) - install_requires=external_dependencies, - entry_points={ - 'console_scripts': ["{}=scripts.{}:main".format( - os.path.basename(s), - os.path.basename(s).split(".")[0]) for s in SCRIPTS] + - entry_point_legacy - }, - data_files=[('data/LUT', - ["data/LUT/freesurfer_desikan_killiany.json", - "data/LUT/freesurfer_subcortical.json", - "data/LUT/dk_aggregate_structures.json"])], - include_package_data=True) - -setup(**opts) +from Cython.Build import cythonize +import numpy +from setuptools import setup, Extension + + +define_macros = [('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')] +# Modules to be compiled and include_dirs when necessary +extensions = [ + Extension('scilpy.tractograms.uncompress', + ['src/scilpy/tractograms/uncompress.pyx'], + define_macros=define_macros), + Extension('scilpy.tractanalysis.voxel_boundary_intersection', + ['src/scilpy/tractanalysis/voxel_boundary_intersection.pyx'], + define_macros=define_macros), + Extension('scilpy.tractanalysis.streamlines_metrics', + ['src/scilpy/tractanalysis/streamlines_metrics.pyx'], + define_macros=define_macros)] + +# This is the function that is executed +setup( + name='scilpy', + + # A list of compiler Directives is available at + # https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html#compiler-directives + + # external to be compiled + ext_modules=cythonize(extensions), + include_dirs=[numpy.get_include()] +) diff --git a/scilpy/__init__.py b/src/scilpy/__init__.py similarity index 95% rename from scilpy/__init__.py rename to src/scilpy/__init__.py index fb666eb4d..de573386d 100644 --- a/scilpy/__init__.py +++ b/src/scilpy/__init__.py @@ -12,7 +12,7 @@ def get_home(): def get_root(): import os - return os.path.realpath(f"{os.path.dirname(os.path.abspath(__file__))}/..") + return os.path.realpath(f"{os.path.dirname(os.path.abspath(__file__))}/../..") SCILPY_HOME = get_home() diff --git a/scilpy/connectivity/__init__.py b/src/scilpy/cli/__init__.py similarity index 100% rename from scilpy/connectivity/__init__.py rename to src/scilpy/cli/__init__.py diff --git a/scripts/scil_NODDI_maps.py b/src/scilpy/cli/scil_NODDI_maps.py similarity index 100% rename from scripts/scil_NODDI_maps.py rename to src/scilpy/cli/scil_NODDI_maps.py diff --git a/scripts/scil_NODDI_priors.py b/src/scilpy/cli/scil_NODDI_priors.py similarity index 100% rename from scripts/scil_NODDI_priors.py rename to src/scilpy/cli/scil_NODDI_priors.py diff --git a/scripts/scil_aodf_metrics.py b/src/scilpy/cli/scil_aodf_metrics.py similarity index 100% rename from scripts/scil_aodf_metrics.py rename to src/scilpy/cli/scil_aodf_metrics.py diff --git a/scripts/scil_bids_validate.py b/src/scilpy/cli/scil_bids_validate.py similarity index 100% rename from scripts/scil_bids_validate.py rename to src/scilpy/cli/scil_bids_validate.py diff --git a/scripts/scil_bingham_metrics.py b/src/scilpy/cli/scil_bingham_metrics.py similarity index 100% rename from scripts/scil_bingham_metrics.py rename to src/scilpy/cli/scil_bingham_metrics.py diff --git a/scripts/scil_btensor_metrics.py b/src/scilpy/cli/scil_btensor_metrics.py similarity index 100% rename from scripts/scil_btensor_metrics.py rename to src/scilpy/cli/scil_btensor_metrics.py diff --git a/scripts/scil_bundle_alter_to_target_dice.py b/src/scilpy/cli/scil_bundle_alter_to_target_dice.py similarity index 100% rename from scripts/scil_bundle_alter_to_target_dice.py rename to src/scilpy/cli/scil_bundle_alter_to_target_dice.py diff --git a/scripts/scil_bundle_clean_qbx_clusters.py b/src/scilpy/cli/scil_bundle_clean_qbx_clusters.py similarity index 100% rename from scripts/scil_bundle_clean_qbx_clusters.py rename to src/scilpy/cli/scil_bundle_clean_qbx_clusters.py diff --git a/scripts/scil_bundle_compute_centroid.py b/src/scilpy/cli/scil_bundle_compute_centroid.py similarity index 100% rename from scripts/scil_bundle_compute_centroid.py rename to src/scilpy/cli/scil_bundle_compute_centroid.py diff --git a/scripts/scil_bundle_compute_endpoints_map.py b/src/scilpy/cli/scil_bundle_compute_endpoints_map.py similarity index 100% rename from scripts/scil_bundle_compute_endpoints_map.py rename to src/scilpy/cli/scil_bundle_compute_endpoints_map.py diff --git a/scripts/scil_bundle_diameter.py b/src/scilpy/cli/scil_bundle_diameter.py similarity index 97% rename from scripts/scil_bundle_diameter.py rename to src/scilpy/cli/scil_bundle_diameter.py index 0df1afe38..6a59d1d85 100755 --- a/scripts/scil_bundle_diameter.py +++ b/src/scilpy/cli/scil_bundle_diameter.py @@ -74,7 +74,10 @@ def _build_arg_parser(): p2 = p.add_argument_group(title='Visualization options') p3 = p2.add_mutually_exclusive_group() p3.add_argument('--show_rendering', action='store_true', - help='Display VTK window (optional).') + help='Display VTK window (optional).\n' + '(Note. This option is not verified by tests. If ' + 'you encounter any bug, \nplease report it to our ' + 'team.)') p3.add_argument('--save_rendering', metavar='OUT_FOLDER', help='Save VTK render in the specified folder (optional)') p2.add_argument('--wireframe', action='store_true', @@ -266,7 +269,7 @@ def main(): labels_dict = {label: ([], []) for label in unique_labels} pts_labels = map_coordinates(data_labels, sft.streamlines._data.T-0.5, - order=0) + order=0, mode='nearest') # For each label, all positions and directions are needed to get # a tube estimation per label. for streamline in sft.streamlines: diff --git a/scripts/scil_bundle_explore_bundleseg.py b/src/scilpy/cli/scil_bundle_explore_bundleseg.py similarity index 100% rename from scripts/scil_bundle_explore_bundleseg.py rename to src/scilpy/cli/scil_bundle_explore_bundleseg.py diff --git a/scripts/scil_bundle_filter_by_occurence.py b/src/scilpy/cli/scil_bundle_filter_by_occurence.py similarity index 100% rename from scripts/scil_bundle_filter_by_occurence.py rename to src/scilpy/cli/scil_bundle_filter_by_occurence.py diff --git a/scripts/scil_bundle_fixel_analysis.py b/src/scilpy/cli/scil_bundle_fixel_analysis.py similarity index 100% rename from scripts/scil_bundle_fixel_analysis.py rename to src/scilpy/cli/scil_bundle_fixel_analysis.py diff --git a/scripts/scil_bundle_generate_priors.py b/src/scilpy/cli/scil_bundle_generate_priors.py similarity index 100% rename from scripts/scil_bundle_generate_priors.py rename to src/scilpy/cli/scil_bundle_generate_priors.py diff --git a/scripts/scil_bundle_label_map.py b/src/scilpy/cli/scil_bundle_label_map.py similarity index 95% rename from scripts/scil_bundle_label_map.py rename to src/scilpy/cli/scil_bundle_label_map.py index ce5aefd28..3f5a97d6a 100755 --- a/scripts/scil_bundle_label_map.py +++ b/src/scilpy/cli/scil_bundle_label_map.py @@ -81,7 +81,8 @@ add_verbose_arg, assert_inputs_exist, assert_output_dirs_exist_and_empty, - load_matrix_in_any_format) + load_matrix_in_any_format, + ranged_type) from scilpy.tractanalysis.bundle_operations import uniformize_bundle_sft from scilpy.tractanalysis.streamlines_metrics import compute_tract_counts_map from scilpy.tractanalysis.distance_to_centroid import (subdivide_bundles, @@ -89,7 +90,7 @@ from scilpy.tractograms.streamline_and_mask_operations import \ cut_streamlines_with_mask, CuttingStyle from scilpy.tractograms.streamline_operations import \ - filter_streamlines_by_nb_points + filter_streamlines_by_nb_points, remove_overlapping_points_streamlines from scilpy.viz.color import get_lookup_table from scilpy.version import version_string @@ -117,6 +118,10 @@ def _build_arg_parser(): p.add_argument('--nb_pts', type=int, help='Number of divisions for the bundles.\n' 'Default is the number of points of the centroid.') + p.add_argument('--threshold', type=ranged_type(float, 0, None), + default=0.001, + help='Maximum distance between two points to be considered ' + 'overlapping [%(default)s mm].') p.add_argument('--colormap', default='jet', help='Select the colormap for colored trk (data_per_point) ' '[%(default)s].') @@ -325,6 +330,11 @@ def main(): cut_sft = cut_streamlines_with_mask( new_sft, binary_mask, cutting_style=CuttingStyle.KEEP_LONGEST) + + cut_sft = remove_overlapping_points_streamlines(cut_sft, + args.threshold) + cut_sft = filter_streamlines_by_nb_points(cut_sft, min_nb_points=2) + logging.debug( f'Cut streamlines in {round(time.time() - timer, 3)} seconds') cut_sft.data_per_point['color'] = ArraySequence(cut_sft.streamlines) @@ -347,7 +357,8 @@ def main(): if len(cut_sft): tmp_data = ndi.map_coordinates( - map, cut_sft.streamlines._data.T - 0.5, order=0) + map, cut_sft.streamlines._data.T - 0.5, order=0, + mode='nearest') if basename == 'labels': max_val = args.nb_pts diff --git a/scripts/scil_bundle_mean_fixel_afd.py b/src/scilpy/cli/scil_bundle_mean_fixel_afd.py similarity index 100% rename from scripts/scil_bundle_mean_fixel_afd.py rename to src/scilpy/cli/scil_bundle_mean_fixel_afd.py diff --git a/scripts/scil_bundle_mean_fixel_afd_from_hdf5.py b/src/scilpy/cli/scil_bundle_mean_fixel_afd_from_hdf5.py similarity index 100% rename from scripts/scil_bundle_mean_fixel_afd_from_hdf5.py rename to src/scilpy/cli/scil_bundle_mean_fixel_afd_from_hdf5.py diff --git a/scripts/scil_bundle_mean_fixel_bingham_metric.py b/src/scilpy/cli/scil_bundle_mean_fixel_bingham_metric.py similarity index 100% rename from scripts/scil_bundle_mean_fixel_bingham_metric.py rename to src/scilpy/cli/scil_bundle_mean_fixel_bingham_metric.py diff --git a/scripts/scil_bundle_mean_fixel_mrds_metric.py b/src/scilpy/cli/scil_bundle_mean_fixel_mrds_metric.py similarity index 100% rename from scripts/scil_bundle_mean_fixel_mrds_metric.py rename to src/scilpy/cli/scil_bundle_mean_fixel_mrds_metric.py diff --git a/scripts/scil_bundle_mean_std.py b/src/scilpy/cli/scil_bundle_mean_std.py similarity index 100% rename from scripts/scil_bundle_mean_std.py rename to src/scilpy/cli/scil_bundle_mean_std.py diff --git a/scripts/scil_bundle_pairwise_comparison.py b/src/scilpy/cli/scil_bundle_pairwise_comparison.py similarity index 100% rename from scripts/scil_bundle_pairwise_comparison.py rename to src/scilpy/cli/scil_bundle_pairwise_comparison.py diff --git a/scripts/scil_bundle_reject_outliers.py b/src/scilpy/cli/scil_bundle_reject_outliers.py similarity index 100% rename from scripts/scil_bundle_reject_outliers.py rename to src/scilpy/cli/scil_bundle_reject_outliers.py diff --git a/scripts/scil_bundle_score_many_bundles_one_tractogram.py b/src/scilpy/cli/scil_bundle_score_many_bundles_one_tractogram.py similarity index 100% rename from scripts/scil_bundle_score_many_bundles_one_tractogram.py rename to src/scilpy/cli/scil_bundle_score_many_bundles_one_tractogram.py diff --git a/scripts/scil_bundle_score_same_bundle_many_segmentations.py b/src/scilpy/cli/scil_bundle_score_same_bundle_many_segmentations.py similarity index 100% rename from scripts/scil_bundle_score_same_bundle_many_segmentations.py rename to src/scilpy/cli/scil_bundle_score_same_bundle_many_segmentations.py diff --git a/scripts/scil_bundle_shape_measures.py b/src/scilpy/cli/scil_bundle_shape_measures.py similarity index 100% rename from scripts/scil_bundle_shape_measures.py rename to src/scilpy/cli/scil_bundle_shape_measures.py diff --git a/scripts/scil_bundle_uniformize_endpoints.py b/src/scilpy/cli/scil_bundle_uniformize_endpoints.py similarity index 100% rename from scripts/scil_bundle_uniformize_endpoints.py rename to src/scilpy/cli/scil_bundle_uniformize_endpoints.py diff --git a/scripts/scil_bundle_volume_per_label.py b/src/scilpy/cli/scil_bundle_volume_per_label.py similarity index 100% rename from scripts/scil_bundle_volume_per_label.py rename to src/scilpy/cli/scil_bundle_volume_per_label.py diff --git a/scripts/scil_connectivity_compare_populations.py b/src/scilpy/cli/scil_connectivity_compare_populations.py similarity index 100% rename from scripts/scil_connectivity_compare_populations.py rename to src/scilpy/cli/scil_connectivity_compare_populations.py diff --git a/scripts/scil_connectivity_compute_matrices.py b/src/scilpy/cli/scil_connectivity_compute_matrices.py similarity index 100% rename from scripts/scil_connectivity_compute_matrices.py rename to src/scilpy/cli/scil_connectivity_compute_matrices.py diff --git a/scripts/scil_connectivity_compute_pca.py b/src/scilpy/cli/scil_connectivity_compute_pca.py similarity index 100% rename from scripts/scil_connectivity_compute_pca.py rename to src/scilpy/cli/scil_connectivity_compute_pca.py diff --git a/scripts/scil_connectivity_compute_simple_matrix.py b/src/scilpy/cli/scil_connectivity_compute_simple_matrix.py similarity index 100% rename from scripts/scil_connectivity_compute_simple_matrix.py rename to src/scilpy/cli/scil_connectivity_compute_simple_matrix.py diff --git a/scripts/scil_connectivity_filter.py b/src/scilpy/cli/scil_connectivity_filter.py similarity index 100% rename from scripts/scil_connectivity_filter.py rename to src/scilpy/cli/scil_connectivity_filter.py diff --git a/scripts/scil_connectivity_graph_measures.py b/src/scilpy/cli/scil_connectivity_graph_measures.py similarity index 100% rename from scripts/scil_connectivity_graph_measures.py rename to src/scilpy/cli/scil_connectivity_graph_measures.py diff --git a/scripts/scil_connectivity_hdf5_average_density_map.py b/src/scilpy/cli/scil_connectivity_hdf5_average_density_map.py similarity index 100% rename from scripts/scil_connectivity_hdf5_average_density_map.py rename to src/scilpy/cli/scil_connectivity_hdf5_average_density_map.py diff --git a/scripts/scil_connectivity_math.py b/src/scilpy/cli/scil_connectivity_math.py similarity index 100% rename from scripts/scil_connectivity_math.py rename to src/scilpy/cli/scil_connectivity_math.py diff --git a/scripts/scil_connectivity_normalize.py b/src/scilpy/cli/scil_connectivity_normalize.py similarity index 100% rename from scripts/scil_connectivity_normalize.py rename to src/scilpy/cli/scil_connectivity_normalize.py diff --git a/scripts/scil_connectivity_pairwise_agreement.py b/src/scilpy/cli/scil_connectivity_pairwise_agreement.py similarity index 100% rename from scripts/scil_connectivity_pairwise_agreement.py rename to src/scilpy/cli/scil_connectivity_pairwise_agreement.py diff --git a/scripts/scil_connectivity_print_filenames.py b/src/scilpy/cli/scil_connectivity_print_filenames.py similarity index 100% rename from scripts/scil_connectivity_print_filenames.py rename to src/scilpy/cli/scil_connectivity_print_filenames.py diff --git a/scripts/scil_connectivity_reorder_rois.py b/src/scilpy/cli/scil_connectivity_reorder_rois.py similarity index 100% rename from scripts/scil_connectivity_reorder_rois.py rename to src/scilpy/cli/scil_connectivity_reorder_rois.py diff --git a/src/scilpy/cli/scil_data_download.py b/src/scilpy/cli/scil_data_download.py new file mode 100755 index 000000000..0a08f0a03 --- /dev/null +++ b/src/scilpy/cli/scil_data_download.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +""" +Download data for tests +""" +import tqdm + +import nltk + +from scilpy.io.dvc import pull_test_case_package +from scilpy.io.fetcher import fetch_data, get_testing_files_dict + +LIST_ZIP_FILES = ["anatomical_filtering", + "atlas", + "bids_json", + "bst", + "btensor_testdata", + "bundles", + "commit_amico", + "connectivity", + "filtering", + "ihMT", + "lesions", + "mrds", + "MT", + "others", + "plot", + "processing", + "stats", + "surface_vtk_fib", + "tracking", + "tractograms", + "tractometry"] + + +def main(): + + tqdm_bar = tqdm.tqdm(total=len(LIST_ZIP_FILES)+2, + desc="Download data test") + for zip_file in LIST_ZIP_FILES: + fetch_data(get_testing_files_dict(), + keys=[zip_file+'.zip'], verbose=False) + tqdm_bar.update(1) + + _ = pull_test_case_package("aodf") + tqdm_bar.update(1) + + nltk.download('punkt', quiet=True) + nltk.download('punkt_tab', quiet=True) + nltk.download('wordnet', quiet=True) + + +if __name__ == "__main__": + main() diff --git a/scripts/scil_denoising_nlmeans.py b/src/scilpy/cli/scil_denoising_nlmeans.py similarity index 100% rename from scripts/scil_denoising_nlmeans.py rename to src/scilpy/cli/scil_denoising_nlmeans.py diff --git a/scripts/scil_dki_metrics.py b/src/scilpy/cli/scil_dki_metrics.py similarity index 100% rename from scripts/scil_dki_metrics.py rename to src/scilpy/cli/scil_dki_metrics.py diff --git a/scripts/scil_dti_convert_tensors.py b/src/scilpy/cli/scil_dti_convert_tensors.py similarity index 100% rename from scripts/scil_dti_convert_tensors.py rename to src/scilpy/cli/scil_dti_convert_tensors.py diff --git a/scripts/scil_dti_metrics.py b/src/scilpy/cli/scil_dti_metrics.py similarity index 100% rename from scripts/scil_dti_metrics.py rename to src/scilpy/cli/scil_dti_metrics.py diff --git a/scripts/scil_dwi_apply_bias_field.py b/src/scilpy/cli/scil_dwi_apply_bias_field.py similarity index 100% rename from scripts/scil_dwi_apply_bias_field.py rename to src/scilpy/cli/scil_dwi_apply_bias_field.py diff --git a/scripts/scil_dwi_compute_snr.py b/src/scilpy/cli/scil_dwi_compute_snr.py similarity index 100% rename from scripts/scil_dwi_compute_snr.py rename to src/scilpy/cli/scil_dwi_compute_snr.py diff --git a/scripts/scil_dwi_concatenate.py b/src/scilpy/cli/scil_dwi_concatenate.py similarity index 100% rename from scripts/scil_dwi_concatenate.py rename to src/scilpy/cli/scil_dwi_concatenate.py diff --git a/scripts/scil_dwi_convert_FDF.py b/src/scilpy/cli/scil_dwi_convert_FDF.py similarity index 100% rename from scripts/scil_dwi_convert_FDF.py rename to src/scilpy/cli/scil_dwi_convert_FDF.py diff --git a/scripts/scil_dwi_detect_volume_outliers.py b/src/scilpy/cli/scil_dwi_detect_volume_outliers.py similarity index 100% rename from scripts/scil_dwi_detect_volume_outliers.py rename to src/scilpy/cli/scil_dwi_detect_volume_outliers.py diff --git a/scripts/scil_dwi_extract_b0.py b/src/scilpy/cli/scil_dwi_extract_b0.py similarity index 100% rename from scripts/scil_dwi_extract_b0.py rename to src/scilpy/cli/scil_dwi_extract_b0.py diff --git a/scripts/scil_dwi_extract_shell.py b/src/scilpy/cli/scil_dwi_extract_shell.py similarity index 100% rename from scripts/scil_dwi_extract_shell.py rename to src/scilpy/cli/scil_dwi_extract_shell.py diff --git a/scripts/scil_dwi_powder_average.py b/src/scilpy/cli/scil_dwi_powder_average.py similarity index 100% rename from scripts/scil_dwi_powder_average.py rename to src/scilpy/cli/scil_dwi_powder_average.py diff --git a/scripts/scil_dwi_prepare_eddy_command.py b/src/scilpy/cli/scil_dwi_prepare_eddy_command.py similarity index 100% rename from scripts/scil_dwi_prepare_eddy_command.py rename to src/scilpy/cli/scil_dwi_prepare_eddy_command.py diff --git a/scripts/scil_dwi_prepare_topup_command.py b/src/scilpy/cli/scil_dwi_prepare_topup_command.py similarity index 100% rename from scripts/scil_dwi_prepare_topup_command.py rename to src/scilpy/cli/scil_dwi_prepare_topup_command.py diff --git a/scripts/scil_dwi_reorder_philips.py b/src/scilpy/cli/scil_dwi_reorder_philips.py similarity index 100% rename from scripts/scil_dwi_reorder_philips.py rename to src/scilpy/cli/scil_dwi_reorder_philips.py diff --git a/scripts/scil_dwi_split_by_indices.py b/src/scilpy/cli/scil_dwi_split_by_indices.py similarity index 100% rename from scripts/scil_dwi_split_by_indices.py rename to src/scilpy/cli/scil_dwi_split_by_indices.py diff --git a/scripts/scil_dwi_to_sh.py b/src/scilpy/cli/scil_dwi_to_sh.py similarity index 100% rename from scripts/scil_dwi_to_sh.py rename to src/scilpy/cli/scil_dwi_to_sh.py diff --git a/scripts/scil_fibertube_compute_density.py b/src/scilpy/cli/scil_fibertube_compute_density.py similarity index 100% rename from scripts/scil_fibertube_compute_density.py rename to src/scilpy/cli/scil_fibertube_compute_density.py diff --git a/scripts/scil_fibertube_score_tractogram.py b/src/scilpy/cli/scil_fibertube_score_tractogram.py similarity index 100% rename from scripts/scil_fibertube_score_tractogram.py rename to src/scilpy/cli/scil_fibertube_score_tractogram.py diff --git a/scripts/scil_fibertube_tracking.py b/src/scilpy/cli/scil_fibertube_tracking.py similarity index 100% rename from scripts/scil_fibertube_tracking.py rename to src/scilpy/cli/scil_fibertube_tracking.py diff --git a/scripts/scil_fodf_bundleparc.py b/src/scilpy/cli/scil_fodf_bundleparc.py similarity index 100% rename from scripts/scil_fodf_bundleparc.py rename to src/scilpy/cli/scil_fodf_bundleparc.py diff --git a/scripts/scil_fodf_max_in_ventricles.py b/src/scilpy/cli/scil_fodf_max_in_ventricles.py similarity index 100% rename from scripts/scil_fodf_max_in_ventricles.py rename to src/scilpy/cli/scil_fodf_max_in_ventricles.py diff --git a/scripts/scil_fodf_memsmt.py b/src/scilpy/cli/scil_fodf_memsmt.py similarity index 100% rename from scripts/scil_fodf_memsmt.py rename to src/scilpy/cli/scil_fodf_memsmt.py diff --git a/scripts/scil_fodf_metrics.py b/src/scilpy/cli/scil_fodf_metrics.py similarity index 100% rename from scripts/scil_fodf_metrics.py rename to src/scilpy/cli/scil_fodf_metrics.py diff --git a/scripts/scil_fodf_msmt.py b/src/scilpy/cli/scil_fodf_msmt.py similarity index 100% rename from scripts/scil_fodf_msmt.py rename to src/scilpy/cli/scil_fodf_msmt.py diff --git a/scripts/scil_fodf_ssst.py b/src/scilpy/cli/scil_fodf_ssst.py similarity index 100% rename from scripts/scil_fodf_ssst.py rename to src/scilpy/cli/scil_fodf_ssst.py diff --git a/scripts/scil_fodf_to_bingham.py b/src/scilpy/cli/scil_fodf_to_bingham.py similarity index 98% rename from scripts/scil_fodf_to_bingham.py rename to src/scilpy/cli/scil_fodf_to_bingham.py index 025b8e158..0b30935a2 100755 --- a/scripts/scil_fodf_to_bingham.py +++ b/src/scilpy/cli/scil_fodf_to_bingham.py @@ -37,7 +37,7 @@ assert_outputs_exist, validate_nbr_processes, assert_headers_compatible) from scilpy.io.image import get_data_as_mask -from scilpy.reconst.bingham import (bingham_fit_sh) +from scilpy.reconst.bingham import bingham_fit_sh from scilpy.version import version_string diff --git a/scripts/scil_freewater_maps.py b/src/scilpy/cli/scil_freewater_maps.py similarity index 100% rename from scripts/scil_freewater_maps.py rename to src/scilpy/cli/scil_freewater_maps.py diff --git a/scripts/scil_freewater_priors.py b/src/scilpy/cli/scil_freewater_priors.py similarity index 71% rename from scripts/scil_freewater_priors.py rename to src/scilpy/cli/scil_freewater_priors.py index d0ae218ca..884795220 100755 --- a/scripts/scil_freewater_priors.py +++ b/src/scilpy/cli/scil_freewater_priors.py @@ -5,7 +5,7 @@ Synonym for scil_NODDI_priors.py """ -from scripts.scil_NODDI_priors import main as noddi_priors_main +from scilpy.cli.scil_NODDI_priors import main as noddi_priors_main def main(): diff --git a/scripts/scil_frf_mean.py b/src/scilpy/cli/scil_frf_mean.py similarity index 100% rename from scripts/scil_frf_mean.py rename to src/scilpy/cli/scil_frf_mean.py diff --git a/scripts/scil_frf_memsmt.py b/src/scilpy/cli/scil_frf_memsmt.py similarity index 100% rename from scripts/scil_frf_memsmt.py rename to src/scilpy/cli/scil_frf_memsmt.py diff --git a/scripts/scil_frf_msmt.py b/src/scilpy/cli/scil_frf_msmt.py similarity index 100% rename from scripts/scil_frf_msmt.py rename to src/scilpy/cli/scil_frf_msmt.py diff --git a/scripts/scil_frf_set_diffusivities.py b/src/scilpy/cli/scil_frf_set_diffusivities.py similarity index 100% rename from scripts/scil_frf_set_diffusivities.py rename to src/scilpy/cli/scil_frf_set_diffusivities.py diff --git a/scripts/scil_frf_ssst.py b/src/scilpy/cli/scil_frf_ssst.py similarity index 100% rename from scripts/scil_frf_ssst.py rename to src/scilpy/cli/scil_frf_ssst.py diff --git a/scripts/scil_get_version.py b/src/scilpy/cli/scil_get_version.py similarity index 80% rename from scripts/scil_get_version.py rename to src/scilpy/cli/scil_get_version.py index 046ab1e19..b6067ac26 100755 --- a/scripts/scil_get_version.py +++ b/src/scilpy/cli/scil_get_version.py @@ -14,12 +14,13 @@ import datetime import git import pathlib -import pkg_resources +from importlib.metadata import distributions import platform import os import time from scilpy.io.utils import add_verbose_arg + def _build_arg_parser(): p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawTextHelpFormatter) @@ -41,22 +42,27 @@ def main(): print('Your {} version is: {}'.format(_bold('Python'), _bold(platform.python_version()))) - dists = [d for d in pkg_resources.working_set] + dists = [] + for d in distributions(): + dists.append({"version": d.version, + "project_name": d.metadata['Name'], + "location": str(d.locate_file(''))}) + important_deps = ['dipy', 'numpy', 'nibabel', 'dmri-commit', 'dmri-amico'] for dist in dists: - if dist.project_name == 'scilpy': - date = time.ctime(os.path.getctime(dist.location)) + if dist['project_name'] == 'scilpy': + date = time.ctime(os.path.getctime(dist['location'])) date = datetime.datetime.strptime(date, "%a %b %d %H:%M:%S %Y") date = date.strftime('%Y-%m-%d') print('You installed {} with pip on {}'.format(_bold('Scilpy'), _bold(date))) - print('The closest release is {}\n'.format(_bold(dist.version))) - if args.show_dependencies and dist.project_name in important_deps: - print(' {}: {}'.format(_bold(dist.project_name), - _bold(dist.version))) + print('The closest release is {}\n'.format(_bold(dist['version']))) + if args.show_dependencies and dist['project_name'] in important_deps: + print(' {}: {}'.format(_bold(dist['project_name']), + _bold(dist['version']))) - repo_dir = pathlib.Path(__file__).parent.parent + repo_dir = pathlib.Path(__file__).parent.parent.parent.parent try: repo = git.Repo(repo_dir) except git.InvalidGitRepositoryError: @@ -71,11 +77,14 @@ def main(): with open(os.path.join(repo_dir, '.git', 'FETCH_HEAD')) as f: git_text = f.read().split() branch = git_text[2].replace("'", "") - origin = git_text[4] + origin = '' + if len(git_text) > 4 : + origin = git_text[4] print('Your Scilpy directory is: {}'.format(_bold(repo_dir))) - print('Your current Origin is: {}'.format(_bold(origin))) - print('Your repository is on branch: {}\n'.format(_bold(branch))) + if origin: + print('Your current origin is: {}'.format(_bold(origin))) + print('Your repository is on branch: {}\n'.format(_bold(branch))) last_commit = repo.head.commit print('The last commit hash is: {}'.format(_bold(last_commit.hexsha))) diff --git a/scripts/scil_gradients_apply_transform.py b/src/scilpy/cli/scil_gradients_apply_transform.py similarity index 100% rename from scripts/scil_gradients_apply_transform.py rename to src/scilpy/cli/scil_gradients_apply_transform.py diff --git a/scripts/scil_gradients_convert.py b/src/scilpy/cli/scil_gradients_convert.py similarity index 100% rename from scripts/scil_gradients_convert.py rename to src/scilpy/cli/scil_gradients_convert.py diff --git a/scripts/scil_gradients_generate_sampling.py b/src/scilpy/cli/scil_gradients_generate_sampling.py similarity index 100% rename from scripts/scil_gradients_generate_sampling.py rename to src/scilpy/cli/scil_gradients_generate_sampling.py diff --git a/scripts/scil_gradients_modify_axes.py b/src/scilpy/cli/scil_gradients_modify_axes.py similarity index 100% rename from scripts/scil_gradients_modify_axes.py rename to src/scilpy/cli/scil_gradients_modify_axes.py diff --git a/scripts/scil_gradients_normalize_bvecs.py b/src/scilpy/cli/scil_gradients_normalize_bvecs.py similarity index 100% rename from scripts/scil_gradients_normalize_bvecs.py rename to src/scilpy/cli/scil_gradients_normalize_bvecs.py diff --git a/scripts/scil_gradients_round_bvals.py b/src/scilpy/cli/scil_gradients_round_bvals.py similarity index 100% rename from scripts/scil_gradients_round_bvals.py rename to src/scilpy/cli/scil_gradients_round_bvals.py diff --git a/scripts/scil_gradients_validate_correct.py b/src/scilpy/cli/scil_gradients_validate_correct.py similarity index 100% rename from scripts/scil_gradients_validate_correct.py rename to src/scilpy/cli/scil_gradients_validate_correct.py diff --git a/scripts/scil_gradients_validate_correct_eddy.py b/src/scilpy/cli/scil_gradients_validate_correct_eddy.py similarity index 100% rename from scripts/scil_gradients_validate_correct_eddy.py rename to src/scilpy/cli/scil_gradients_validate_correct_eddy.py diff --git a/scripts/scil_gradients_validate_sampling.py b/src/scilpy/cli/scil_gradients_validate_sampling.py similarity index 88% rename from scripts/scil_gradients_validate_sampling.py rename to src/scilpy/cli/scil_gradients_validate_sampling.py index 7483b485d..3ea46aa36 100644 --- a/scripts/scil_gradients_validate_sampling.py +++ b/src/scilpy/cli/scil_gradients_validate_sampling.py @@ -19,11 +19,10 @@ value, the script raises a warning. The user might want to use the -v verbose option to see the computed energies. -The --viz option displays both the inputed and optimal b-vectors on a -single shell. The --viz_and_save option first displays both the inputed and -optimal b-vectors on a single shell and then saves them as png. Use one or the -other, not both. For more options on visualization, please use -scil_viz_gradients_screenshot.py. +The --viz option displays both the input and optimal b-vectors on a single +shell. The --save_viz option saves this image as png. If --save_viz is used +without --viz, the image will be saved but not shown. For more options on +visualization, please use scil_viz_gradients_screenshot.py. ------------------------------------------------------------------------------ Reference: [1] Emmanuel Caruyer, Christophe Lenglet, Guillermo Sapiro, @@ -70,13 +69,13 @@ def _build_arg_parser(): 'energy \nand the optimal b-vectors\' energy ' '(input_energy/optimal_energy). [%(default)s]') - p2 = p.add_mutually_exclusive_group() - p2.add_argument('--viz', action='store_true', - help='Visualize the inputed gradient scheme, then the ' - 'optimal one.') - p2.add_argument('--viz_and_save', metavar='OUT_FOLDER', - help='Save the inputed and optimal gradient schemes in ' - 'the specified folder.') + p.add_argument('--viz', action='store_true', + help='Visualize the inputed gradient scheme, then the ' + 'optimal one.') + p.add_argument('--save_viz', metavar='OUT_FOLDER', + help='Save the input and optimal gradient schemes in ' + 'the specified folder. If --viz is not set, then ' + 'the window is not shown but will be saved.') add_b0_thresh_arg(p) add_skip_b0_check_arg(p, will_overwrite_with_min=False) @@ -110,8 +109,8 @@ def main(): # Check output files out_files = [None, None] - if args.viz_and_save: - out_path = args.viz_and_save + if args.save_viz is not None: + out_path = args.save_viz out_files = [os.path.join(out_path, "inputed_gradient_scheme"), os.path.join(out_path, "optimized_gradient_scheme")] assert_outputs_exist(parser, args, [], @@ -150,13 +149,14 @@ def main(): verbose=0) # Visualize the gradient schemes - if args.viz or args.viz_and_save: + if args.viz or (args.save_viz is not None): viz_bvecs = build_ms_from_shell_idx(bvecs, shell_idx) viz_opt_bvecs = build_ms_from_shell_idx(opt_bvecs, shell_idx) plot_proj_shell(viz_bvecs, use_sym=True, title="Inputed b-vectors", - ofile=out_files[0]) + ofile=out_files[0], silent=not args.viz) plot_proj_shell(viz_opt_bvecs, use_sym=True, - title="Optimized b-vectors", ofile=out_files[1]) + title="Optimized b-vectors", ofile=out_files[1], + silent=not args.viz) # Compute the energy for both the input bvecs and optimal bvecs. energy, opt_energy = energy_comparison(bvecs, opt_bvecs, nb_shells, diff --git a/scripts/scil_header_print_info.py b/src/scilpy/cli/scil_header_print_info.py similarity index 100% rename from scripts/scil_header_print_info.py rename to src/scilpy/cli/scil_header_print_info.py diff --git a/scripts/scil_header_validate_compatibility.py b/src/scilpy/cli/scil_header_validate_compatibility.py similarity index 100% rename from scripts/scil_header_validate_compatibility.py rename to src/scilpy/cli/scil_header_validate_compatibility.py diff --git a/scripts/scil_json_convert_entries_to_xlsx.py b/src/scilpy/cli/scil_json_convert_entries_to_xlsx.py similarity index 100% rename from scripts/scil_json_convert_entries_to_xlsx.py rename to src/scilpy/cli/scil_json_convert_entries_to_xlsx.py diff --git a/scripts/scil_json_harmonize_entries.py b/src/scilpy/cli/scil_json_harmonize_entries.py similarity index 100% rename from scripts/scil_json_harmonize_entries.py rename to src/scilpy/cli/scil_json_harmonize_entries.py diff --git a/scripts/scil_json_merge_entries.py b/src/scilpy/cli/scil_json_merge_entries.py similarity index 100% rename from scripts/scil_json_merge_entries.py rename to src/scilpy/cli/scil_json_merge_entries.py diff --git a/scripts/scil_labels_combine.py b/src/scilpy/cli/scil_labels_combine.py similarity index 100% rename from scripts/scil_labels_combine.py rename to src/scilpy/cli/scil_labels_combine.py diff --git a/scripts/scil_labels_dilate.py b/src/scilpy/cli/scil_labels_dilate.py similarity index 100% rename from scripts/scil_labels_dilate.py rename to src/scilpy/cli/scil_labels_dilate.py diff --git a/scripts/scil_labels_from_mask.py b/src/scilpy/cli/scil_labels_from_mask.py similarity index 100% rename from scripts/scil_labels_from_mask.py rename to src/scilpy/cli/scil_labels_from_mask.py diff --git a/scripts/scil_labels_remove.py b/src/scilpy/cli/scil_labels_remove.py similarity index 100% rename from scripts/scil_labels_remove.py rename to src/scilpy/cli/scil_labels_remove.py diff --git a/scripts/scil_labels_split_volume_by_ids.py b/src/scilpy/cli/scil_labels_split_volume_by_ids.py similarity index 100% rename from scripts/scil_labels_split_volume_by_ids.py rename to src/scilpy/cli/scil_labels_split_volume_by_ids.py diff --git a/scripts/scil_labels_split_volume_from_lut.py b/src/scilpy/cli/scil_labels_split_volume_from_lut.py similarity index 93% rename from scripts/scil_labels_split_volume_from_lut.py rename to src/scilpy/cli/scil_labels_split_volume_from_lut.py index a031aa4fd..cb197e15a 100755 --- a/scripts/scil_labels_split_volume_from_lut.py +++ b/src/scilpy/cli/scil_labels_split_volume_from_lut.py @@ -19,7 +19,7 @@ import nibabel as nib -from scilpy.image.labels import get_data_as_labels, get_lut_dir, split_labels +from scilpy.image.labels import get_data_as_labels, split_labels, SCILPY_LUT_DIR from scilpy.io.utils import (add_overwrite_arg, add_verbose_arg, assert_inputs_exist, assert_outputs_exist, assert_output_dirs_exist_and_empty) @@ -27,7 +27,7 @@ def _build_arg_parser(): - luts = [os.path.splitext(f)[0] for f in os.listdir(get_lut_dir())] + luts = [os.path.splitext(f)[0] for f in os.listdir(SCILPY_LUT_DIR)] p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawTextHelpFormatter, @@ -67,7 +67,7 @@ def main(): label_img_data = get_data_as_labels(label_img) if args.scilpy_lut: - with open(os.path.join(get_lut_dir(), args.scilpy_lut + '.json')) as f: + with open(os.path.join(SCILPY_LUT_DIR, args.scilpy_lut + '.json')) as f: label_dict = json.load(f) else: with open(args.custom_lut) as f: diff --git a/scripts/scil_lesions_generate_nawm.py b/src/scilpy/cli/scil_lesions_generate_nawm.py similarity index 100% rename from scripts/scil_lesions_generate_nawm.py rename to src/scilpy/cli/scil_lesions_generate_nawm.py diff --git a/src/scilpy/cli/scil_lesions_harmonize_labels.py b/src/scilpy/cli/scil_lesions_harmonize_labels.py new file mode 100644 index 000000000..713dacb35 --- /dev/null +++ b/src/scilpy/cli/scil_lesions_harmonize_labels.py @@ -0,0 +1,108 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +""" +This script harmonizes labels across a set of lesion files represented in +NIfTI format. It ensures that labels are consistent across multiple input +images by matching labels between images based on spatial proximity and +overlap criteria. + +The script works iteratively, so the multiple inputs should be in chronological +order (and changing the order affects the output). All images should be +co-registered. + +To obtain labels from binary mask use scil_labels_from_mask.py + +WARNING: this script requires all files to have all lesions segmented. +If your data only show new lesions at each timepoints (common in manual +segmentation), use the option --incremental_lesions to merge past timepoints. + T1 = T1, T2 = T1 + T2, T3 = T1 + T2 + T3 +""" + +import argparse +import os + +import nibabel as nib +import numpy as np + +from scilpy.image.labels import (get_data_as_labels, harmonize_labels, + get_labels_from_mask) +from scilpy.io.utils import (add_overwrite_arg, + assert_inputs_exist, + assert_output_dirs_exist_and_empty, + assert_headers_compatible) + +EPILOG = """ +Reference: + [1] Köhler, Caroline, et al. "Exploring individual multiple sclerosis + lesion volume change over time: development of an algorithm for the + analyses of longitudinal quantitative MRI measures." + NeuroImage: Clinical 21 (2019): 101623. +""" + + +def _build_arg_parser(): + p = argparse.ArgumentParser( + description=__doc__, formatter_class=argparse.RawTextHelpFormatter) + p.add_argument('in_images', nargs='+', + help='Input file name, in nifti format.') + p.add_argument('out_dir', + help='Output directory.') + p.add_argument('--max_adjacency', type=float, default=5.0, + help='Maximum adjacency distance between lesions for ' + 'them to be considered as the potential match ' + '[%(default)s].') + p.add_argument('--min_voxel_overlap', type=int, default=1, + help='Minimum number of overlapping voxels between ' + 'lesions for them to be considered as the potential ' + 'match [%(default)s].') + + p.add_argument('--incremental_lesions', action='store_true', + help='If lesions files only show new lesions at each ' + 'timepoint, this will merge past timepoints.') + p.add_argument('--debug_mode', action='store_true', + help='Add a fake voxel to the corner to ensure consistent ' + 'colors in MI-Brain.') + + add_overwrite_arg(p) + return p + + +def main(): + parser = _build_arg_parser() + args = parser.parse_args() + + assert_inputs_exist(parser, args.in_images) + assert_output_dirs_exist_and_empty(parser, args, args.out_dir) + assert_headers_compatible(parser, args.in_images) + + imgs = [nib.load(filename) for filename in args.in_images] + original_data = [get_data_as_labels(img) for img in imgs] + + masks = [] + if args.incremental_lesions: + for i, data in enumerate(original_data): + mask = np.zeros_like(data) + mask[data > 0] = 1 + masks.append(mask) + if i > 0: + new_data = np.sum(masks, axis=0) + new_data[new_data > 0] = 1 + else: + new_data = mask + original_data[i] = get_labels_from_mask(new_data) + + relabeled_data = harmonize_labels(original_data, + args.min_voxel_overlap, + max_adjacency=args.max_adjacency) + + max_label = np.max(relabeled_data) + 1 + for i, img in enumerate(imgs): + if args.debug_mode: + relabeled_data[i][0, 0, 0] = max_label # To force identical color + nib.save(nib.Nifti1Image(relabeled_data[i], img.affine), + os.path.join(args.out_dir, os.path.basename(args.in_images[i]))) + + +if __name__ == "__main__": + main() diff --git a/scripts/scil_lesions_info.py b/src/scilpy/cli/scil_lesions_info.py similarity index 100% rename from scripts/scil_lesions_info.py rename to src/scilpy/cli/scil_lesions_info.py diff --git a/scripts/scil_mrds_metrics.py b/src/scilpy/cli/scil_mrds_metrics.py similarity index 100% rename from scripts/scil_mrds_metrics.py rename to src/scilpy/cli/scil_mrds_metrics.py diff --git a/scripts/scil_mrds_select_number_of_tensors.py b/src/scilpy/cli/scil_mrds_select_number_of_tensors.py similarity index 100% rename from scripts/scil_mrds_select_number_of_tensors.py rename to src/scilpy/cli/scil_mrds_select_number_of_tensors.py diff --git a/scripts/scil_mti_adjust_B1_header.py b/src/scilpy/cli/scil_mti_adjust_B1_header.py similarity index 100% rename from scripts/scil_mti_adjust_B1_header.py rename to src/scilpy/cli/scil_mti_adjust_B1_header.py diff --git a/scripts/scil_mti_maps_MT.py b/src/scilpy/cli/scil_mti_maps_MT.py similarity index 100% rename from scripts/scil_mti_maps_MT.py rename to src/scilpy/cli/scil_mti_maps_MT.py diff --git a/scripts/scil_mti_maps_ihMT.py b/src/scilpy/cli/scil_mti_maps_ihMT.py similarity index 100% rename from scripts/scil_mti_maps_ihMT.py rename to src/scilpy/cli/scil_mti_maps_ihMT.py diff --git a/scripts/scil_plot_stats_per_point.py b/src/scilpy/cli/scil_plot_stats_per_point.py similarity index 100% rename from scripts/scil_plot_stats_per_point.py rename to src/scilpy/cli/scil_plot_stats_per_point.py diff --git a/scripts/scil_qball_metrics.py b/src/scilpy/cli/scil_qball_metrics.py similarity index 100% rename from scripts/scil_qball_metrics.py rename to src/scilpy/cli/scil_qball_metrics.py diff --git a/scripts/scil_rgb_convert.py b/src/scilpy/cli/scil_rgb_convert.py similarity index 100% rename from scripts/scil_rgb_convert.py rename to src/scilpy/cli/scil_rgb_convert.py diff --git a/scripts/scil_search_keywords.py b/src/scilpy/cli/scil_search_keywords.py similarity index 98% rename from scripts/scil_search_keywords.py rename to src/scilpy/cli/scil_search_keywords.py index 533c107c5..176798593 100755 --- a/scripts/scil_search_keywords.py +++ b/src/scilpy/cli/scil_search_keywords.py @@ -65,7 +65,7 @@ from scilpy.utils.scilpy_bot import SPACING_LEN, VOCAB_FILE_PATH from scilpy.io.utils import add_verbose_arg from scilpy.version import version_string - +from scilpy import SCILPY_HOME def _build_arg_parser(): p = argparse.ArgumentParser(description=__doc__, @@ -107,8 +107,7 @@ def main(): # keywords are single words. Phrases are composed keywords keywords, phrases = _extract_keywords_and_phrases(args.expressions) - - with open(VOCAB_FILE_PATH, 'r') as f: + with open(VOCAB_FILE_PATH, 'r', encoding="utf-8") as f: vocab_data = json.load(f) # If synonyms are enabled, extend the search to include synonyms @@ -131,8 +130,7 @@ def main(): phrase_mapping = {stem: orig for orig, stem in zip(phrases, stemmed_phrases)} - script_dir = pathlib.Path(__file__).parent - hidden_dir = script_dir / '.hidden' + hidden_dir = pathlib.Path(SCILPY_HOME) / ".hidden" if args.regenerate_help_files: shutil.rmtree(hidden_dir) diff --git a/scripts/scil_sh_convert.py b/src/scilpy/cli/scil_sh_convert.py similarity index 100% rename from scripts/scil_sh_convert.py rename to src/scilpy/cli/scil_sh_convert.py diff --git a/scripts/scil_sh_fusion.py b/src/scilpy/cli/scil_sh_fusion.py similarity index 100% rename from scripts/scil_sh_fusion.py rename to src/scilpy/cli/scil_sh_fusion.py diff --git a/scripts/scil_sh_to_aodf.py b/src/scilpy/cli/scil_sh_to_aodf.py similarity index 100% rename from scripts/scil_sh_to_aodf.py rename to src/scilpy/cli/scil_sh_to_aodf.py diff --git a/scripts/scil_sh_to_rish.py b/src/scilpy/cli/scil_sh_to_rish.py similarity index 100% rename from scripts/scil_sh_to_rish.py rename to src/scilpy/cli/scil_sh_to_rish.py diff --git a/scripts/scil_sh_to_sf.py b/src/scilpy/cli/scil_sh_to_sf.py similarity index 100% rename from scripts/scil_sh_to_sf.py rename to src/scilpy/cli/scil_sh_to_sf.py diff --git a/scripts/scil_stats_group_comparison.py b/src/scilpy/cli/scil_stats_group_comparison.py similarity index 100% rename from scripts/scil_stats_group_comparison.py rename to src/scilpy/cli/scil_stats_group_comparison.py diff --git a/scripts/scil_surface_apply_transform.py b/src/scilpy/cli/scil_surface_apply_transform.py similarity index 100% rename from scripts/scil_surface_apply_transform.py rename to src/scilpy/cli/scil_surface_apply_transform.py diff --git a/scripts/scil_surface_convert.py b/src/scilpy/cli/scil_surface_convert.py similarity index 100% rename from scripts/scil_surface_convert.py rename to src/scilpy/cli/scil_surface_convert.py diff --git a/scripts/scil_surface_create.py b/src/scilpy/cli/scil_surface_create.py similarity index 100% rename from scripts/scil_surface_create.py rename to src/scilpy/cli/scil_surface_create.py diff --git a/scripts/scil_surface_flip.py b/src/scilpy/cli/scil_surface_flip.py similarity index 100% rename from scripts/scil_surface_flip.py rename to src/scilpy/cli/scil_surface_flip.py diff --git a/scripts/scil_surface_smooth.py b/src/scilpy/cli/scil_surface_smooth.py similarity index 100% rename from scripts/scil_surface_smooth.py rename to src/scilpy/cli/scil_surface_smooth.py diff --git a/scripts/scil_tracking_local.py b/src/scilpy/cli/scil_tracking_local.py similarity index 100% rename from scripts/scil_tracking_local.py rename to src/scilpy/cli/scil_tracking_local.py diff --git a/scripts/scil_tracking_local_dev.py b/src/scilpy/cli/scil_tracking_local_dev.py similarity index 100% rename from scripts/scil_tracking_local_dev.py rename to src/scilpy/cli/scil_tracking_local_dev.py diff --git a/scripts/scil_tracking_pft.py b/src/scilpy/cli/scil_tracking_pft.py similarity index 100% rename from scripts/scil_tracking_pft.py rename to src/scilpy/cli/scil_tracking_pft.py diff --git a/scripts/scil_tracking_pft_maps.py b/src/scilpy/cli/scil_tracking_pft_maps.py similarity index 100% rename from scripts/scil_tracking_pft_maps.py rename to src/scilpy/cli/scil_tracking_pft_maps.py diff --git a/scripts/scil_tracking_pft_maps_edit.py b/src/scilpy/cli/scil_tracking_pft_maps_edit.py similarity index 100% rename from scripts/scil_tracking_pft_maps_edit.py rename to src/scilpy/cli/scil_tracking_pft_maps_edit.py diff --git a/scripts/scil_tractogram_apply_transform.py b/src/scilpy/cli/scil_tractogram_apply_transform.py similarity index 100% rename from scripts/scil_tractogram_apply_transform.py rename to src/scilpy/cli/scil_tractogram_apply_transform.py diff --git a/scripts/scil_tractogram_apply_transform_to_hdf5.py b/src/scilpy/cli/scil_tractogram_apply_transform_to_hdf5.py similarity index 100% rename from scripts/scil_tractogram_apply_transform_to_hdf5.py rename to src/scilpy/cli/scil_tractogram_apply_transform_to_hdf5.py diff --git a/scripts/scil_tractogram_assign_custom_color.py b/src/scilpy/cli/scil_tractogram_assign_custom_color.py similarity index 98% rename from scripts/scil_tractogram_assign_custom_color.py rename to src/scilpy/cli/scil_tractogram_assign_custom_color.py index 4e716f7bb..8471b04d8 100755 --- a/scripts/scil_tractogram_assign_custom_color.py +++ b/src/scilpy/cli/scil_tractogram_assign_custom_color.py @@ -50,7 +50,6 @@ import logging from dipy.io.streamline import save_tractogram -from fury import colormap import nibabel as nib import numpy as np import matplotlib.pyplot as plt @@ -120,7 +119,7 @@ def _build_arg_parser(): g2 = p.add_argument_group(title='Coloring options') g2.add_argument('--ambiant_occlusion', nargs='?', const=4, type=int, help='Impact factor of the ambiant occlusion ' - 'approximation. [%(default)s]') + 'approximation. Default if set is 4.') g2.add_argument('--colormap', default='jet', help='Select the colormap for colored trk (dps/dpp) ' '[%(default)s].\nUse two Matplotlib named color separeted ' @@ -214,7 +213,8 @@ def main(): 'but got {}'.format(expected_shape, len(data))) else: # args.from_anatomy: data = nib.load(args.from_anatomy).get_fdata() - data = map_coordinates(data, concat_points, order=0) + data = map_coordinates(data, concat_points, order=0, + mode='nearest') elif args.along_profile: data = get_streamlines_as_linspaces(sft) data = np.hstack(data) diff --git a/scripts/scil_tractogram_assign_uniform_color.py b/src/scilpy/cli/scil_tractogram_assign_uniform_color.py similarity index 99% rename from scripts/scil_tractogram_assign_uniform_color.py rename to src/scilpy/cli/scil_tractogram_assign_uniform_color.py index 1c834bfa8..5ee981b41 100755 --- a/scripts/scil_tractogram_assign_uniform_color.py +++ b/src/scilpy/cli/scil_tractogram_assign_uniform_color.py @@ -143,6 +143,7 @@ def main(): if args.dict_colors: base, ext = os.path.splitext(filename) + base = os.path.basename(base) pos = base.index('__') if '__' in base else -2 base = base[pos + 2:] diff --git a/scripts/scil_tractogram_commit.py b/src/scilpy/cli/scil_tractogram_commit.py similarity index 99% rename from scripts/scil_tractogram_commit.py rename to src/scilpy/cli/scil_tractogram_commit.py index 4014516b7..ef9dc2a40 100755 --- a/scripts/scil_tractogram_commit.py +++ b/src/scilpy/cli/scil_tractogram_commit.py @@ -259,8 +259,8 @@ def _save_results(args, tmp_dir, ext, in_hdf5_file, offsets_list, sub_dir, shutil.copy(os.path.join(commit_results_dir, f), out_dir) dps_key = 'commit2_weights' if is_commit_2 else 'commit1_weights' - dps_key_tot = 'tot_commit2_weights' if is_commit_2 else \ - 'tot_commit1_weights' + dps_key_tot = 'tot_commit2_w' if is_commit_2 else \ + 'tot_commit_w' # Reload is needed because of COMMIT handling its file by itself sft.data_per_streamline[dps_key] = streamline_weights sft.data_per_streamline[dps_key_tot] = streamline_weights * length_list @@ -322,8 +322,8 @@ def _save_out_hdf5(commit_results_dir, sft, in_hdf5_file, dps_commit_key = 'commit2_weights' if is_commit_2 else \ 'commit1_weights' dps[dps_commit_key] = tmp_streamline_weights - dps_key_tot = 'tot_commit2_weights' if is_commit_2 else \ - 'tot_commit1_weights' + dps_key_tot = 'tot_commit2_w' if is_commit_2 else \ + 'tot_commit_w' dps[dps_key_tot] = tmp_streamline_weights * tmp_length_list # Replacing the data with the one above the threshold diff --git a/scripts/scil_tractogram_compress.py b/src/scilpy/cli/scil_tractogram_compress.py similarity index 100% rename from scripts/scil_tractogram_compress.py rename to src/scilpy/cli/scil_tractogram_compress.py diff --git a/scripts/scil_tractogram_compute_TODI.py b/src/scilpy/cli/scil_tractogram_compute_TODI.py similarity index 100% rename from scripts/scil_tractogram_compute_TODI.py rename to src/scilpy/cli/scil_tractogram_compute_TODI.py diff --git a/scripts/scil_tractogram_compute_density_map.py b/src/scilpy/cli/scil_tractogram_compute_density_map.py similarity index 100% rename from scripts/scil_tractogram_compute_density_map.py rename to src/scilpy/cli/scil_tractogram_compute_density_map.py diff --git a/scripts/scil_tractogram_convert.py b/src/scilpy/cli/scil_tractogram_convert.py similarity index 100% rename from scripts/scil_tractogram_convert.py rename to src/scilpy/cli/scil_tractogram_convert.py diff --git a/scripts/scil_tractogram_convert_hdf5_to_trk.py b/src/scilpy/cli/scil_tractogram_convert_hdf5_to_trk.py similarity index 100% rename from scripts/scil_tractogram_convert_hdf5_to_trk.py rename to src/scilpy/cli/scil_tractogram_convert_hdf5_to_trk.py diff --git a/scripts/scil_tractogram_convert_trk_to_hdf5.py b/src/scilpy/cli/scil_tractogram_convert_trk_to_hdf5.py similarity index 100% rename from scripts/scil_tractogram_convert_trk_to_hdf5.py rename to src/scilpy/cli/scil_tractogram_convert_trk_to_hdf5.py diff --git a/scripts/scil_tractogram_count_streamlines.py b/src/scilpy/cli/scil_tractogram_count_streamlines.py similarity index 100% rename from scripts/scil_tractogram_count_streamlines.py rename to src/scilpy/cli/scil_tractogram_count_streamlines.py diff --git a/scripts/scil_tractogram_cut_streamlines.py b/src/scilpy/cli/scil_tractogram_cut_streamlines.py similarity index 100% rename from scripts/scil_tractogram_cut_streamlines.py rename to src/scilpy/cli/scil_tractogram_cut_streamlines.py diff --git a/scripts/scil_tractogram_detect_loops.py b/src/scilpy/cli/scil_tractogram_detect_loops.py similarity index 100% rename from scripts/scil_tractogram_detect_loops.py rename to src/scilpy/cli/scil_tractogram_detect_loops.py diff --git a/scripts/scil_tractogram_dpp_math.py b/src/scilpy/cli/scil_tractogram_dpp_math.py similarity index 100% rename from scripts/scil_tractogram_dpp_math.py rename to src/scilpy/cli/scil_tractogram_dpp_math.py diff --git a/scripts/scil_tractogram_dps_math.py b/src/scilpy/cli/scil_tractogram_dps_math.py similarity index 99% rename from scripts/scil_tractogram_dps_math.py rename to src/scilpy/cli/scil_tractogram_dps_math.py index 90b6527d7..62c036cec 100755 --- a/scripts/scil_tractogram_dps_math.py +++ b/src/scilpy/cli/scil_tractogram_dps_math.py @@ -140,7 +140,7 @@ def main(): if len(data) == 1: data = data[0] - data = [data] * len(sft.streamlines) + data = np.array([data] * len(sft), dtype=data.dtype) sft.data_per_streamline[args.dps_key] = data diff --git a/scripts/scil_tractogram_extract_ushape.py b/src/scilpy/cli/scil_tractogram_extract_ushape.py similarity index 100% rename from scripts/scil_tractogram_extract_ushape.py rename to src/scilpy/cli/scil_tractogram_extract_ushape.py diff --git a/scripts/scil_tractogram_filter_by_anatomy.py b/src/scilpy/cli/scil_tractogram_filter_by_anatomy.py similarity index 100% rename from scripts/scil_tractogram_filter_by_anatomy.py rename to src/scilpy/cli/scil_tractogram_filter_by_anatomy.py diff --git a/scripts/scil_tractogram_filter_by_length.py b/src/scilpy/cli/scil_tractogram_filter_by_length.py similarity index 100% rename from scripts/scil_tractogram_filter_by_length.py rename to src/scilpy/cli/scil_tractogram_filter_by_length.py diff --git a/scripts/scil_tractogram_filter_by_orientation.py b/src/scilpy/cli/scil_tractogram_filter_by_orientation.py similarity index 100% rename from scripts/scil_tractogram_filter_by_orientation.py rename to src/scilpy/cli/scil_tractogram_filter_by_orientation.py diff --git a/scripts/scil_tractogram_filter_by_roi.py b/src/scilpy/cli/scil_tractogram_filter_by_roi.py similarity index 98% rename from scripts/scil_tractogram_filter_by_roi.py rename to src/scilpy/cli/scil_tractogram_filter_by_roi.py index fa94bd418..7a6c35c63 100755 --- a/scripts/scil_tractogram_filter_by_roi.py +++ b/src/scilpy/cli/scil_tractogram_filter_by_roi.py @@ -180,12 +180,16 @@ def _convert_filering_list_to_roi_args(parser, args): content = txt.readlines() for roi_opt in content: - # Convert the line with spaces to a list of args. - tmp_opt = roi_opt.split() + # Handle args when using multiple IDs with atlas_roi + tmp_opt = [] + if "\"" in roi_opt: + tmp_tmp = [i.strip() for i in roi_opt.strip().split("\"")] + tmp_opt.append( + tmp_tmp[0].split() + [tmp_tmp[1]] + tmp_tmp[2].split()) + else: + tmp_opt.append(roi_opt.strip().split()) - # Manage cases with " " or ' ' around options - tmp_opt = [i.replace("\"", '') for i in tmp_opt] - tmp_opt = [i.replace("'", '') for i in tmp_opt] + tmp_opt = tmp_opt[0] if tmp_opt[0] == 'drawn_roi': args.drawn_roi.append(tmp_opt[1:]) @@ -202,7 +206,6 @@ def _convert_filering_list_to_roi_args(parser, args): else: parser.error("Filtering list option {} not understood." .format(tmp_opt[0])) - return args diff --git a/scripts/scil_tractogram_filter_collisions.py b/src/scilpy/cli/scil_tractogram_filter_collisions.py similarity index 100% rename from scripts/scil_tractogram_filter_collisions.py rename to src/scilpy/cli/scil_tractogram_filter_collisions.py diff --git a/scripts/scil_tractogram_flip.py b/src/scilpy/cli/scil_tractogram_flip.py similarity index 100% rename from scripts/scil_tractogram_flip.py rename to src/scilpy/cli/scil_tractogram_flip.py diff --git a/scripts/scil_tractogram_math.py b/src/scilpy/cli/scil_tractogram_math.py similarity index 100% rename from scripts/scil_tractogram_math.py rename to src/scilpy/cli/scil_tractogram_math.py diff --git a/scripts/scil_tractogram_pairwise_comparison.py b/src/scilpy/cli/scil_tractogram_pairwise_comparison.py similarity index 100% rename from scripts/scil_tractogram_pairwise_comparison.py rename to src/scilpy/cli/scil_tractogram_pairwise_comparison.py diff --git a/scripts/scil_tractogram_print_info.py b/src/scilpy/cli/scil_tractogram_print_info.py similarity index 100% rename from scripts/scil_tractogram_print_info.py rename to src/scilpy/cli/scil_tractogram_print_info.py diff --git a/scripts/scil_tractogram_project_map_to_streamlines.py b/src/scilpy/cli/scil_tractogram_project_map_to_streamlines.py similarity index 100% rename from scripts/scil_tractogram_project_map_to_streamlines.py rename to src/scilpy/cli/scil_tractogram_project_map_to_streamlines.py diff --git a/scripts/scil_tractogram_project_streamlines_to_map.py b/src/scilpy/cli/scil_tractogram_project_streamlines_to_map.py similarity index 100% rename from scripts/scil_tractogram_project_streamlines_to_map.py rename to src/scilpy/cli/scil_tractogram_project_streamlines_to_map.py diff --git a/scripts/scil_tractogram_qbx.py b/src/scilpy/cli/scil_tractogram_qbx.py similarity index 100% rename from scripts/scil_tractogram_qbx.py rename to src/scilpy/cli/scil_tractogram_qbx.py diff --git a/scripts/scil_tractogram_register.py b/src/scilpy/cli/scil_tractogram_register.py similarity index 100% rename from scripts/scil_tractogram_register.py rename to src/scilpy/cli/scil_tractogram_register.py diff --git a/scripts/scil_tractogram_remove_invalid.py b/src/scilpy/cli/scil_tractogram_remove_invalid.py similarity index 100% rename from scripts/scil_tractogram_remove_invalid.py rename to src/scilpy/cli/scil_tractogram_remove_invalid.py diff --git a/scripts/scil_tractogram_resample.py b/src/scilpy/cli/scil_tractogram_resample.py similarity index 100% rename from scripts/scil_tractogram_resample.py rename to src/scilpy/cli/scil_tractogram_resample.py diff --git a/scripts/scil_tractogram_resample_nb_points.py b/src/scilpy/cli/scil_tractogram_resample_nb_points.py similarity index 100% rename from scripts/scil_tractogram_resample_nb_points.py rename to src/scilpy/cli/scil_tractogram_resample_nb_points.py diff --git a/scripts/scil_tractogram_seed_density_map.py b/src/scilpy/cli/scil_tractogram_seed_density_map.py similarity index 100% rename from scripts/scil_tractogram_seed_density_map.py rename to src/scilpy/cli/scil_tractogram_seed_density_map.py diff --git a/scripts/scil_tractogram_segment_connections_from_labels.py b/src/scilpy/cli/scil_tractogram_segment_connections_from_labels.py similarity index 100% rename from scripts/scil_tractogram_segment_connections_from_labels.py rename to src/scilpy/cli/scil_tractogram_segment_connections_from_labels.py diff --git a/scripts/scil_tractogram_segment_with_ROI_and_score.py b/src/scilpy/cli/scil_tractogram_segment_with_ROI_and_score.py similarity index 100% rename from scripts/scil_tractogram_segment_with_ROI_and_score.py rename to src/scilpy/cli/scil_tractogram_segment_with_ROI_and_score.py diff --git a/scripts/scil_tractogram_segment_with_bundleseg.py b/src/scilpy/cli/scil_tractogram_segment_with_bundleseg.py similarity index 100% rename from scripts/scil_tractogram_segment_with_bundleseg.py rename to src/scilpy/cli/scil_tractogram_segment_with_bundleseg.py diff --git a/scripts/scil_tractogram_segment_with_recobundles.py b/src/scilpy/cli/scil_tractogram_segment_with_recobundles.py similarity index 100% rename from scripts/scil_tractogram_segment_with_recobundles.py rename to src/scilpy/cli/scil_tractogram_segment_with_recobundles.py diff --git a/scripts/scil_tractogram_shuffle.py b/src/scilpy/cli/scil_tractogram_shuffle.py similarity index 100% rename from scripts/scil_tractogram_shuffle.py rename to src/scilpy/cli/scil_tractogram_shuffle.py diff --git a/scripts/scil_tractogram_smooth.py b/src/scilpy/cli/scil_tractogram_smooth.py similarity index 100% rename from scripts/scil_tractogram_smooth.py rename to src/scilpy/cli/scil_tractogram_smooth.py diff --git a/scripts/scil_tractogram_split.py b/src/scilpy/cli/scil_tractogram_split.py similarity index 100% rename from scripts/scil_tractogram_split.py rename to src/scilpy/cli/scil_tractogram_split.py diff --git a/scripts/scil_viz_bingham_fit.py b/src/scilpy/cli/scil_viz_bingham_fit.py similarity index 86% rename from scripts/scil_viz_bingham_fit.py rename to src/scilpy/cli/scil_viz_bingham_fit.py index ecacd11da..1e5c37b1d 100755 --- a/scripts/scil_viz_bingham_fit.py +++ b/src/scilpy/cli/scil_viz_bingham_fit.py @@ -6,6 +6,9 @@ Given an image of Bingham coefficients, this script displays a slice in a given orientation. + +Note. The interactive visualization is not verified by tests. If you encounter +any bug, please report it to our team or use --silent. """ import argparse @@ -36,7 +39,9 @@ def _build_arg_parser(): epilog=version_string) # Positional arguments - p.add_argument('in_bingham', help='Input SH image file.') + p.add_argument('in_bingham', + help='Input SH image file. Expecting data to be of size ' + '(X, Y, Z, nb_lobes, 7)') # Window configuration options p.add_argument('--slice_index', type=int, @@ -59,7 +64,7 @@ def _build_arg_parser(): p.add_argument('--silent', action='store_true', help='Disable interactive visualization.') - p.add_argument('--output', help='Path to output file.') + p.add_argument('--output', help='Path to output image file.') add_verbose_arg(p) add_overwrite_arg(p) @@ -76,24 +81,6 @@ def _build_arg_parser(): return p -def _parse_args(parser): - args = parser.parse_args() - inputs = [] - output = [] - inputs.append(args.in_bingham) - if args.output: - output.append(args.output) - else: - if args.silent: - parser.error('Silent mode is enabled but no output is specified.' - 'Specify an output with --output to use silent mode.') - - assert_inputs_exist(parser, inputs) - assert_outputs_exist(parser, args, output) - - return args - - def _get_slicing_for_axis(axis_name, index, shape): """ Get a tuple of slice representing the slice of interest at `index` @@ -121,14 +108,22 @@ def _get_data_from_inputs(args): def main(): parser = _build_arg_parser() - args = _parse_args(parser) + args = parser.parse_args() + logging.getLogger().setLevel(logging.getLevelName(args.verbose)) + + if not args.output and args.silent: + parser.error('Silent mode is enabled but no output is specified.' + 'Specify an output with --output to use silent mode.') + + assert_inputs_exist(parser, args.in_bingham) + assert_outputs_exist(parser, args, [], args.output) + data = _get_data_from_inputs(args) sph = get_sphere(name=args.sphere) - logging.getLogger().setLevel(logging.getLevelName(args.verbose)) actors = create_bingham_slicer(data, args.axis_name, args.slice_index, sph, - args.color_per_lobe) + color_per_lobe=args.color_per_lobe) # Prepare and display the scene scene = create_scene(actors, args.axis_name, diff --git a/scripts/scil_viz_bundle.py b/src/scilpy/cli/scil_viz_bundle.py similarity index 100% rename from scripts/scil_viz_bundle.py rename to src/scilpy/cli/scil_viz_bundle.py diff --git a/scripts/scil_viz_bundle_screenshot_mni.py b/src/scilpy/cli/scil_viz_bundle_screenshot_mni.py similarity index 100% rename from scripts/scil_viz_bundle_screenshot_mni.py rename to src/scilpy/cli/scil_viz_bundle_screenshot_mni.py diff --git a/scripts/scil_viz_bundle_screenshot_mosaic.py b/src/scilpy/cli/scil_viz_bundle_screenshot_mosaic.py similarity index 100% rename from scripts/scil_viz_bundle_screenshot_mosaic.py rename to src/scilpy/cli/scil_viz_bundle_screenshot_mosaic.py diff --git a/scripts/scil_viz_connectivity.py b/src/scilpy/cli/scil_viz_connectivity.py similarity index 100% rename from scripts/scil_viz_connectivity.py rename to src/scilpy/cli/scil_viz_connectivity.py diff --git a/scripts/scil_viz_dti_screenshot.py b/src/scilpy/cli/scil_viz_dti_screenshot.py similarity index 100% rename from scripts/scil_viz_dti_screenshot.py rename to src/scilpy/cli/scil_viz_dti_screenshot.py diff --git a/scripts/scil_viz_fodf.py b/src/scilpy/cli/scil_viz_fodf.py similarity index 85% rename from scripts/scil_viz_fodf.py rename to src/scilpy/cli/scil_viz_fodf.py index 8180e5747..753eae950 100755 --- a/scripts/scil_viz_fodf.py +++ b/src/scilpy/cli/scil_viz_fodf.py @@ -14,6 +14,9 @@ !!! CAUTION !!! The script is memory intensive about (9kB of allocated RAM per voxel, or 9GB for a 1M voxel volume) with a sphere interpolated to 362 points. + +Note. The interactive visualization is not verified by tests. If you encounter +any bug, please report it to our team or use --silent. """ import argparse @@ -179,7 +182,7 @@ def _build_arg_parser(): 'as follow: mean + k * sqrt(variance), where ' 'mean is the input fodf (in_fodf) and k is the ' 'scaling factor (variance_k).') - var.add_argument('--variance', help='FODF variance file.') + var.add_argument('--variance', help='FODF variance file (nifti).') var.add_argument('--variance_k', default=1, type=float, help='Scaling factor (k) for the computation of the fodf ' 'uncertainty. [%(default)s]') @@ -217,21 +220,24 @@ def _get_data_from_inputs(args): Load data given by args. Perform checks to ensure dimensions agree between the data for mask, background, peaks and fODF. """ - fodf = nib.load(args.in_fodf).get_fdata(dtype=np.float32) - data = {'fodf': fodf} + + # Optional: + bg = None + transparency_mask = None + mask = None + peaks = None + peak_vals = None + variance = None if args.background: assert_same_resolution([args.background, args.in_fodf]) bg = nib.load(args.background).get_fdata() - data['bg'] = bg if args.in_transparency_mask: transparency_mask = get_data_as_mask( nib.load(args.in_transparency_mask), dtype=bool) - data['transparency_mask'] = transparency_mask if args.mask: assert_same_resolution([args.mask, args.in_fodf]) mask = get_data_as_mask(nib.load(args.mask), dtype=bool) - data['mask'] = mask if args.peaks: assert_same_resolution([args.peaks, args.in_fodf]) peaks = nib.load(args.peaks).get_fdata() @@ -244,12 +250,10 @@ def _get_data_from_inputs(args): raise ValueError('Peaks volume last dimension ({0}) cannot ' 'be reshaped as (npeaks, 3).' .format(peaks.shape[-1])) - data['peaks'] = peaks if args.peaks_values: assert_same_resolution([args.peaks_values, args.in_fodf]) peak_vals =\ nib.load(args.peaks_values).get_fdata() - data['peaks_values'] = peak_vals if args.variance: assert_same_resolution([args.variance, args.in_fodf]) variance = nib.load(args.variance).get_fdata(dtype=np.float32) @@ -259,56 +263,45 @@ def _get_data_from_inputs(args): raise ValueError('Dimensions mismatch between fODF {0} and ' 'variance {1}.' .format(fodf.shape, variance.shape)) - data['variance'] = variance - return data + return fodf, bg, transparency_mask, mask, peaks, peak_vals, variance def main(): parser = _build_arg_parser() args = _parse_args(parser) - data = _get_data_from_inputs(args) + (fodf, bg, transparency_mask, mask, peaks, peaks_values, + variance) = _get_data_from_inputs(args) sph = get_sphere(name=args.sphere) - sh_order, full_basis = get_sh_order_and_fullness(data['fodf'].shape[-1]) + sh_order, full_basis = get_sh_order_and_fullness(fodf.shape[-1]) sh_basis, is_legacy = parse_sh_basis_arg(args) logging.getLogger().setLevel(logging.getLevelName(args.verbose)) actors = [] - # Retrieve the mask if supplied - if 'mask' in data: - mask = data['mask'] - else: - mask = None - if args.color_rgb: color_rgb = np.round(np.asarray(args.color_rgb) * 255) else: color_rgb = None - - variance = data['variance'] if args.variance else None var_color = np.asarray(args.var_color) * 255 + # Instantiate the ODF slicer actor - odf_actor, var_actor = create_odf_slicer(data['fodf'], args.axis_name, - args.slice_index, sph, sh_order, - sh_basis, full_basis, - args.scale, variance, mask, - args.sph_subdivide, - not args.radial_scale_off, - not args.norm_off, - args.colormap or color_rgb, - variance_k=args.variance_k, - variance_color=var_color, - is_legacy=is_legacy) + odf_actor, var_actor = create_odf_slicer( + fodf, args.axis_name, args.slice_index, sph, sh_order, + sh_basis, full_basis, args.scale, + sh_variance=variance, mask=mask, nb_subdivide=args.sph_subdivide, + radial_scale=not args.radial_scale_off, norm=not args.norm_off, + colormap=args.colormap or color_rgb, variance_k=args.variance_k, + variance_color=var_color, is_legacy=is_legacy) actors.append(odf_actor) # Instantiate a variance slicer actor if a variance image is supplied - if 'variance' in data: + if variance is not None: actors.append(var_actor) # Instantiate a texture slicer actor if a background image is supplied - if 'bg' in data: - bg_actor = create_texture_slicer(data['bg'], + if bg is not None: + bg_actor = create_texture_slicer(bg, args.axis_name, args.slice_index, mask=mask, @@ -319,14 +312,10 @@ def main(): actors.append(bg_actor) # Instantiate a peaks slicer actor if peaks are supplied - if 'peaks' in data: - - if 'peaks_values' in data: - peaks_values = data['peaks_values'] - else: - peaks_values =\ - np.ones(data['peaks'].shape[:-1]) * args.peaks_length - peaks_actor = create_peaks_slicer(data['peaks'], + if peaks is not None: + if peaks_values is None: + peaks_values = np.ones(peaks.shape[:-1]) * args.peaks_length + peaks_actor = create_peaks_slicer(peaks, args.axis_name, args.slice_index, peak_values=peaks_values, @@ -341,30 +330,25 @@ def main(): # Prepare and display the scene scene = create_scene(actors, args.axis_name, args.slice_index, - data['fodf'].shape[:3], + fodf.shape[:3], args.win_dims[0] / args.win_dims[1], bg_color=args.bg_color) mask_scene = None - if 'transparency_mask' in data: - mask_actor = create_texture_slicer( - data['transparency_mask'].astype("uint8"), - args.axis_name, - args.slice_index, - offset=0.0, - ) - - mask_scene = create_scene( - [mask_actor], - args.axis_name, - args.slice_index, - data['transparency_mask'].shape, - args.win_dims[0] / args.win_dims[1], - bg_color=args.bg_color) + if transparency_mask is not None: + mask_actor = create_texture_slicer(transparency_mask.astype("uint8"), + args.axis_name, + args.slice_index, + offset=0.0) + + mask_scene = create_scene([mask_actor], args.axis_name, + args.slice_index, + transparency_mask.shape, + args.win_dims[0] / args.win_dims[1], + bg_color=args.bg_color) if not args.silent: - create_interactive_window( - scene, args.win_dims, args.interactor) + create_interactive_window(scene, args.win_dims, args.interactor) if args.output: snapshots = snapshot_scenes(filter(None, [mask_scene, scene]), diff --git a/scripts/scil_viz_gradients_screenshot.py b/src/scilpy/cli/scil_viz_gradients_screenshot.py similarity index 94% rename from scripts/scil_viz_gradients_screenshot.py rename to src/scilpy/cli/scil_viz_gradients_screenshot.py index 72a991fca..8b4132700 100755 --- a/scripts/scil_viz_gradients_screenshot.py +++ b/src/scilpy/cli/scil_viz_gradients_screenshot.py @@ -73,6 +73,9 @@ def _build_arg_parser(): '--opacity', type=float, default=1.0, help='Opacity for the shells.') + p.add_argument('--silent', action='store_true', + help="If set, will not show anything, but will save " + "image to disc only.") add_verbose_arg(p) add_overwrite_arg(p) @@ -133,9 +136,8 @@ def main(): bvals = tmp[:, 3] centroids, shell_idx = identify_shells(bvals) - if args.verbose: - logging.info("Found {} centroids: {}".format( - len(centroids), centroids)) + logging.info("Found {} centroids: {}" + .format(len(centroids), centroids)) if args.out_basename: out_basename, ext = os.path.splitext(args.out_basename) @@ -173,11 +175,13 @@ def main(): if proj: plot_proj_shell(ms, use_sym=sym, use_sphere=sph, same_color=same, rad=0.025, opacity=args.opacity, - ofile=out_basename, ores=(args.res, args.res)) + ofile=out_basename, ores=(args.res, args.res), + silent=args.silent) if each: plot_each_shell(ms, centroids, plot_sym_vecs=sym, use_sphere=sph, same_color=same, rad=0.025, opacity=args.opacity, - ofile=out_basename, ores=(args.res, args.res)) + ofile=out_basename, ores=(args.res, args.res), + silent=args.silent) if __name__ == "__main__": diff --git a/scripts/scil_viz_tractogram_collisions.py b/src/scilpy/cli/scil_viz_tractogram_collisions.py similarity index 100% rename from scripts/scil_viz_tractogram_collisions.py rename to src/scilpy/cli/scil_viz_tractogram_collisions.py diff --git a/scripts/scil_viz_tractogram_seeds.py b/src/scilpy/cli/scil_viz_tractogram_seeds.py similarity index 100% rename from scripts/scil_viz_tractogram_seeds.py rename to src/scilpy/cli/scil_viz_tractogram_seeds.py diff --git a/scripts/scil_viz_tractogram_seeds_3d.py b/src/scilpy/cli/scil_viz_tractogram_seeds_3d.py similarity index 92% rename from scripts/scil_viz_tractogram_seeds_3d.py rename to src/scilpy/cli/scil_viz_tractogram_seeds_3d.py index 87ac3fc75..0ebc77208 100755 --- a/scripts/scil_viz_tractogram_seeds_3d.py +++ b/src/scilpy/cli/scil_viz_tractogram_seeds_3d.py @@ -59,7 +59,9 @@ def _build_arg_parser(): default=[0, 0, 0], type=parser_color_type, help='RBG values [0, 255] of the color of the background.' '\n[Default: %(default)s]') - + p.add_argument('--silent', action='store_true', + help="If set, runs the script but does not display the " + "window. For debugging purposes.") add_verbose_arg(p) return p @@ -114,9 +116,10 @@ def main(): scene.add(line_actor) # Showtime ! - showm = window.ShowManager(scene, reset_camera=True) - showm.initialize() - showm.start() + if not args.silent: + showm = window.ShowManager(scene, reset_camera=True) + showm.initialize() + showm.start() if __name__ == '__main__': diff --git a/scripts/scil_viz_volume_histogram.py b/src/scilpy/cli/scil_viz_volume_histogram.py similarity index 100% rename from scripts/scil_viz_volume_histogram.py rename to src/scilpy/cli/scil_viz_volume_histogram.py diff --git a/scripts/scil_viz_volume_scatterplot.py b/src/scilpy/cli/scil_viz_volume_scatterplot.py similarity index 100% rename from scripts/scil_viz_volume_scatterplot.py rename to src/scilpy/cli/scil_viz_volume_scatterplot.py diff --git a/scripts/scil_viz_volume_screenshot.py b/src/scilpy/cli/scil_viz_volume_screenshot.py similarity index 96% rename from scripts/scil_viz_volume_screenshot.py rename to src/scilpy/cli/scil_viz_volume_screenshot.py index 0f7921959..9b3886016 100755 --- a/scripts/scil_viz_volume_screenshot.py +++ b/src/scilpy/cli/scil_viz_volume_screenshot.py @@ -62,7 +62,8 @@ add_verbose_arg, assert_headers_compatible, assert_inputs_exist, assert_overlay_colors, - get_default_screenshotting_data) + get_default_screenshotting_data, + assert_outputs_exist, add_overwrite_arg) from scilpy.image.utils import check_slice_indices from scilpy.utils.spatial import get_axis_index from scilpy.version import version_string @@ -96,7 +97,7 @@ def _build_arg_parser(): add_overlays_screenshot_args(xg, 0.5, og) add_peaks_screenshot_args(xg, rendering_parsing_group=pg) add_verbose_arg(p) - + add_overwrite_arg(p) return p @@ -141,6 +142,9 @@ def empty_generator(): else: ax_idx = get_axis_index(args.axis) slice_ids = np.arange(vol_img.shape[ax_idx]) + name, ext = splitext(args.out_fname) + names = ["{}_slice_{}{}".format(name, s, ext) for s in slice_ids] + assert_outputs_exist(parser, args, names) # Generate the image slices volume_screenhots_generator = screenshot_volume(vol_img, args.axis, @@ -182,11 +186,10 @@ def empty_generator(): screenshot_peaks, ([peaks, args.axis, slice_ids, args.size] for peaks in peaks_imgs))) - name, ext = splitext(args.out_fname) - names = ["{}_slice_{}{}".format(name, s, ext) for s in slice_ids] sides_labels = ["P", "A"] if args.axis == "sagittal" else ["L", "R"] # Compose and save each slice + logging.info("Preparing all {} slices: ".format(len(slice_ids))) for volume, trans, label, contour, peaks, name, slice_id in zip_longest( volume_screenhots_generator, transparency_screenshots_generator, @@ -197,6 +200,7 @@ def empty_generator(): slice_ids, fillvalue=None): + logging.info(" - Slice {}".format(slice_id)) img = compose_image(volume, args.size, slice_id, transparency_scene=trans, image_alpha=args.volume_opacity, diff --git a/scripts/scil_viz_volume_screenshot_mosaic.py b/src/scilpy/cli/scil_viz_volume_screenshot_mosaic.py similarity index 100% rename from scripts/scil_viz_volume_screenshot_mosaic.py rename to src/scilpy/cli/scil_viz_volume_screenshot_mosaic.py diff --git a/scripts/scil_volume_apply_transform.py b/src/scilpy/cli/scil_volume_apply_transform.py similarity index 100% rename from scripts/scil_volume_apply_transform.py rename to src/scilpy/cli/scil_volume_apply_transform.py diff --git a/scripts/scil_volume_b0_synthesis.py b/src/scilpy/cli/scil_volume_b0_synthesis.py similarity index 100% rename from scripts/scil_volume_b0_synthesis.py rename to src/scilpy/cli/scil_volume_b0_synthesis.py diff --git a/scripts/scil_volume_count_non_zero_voxels.py b/src/scilpy/cli/scil_volume_count_non_zero_voxels.py similarity index 100% rename from scripts/scil_volume_count_non_zero_voxels.py rename to src/scilpy/cli/scil_volume_count_non_zero_voxels.py diff --git a/scripts/scil_volume_crop.py b/src/scilpy/cli/scil_volume_crop.py similarity index 100% rename from scripts/scil_volume_crop.py rename to src/scilpy/cli/scil_volume_crop.py diff --git a/scripts/scil_volume_distance_map.py b/src/scilpy/cli/scil_volume_distance_map.py similarity index 100% rename from scripts/scil_volume_distance_map.py rename to src/scilpy/cli/scil_volume_distance_map.py diff --git a/scripts/scil_volume_flip.py b/src/scilpy/cli/scil_volume_flip.py similarity index 100% rename from scripts/scil_volume_flip.py rename to src/scilpy/cli/scil_volume_flip.py diff --git a/scripts/scil_volume_math.py b/src/scilpy/cli/scil_volume_math.py similarity index 100% rename from scripts/scil_volume_math.py rename to src/scilpy/cli/scil_volume_math.py diff --git a/scripts/scil_volume_pairwise_comparison.py b/src/scilpy/cli/scil_volume_pairwise_comparison.py similarity index 100% rename from scripts/scil_volume_pairwise_comparison.py rename to src/scilpy/cli/scil_volume_pairwise_comparison.py diff --git a/scripts/scil_volume_remove_outliers_ransac.py b/src/scilpy/cli/scil_volume_remove_outliers_ransac.py similarity index 100% rename from scripts/scil_volume_remove_outliers_ransac.py rename to src/scilpy/cli/scil_volume_remove_outliers_ransac.py diff --git a/scripts/scil_volume_resample.py b/src/scilpy/cli/scil_volume_resample.py similarity index 100% rename from scripts/scil_volume_resample.py rename to src/scilpy/cli/scil_volume_resample.py diff --git a/scripts/scil_volume_reshape.py b/src/scilpy/cli/scil_volume_reshape.py similarity index 100% rename from scripts/scil_volume_reshape.py rename to src/scilpy/cli/scil_volume_reshape.py diff --git a/scripts/scil_volume_reslice_to_reference.py b/src/scilpy/cli/scil_volume_reslice_to_reference.py similarity index 100% rename from scripts/scil_volume_reslice_to_reference.py rename to src/scilpy/cli/scil_volume_reslice_to_reference.py diff --git a/scripts/scil_volume_stats_in_ROI.py b/src/scilpy/cli/scil_volume_stats_in_ROI.py similarity index 100% rename from scripts/scil_volume_stats_in_ROI.py rename to src/scilpy/cli/scil_volume_stats_in_ROI.py diff --git a/scripts/scil_volume_stats_in_labels.py b/src/scilpy/cli/scil_volume_stats_in_labels.py similarity index 100% rename from scripts/scil_volume_stats_in_labels.py rename to src/scilpy/cli/scil_volume_stats_in_labels.py diff --git a/scilpy/denoise/__init__.py b/src/scilpy/cli/tests/__init__.py similarity index 100% rename from scilpy/denoise/__init__.py rename to src/scilpy/cli/tests/__init__.py diff --git a/scripts/tests/test_NODDI_maps.py b/src/scilpy/cli/tests/test_NODDI_maps.py similarity index 63% rename from scripts/tests/test_NODDI_maps.py rename to src/scilpy/cli/tests/test_NODDI_maps.py index ed7e66b9f..b4dbe7ff9 100644 --- a/scripts/tests/test_NODDI_maps.py +++ b/src/scilpy/cli/tests/test_NODDI_maps.py @@ -14,7 +14,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_NODDI_maps.py', '--help') + ret = script_runner.run(['scil_NODDI_maps', '--help']) assert ret.success @@ -28,12 +28,12 @@ def test_execution_commit_amico(script_runner, monkeypatch): 'dwi.bvec') mask = os.path.join(SCILPY_HOME, 'commit_amico', 'mask.nii.gz') - ret = script_runner.run('scil_NODDI_maps.py', in_dwi, - in_bval, in_bvec, '--mask', mask, - '--out_dir', 'noddi', '--tol', '30', - '--para_diff', '0.0017', '--iso_diff', '0.003', - '--lambda1', '0.5', '--lambda2', '0.001', - '--processes', '1', '-f') + ret = script_runner.run(['scil_NODDI_maps', in_dwi, + in_bval, in_bvec, '--mask', mask, + '--out_dir', 'noddi', '--tol', '30', + '--para_diff', '0.0017', '--iso_diff', '0.003', + '--lambda1', '0.5', '--lambda2', '0.001', + '--processes', '1', '-f']) assert ret.success @@ -45,10 +45,10 @@ def test_single_shell_fail(script_runner, monkeypatch): '1000.bval') in_bvec = os.path.join(SCILPY_HOME, 'processing', '1000.bvec') - ret = script_runner.run('scil_NODDI_maps.py', in_dwi, - in_bval, in_bvec, - '--out_dir', 'noddi', '--tol', '30', - '--para_diff', '0.0017', '--iso_diff', '0.003', - '--lambda1', '0.5', '--lambda2', '0.001', - '--processes', '1', '-f') + ret = script_runner.run(['scil_NODDI_maps', in_dwi, + in_bval, in_bvec, + '--out_dir', 'noddi', '--tol', '30', + '--para_diff', '0.0017', '--iso_diff', '0.003', + '--lambda1', '0.5', '--lambda2', '0.001', + '--processes', '1', '-f']) assert not ret.success diff --git a/scripts/tests/test_NODDI_priors.py b/src/scilpy/cli/tests/test_NODDI_priors.py similarity index 64% rename from scripts/tests/test_NODDI_priors.py rename to src/scilpy/cli/tests/test_NODDI_priors.py index 11bfd29d4..b3aa375a7 100644 --- a/scripts/tests/test_NODDI_priors.py +++ b/src/scilpy/cli/tests/test_NODDI_priors.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_NODDI_priors.py', '--help') + ret = script_runner.run(['scil_NODDI_priors', '--help']) assert ret.success @@ -27,10 +27,10 @@ def test_execution_commit_amico(script_runner, monkeypatch): 'md.nii.gz') in_rd = os.path.join(SCILPY_HOME, 'processing', 'rd.nii.gz') - ret = script_runner.run('scil_NODDI_priors.py', in_fa, in_ad, in_rd, in_md, - '--out_txt_1fiber_para', '1fiber_para.txt', - '--out_txt_1fiber_perp', '1fiber_perp.txt', - '--out_mask_1fiber', '1fiber.nii.gz', - '--out_txt_ventricles', 'ventricules.txt', - '--out_mask_ventricles', 'ventricules.nii.gz') + ret = script_runner.run(['scil_NODDI_priors', in_fa, in_ad, in_rd, in_md, + '--out_txt_1fiber_para', '1fiber_para.txt', + '--out_txt_1fiber_perp', '1fiber_perp.txt', + '--out_mask_1fiber', '1fiber.nii.gz', + '--out_txt_ventricles', 'ventricules.txt', + '--out_mask_ventricles', 'ventricules.nii.gz']) assert ret.success diff --git a/scripts/tests/test_aodf_metrics.py b/src/scilpy/cli/tests/test_aodf_metrics.py similarity index 67% rename from scripts/tests/test_aodf_metrics.py rename to src/scilpy/cli/tests/test_aodf_metrics.py index a242e060b..a6daa9aee 100644 --- a/scripts/tests/test_aodf_metrics.py +++ b/src/scilpy/cli/tests/test_aodf_metrics.py @@ -12,7 +12,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_aodf_metrics.py', '--help') + ret = script_runner.run(['scil_aodf_metrics', '--help']) assert ret.success @@ -24,8 +24,8 @@ def test_execution(script_runner, monkeypatch): f"{test_data_root}/fodf_descoteaux07_sub_unified_asym.nii.gz") # Using a low resolution sphere for peak extraction reduces process time - ret = script_runner.run('scil_aodf_metrics.py', in_fodf, - '--sphere', 'repulsion100', '--processes', '1') + ret = script_runner.run(['scil_aodf_metrics', in_fodf, + '--sphere', 'repulsion100', '--processes', '1']) assert ret.success @@ -34,8 +34,8 @@ def test_assert_not_all(script_runner, monkeypatch): in_fodf = os.path.join( f"{test_data_root}/fodf_descoteaux07_sub_unified_asym.nii.gz") - ret = script_runner.run('scil_aodf_metrics.py', in_fodf, - '--not_all', '--processes', '1') + ret = script_runner.run(['scil_aodf_metrics', in_fodf, + '--not_all', '--processes', '1']) assert not ret.success @@ -44,10 +44,10 @@ def test_execution_not_all(script_runner, monkeypatch): in_fodf = os.path.join( f"{test_data_root}/fodf_descoteaux07_sub_unified_asym.nii.gz") - ret = script_runner.run('scil_aodf_metrics.py', in_fodf, - '--not_all', '--asi_map', - 'asi_map.nii.gz', '-f', - '--processes', '1') + ret = script_runner.run(['scil_aodf_metrics', in_fodf, + '--not_all', '--asi_map', + 'asi_map.nii.gz', '-f', + '--processes', '1']) assert ret.success @@ -57,9 +57,9 @@ def test_assert_symmetric_input(script_runner, monkeypatch): f"{test_data_root}/fodf_descoteaux07_sub.nii.gz") # Using a low resolution sphere for peak extraction reduces process time - ret = script_runner.run('scil_aodf_metrics.py', in_fodf, - '--sphere', 'repulsion100', - '--processes', '1') + ret = script_runner.run(['scil_aodf_metrics', in_fodf, + '--sphere', 'repulsion100', + '--processes', '1']) assert not ret.success @@ -70,8 +70,8 @@ def test_execution_symmetric_input(script_runner, monkeypatch): # Using a low resolution sphere for peak extraction reduces process time # Using multiprocessing to test this option. - ret = script_runner.run('scil_aodf_metrics.py', in_fodf, - '--sphere', 'repulsion100', '--not_all', - '--nufid', 'nufid.nii.gz', - '--processes', '4') - assert not ret.success + ret = script_runner.run(['scil_aodf_metrics', in_fodf, + '--sphere', 'repulsion100', '--not_all', + '--nufid', 'nufid.nii.gz', + '--processes', '4', '-f']) + assert ret.success diff --git a/scripts/tests/test_bids_validate.py b/src/scilpy/cli/tests/test_bids_validate.py similarity index 93% rename from scripts/tests/test_bids_validate.py rename to src/scilpy/cli/tests/test_bids_validate.py index 09e9765c5..462c73e03 100644 --- a/scripts/tests/test_bids_validate.py +++ b/src/scilpy/cli/tests/test_bids_validate.py @@ -23,7 +23,7 @@ def generate_fake_metadata_json( - intended_for=None, phase_dir=None, readout=None, **kwargs): + intended_for=None, phase_dir=None, readout=None, **kwargs): base_dict = {} if intended_for: @@ -40,18 +40,19 @@ def generate_fake_metadata_json( def generate_image_packet( - data,directory, prefix, - intended_for=None, - phase_dir=None, - readout=None, - **kwargs): + data, directory, prefix, + intended_for=None, + phase_dir=None, + readout=None, + **kwargs): nib.save(nib.Nifti1Image(data, np.eye(4)), os.path.join(directory, "{}.nii.gz".format(prefix))) metadata = generate_fake_metadata_json( intended_for, phase_dir, readout, **kwargs) if metadata: - with open(os.path.join(directory, "{}.json".format(prefix)), "w+") as f: + with open(os.path.join(directory, "{}.json".format(prefix)), + "w+") as f: json.dump(metadata, f) @@ -302,7 +303,7 @@ def generate_fake_bids_structure( return structure_dir -def compare_jsons(json_output, test_dir): +def compare_jsons(json_output, test_dir): # Open test json file with open(os.path.join(test_dir, json_output), 'r') as f: test_json = json.load(f)[0] @@ -310,10 +311,11 @@ def compare_jsons(json_output, test_dir): # Clean test_json for key, value in test_json.items(): if isinstance(value, str): - test_json[key] = value.replace(test_dir + os.path.sep,'') + test_json[key] = value.replace(test_dir + os.path.sep, '') # Open correct json file - result_json = os.path.join(SCILPY_HOME, 'bids_json', json_output.replace('test', 'result')) + result_json = os.path.join( + SCILPY_HOME, 'bids_json', json_output.replace('test', 'result')) with open(result_json, 'r') as f: result = json.load(f)[0] @@ -327,11 +329,10 @@ def compare_jsons(json_output, test_dir): def test_help_option(script_runner): - ret = script_runner.run('scil_bids_validate.py', '--help') + ret = script_runner.run(['scil_bids_validate', '--help']) assert ret.success - @pytest.mark.parametrize( "dwi_is_complex,json_output", [(False, 'test_real_dwi_epi.json'), @@ -345,11 +346,11 @@ def test_bids_epi(tmpdir, script_runner, dwi_is_complex, json_output): gen_epi=True, complex_dwi=dwi_is_complex) - ret = script_runner.run( - 'scil_bids_validate.py', + ret = script_runner.run([ + 'scil_bids_validate', test_dir, os.path.join(test_dir, json_output), - '-f', '-v') + '-f', '-v']) if ret.success: assert compare_jsons(json_output, test_dir) @@ -363,7 +364,7 @@ def test_bids_epi(tmpdir, script_runner, dwi_is_complex, json_output): (True, True, 'test_complex_dwi_complex_sbref.json')] ) def test_bids_sbref( - tmpdir, script_runner, dwi_is_complex, sbref_is_complex, json_output): + tmpdir, script_runner, dwi_is_complex, sbref_is_complex, json_output): test_dir = generate_fake_bids_structure( tmpdir, 1, 1, gen_anat_t1=True, @@ -372,11 +373,11 @@ def test_bids_sbref( complex_dwi=dwi_is_complex, complex_sbref=sbref_is_complex) - ret = script_runner.run( - 'scil_bids_validate.py', + ret = script_runner.run([ + 'scil_bids_validate', test_dir, os.path.join(test_dir, json_output), - '-f', '-v') + '-f', '-v']) if ret.success: assert compare_jsons(json_output, test_dir) @@ -390,7 +391,7 @@ def test_bids_sbref( (True, True, 'test_complex_dwi_complex_rev_dwi.json')] ) def test_bids_rev_dwi( - tmpdir, script_runner, dwi_is_complex, rev_is_complex, json_output): + tmpdir, script_runner, dwi_is_complex, rev_is_complex, json_output): test_dir = generate_fake_bids_structure( tmpdir, 1, 1, gen_anat_t1=True, @@ -398,11 +399,11 @@ def test_bids_rev_dwi( complex_dwi=dwi_is_complex, complex_rev_dwi=rev_is_complex) - ret = script_runner.run( - 'scil_bids_validate.py', + ret = script_runner.run([ + 'scil_bids_validate', test_dir, os.path.join(test_dir, json_output), - '-f', '-v') + '-f', '-v']) if ret.success: assert compare_jsons(json_output, test_dir) @@ -416,7 +417,7 @@ def test_bids_rev_dwi( (True, True, 'test_complex_dwi_complex_rev_dwi_sbref.json')] ) def test_bids_rev_dwi_sbref( - tmpdir, script_runner, dwi_is_complex, rev_is_complex, json_output): + tmpdir, script_runner, dwi_is_complex, rev_is_complex, json_output): test_dir = generate_fake_bids_structure( tmpdir, 1, 1, gen_anat_t1=True, @@ -426,11 +427,11 @@ def test_bids_rev_dwi_sbref( complex_dwi=dwi_is_complex, complex_rev_dwi=rev_is_complex) - ret = script_runner.run( - 'scil_bids_validate.py', + ret = script_runner.run([ + 'scil_bids_validate', test_dir, os.path.join(test_dir, json_output), - '-f', '-v') + '-f', '-v']) if ret.success: assert compare_jsons(json_output, test_dir) diff --git a/scripts/tests/test_bingham_metrics.py b/src/scilpy/cli/tests/test_bingham_metrics.py similarity index 63% rename from scripts/tests/test_bingham_metrics.py rename to src/scilpy/cli/tests/test_bingham_metrics.py index d46b533d9..d6e9e72ff 100644 --- a/scripts/tests/test_bingham_metrics.py +++ b/src/scilpy/cli/tests/test_bingham_metrics.py @@ -13,8 +13,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_bingham_metrics.py', - '--help') + ret = script_runner.run(['scil_bingham_metrics', + '--help']) assert ret.success @@ -23,9 +23,9 @@ def test_execution_processing(script_runner, monkeypatch): in_bingham = os.path.join(SCILPY_HOME, 'processing', 'fodf_bingham.nii.gz') - ret = script_runner.run('scil_bingham_metrics.py', - in_bingham, '--nbr_integration_steps', '10', - '--processes', '1') + ret = script_runner.run(['scil_bingham_metrics', + in_bingham, '--nbr_integration_steps', '10', + '--processes', '1']) assert ret.success @@ -37,9 +37,9 @@ def test_execution_processing_mask(script_runner, monkeypatch): in_mask = os.path.join(SCILPY_HOME, 'processing', 'seed.nii.gz') - ret = script_runner.run('scil_bingham_metrics.py', - in_bingham, '--nbr_integration_steps', '10', - '--processes', '1', '--mask', in_mask, '-f') + ret = script_runner.run(['scil_bingham_metrics', + in_bingham, '--nbr_integration_steps', '10', + '--processes', '1', '--mask', in_mask, '-f']) assert ret.success @@ -49,9 +49,9 @@ def test_execution_processing_not_all(script_runner, monkeypatch): in_bingham = os.path.join(SCILPY_HOME, 'processing', 'fodf_bingham.nii.gz') - ret = script_runner.run('scil_bingham_metrics.py', - in_bingham, '--nbr_integration_steps', '10', - '--processes', '1', '--not_all', '--out_fs', - 'fs.nii.gz', '-f') + ret = script_runner.run(['scil_bingham_metrics', + in_bingham, '--nbr_integration_steps', '10', + '--processes', '1', '--not_all', '--out_fs', + 'fs.nii.gz', '-f']) assert ret.success diff --git a/scripts/tests/test_btensor_metrics.py b/src/scilpy/cli/tests/test_btensor_metrics.py similarity index 55% rename from scripts/tests/test_btensor_metrics.py rename to src/scilpy/cli/tests/test_btensor_metrics.py index e79e1ce0b..b25e4d49c 100644 --- a/scripts/tests/test_btensor_metrics.py +++ b/src/scilpy/cli/tests/test_btensor_metrics.py @@ -12,7 +12,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_btensor_metrics.py', '--help') + ret = script_runner.run(['scil_btensor_metrics', '--help']) assert ret.success @@ -33,21 +33,22 @@ def test_nb_btensors_check(script_runner, monkeypatch): fa = os.path.join(SCILPY_HOME, 'btensor', 'fa.nii.gz') - ret = script_runner.run('scil_btensor_metrics.py', '--in_dwis', - in_dwi_lin, '--in_bvals', in_bval_lin, - '--in_bvecs', in_bvec_lin, '--in_bdeltas', '1', - '--fa', fa, '--do_weight_bvals', - '--do_weight_pa', '--do_multiple_s0', - '--processes', '1', '-f') + ret = script_runner.run(['scil_btensor_metrics', '--in_dwis', + in_dwi_lin, '--in_bvals', in_bval_lin, + '--in_bvecs', in_bvec_lin, '--in_bdeltas', '1', + '--fa', fa, '--do_weight_bvals', + '--do_weight_pa', '--do_multiple_s0', + '--processes', '1', '-f']) assert (not ret.success) - ret = script_runner.run('scil_btensor_metrics.py', '--in_dwis', - in_dwi_lin, in_dwi_plan, '--in_bvals', in_bval_lin, - in_bval_plan, '--in_bvecs', in_bvec_lin, - in_bvec_plan, '--in_bdeltas', '1', '1', - '--fa', fa, '--do_weight_bvals', - '--do_weight_pa', '--do_multiple_s0', - '--processes', '1', '-f') + ret = script_runner.run(['scil_btensor_metrics', '--in_dwis', + in_dwi_lin, in_dwi_plan, + '--in_bvals', in_bval_lin, + in_bval_plan, '--in_bvecs', in_bvec_lin, + in_bvec_plan, '--in_bdeltas', '1', '1', + '--fa', fa, '--do_weight_bvals', + '--do_weight_pa', '--do_multiple_s0', + '--processes', '1', '-f']) assert (not ret.success) @@ -68,30 +69,31 @@ def test_inputs_check(script_runner, monkeypatch): fa = os.path.join(SCILPY_HOME, 'btensor', 'fa.nii.gz') - ret = script_runner.run('scil_btensor_metrics.py', '--in_dwis', - in_dwi_lin, in_dwi_plan, '--in_bvals', in_bval_lin, - '--in_bvecs', in_bvec_lin, '--in_bdeltas', '1', - '--fa', fa, '--do_weight_bvals', - '--do_weight_pa', '--do_multiple_s0', - '--processes', '1', '-f') + ret = script_runner.run(['scil_btensor_metrics', '--in_dwis', + in_dwi_lin, in_dwi_plan, + '--in_bvals', in_bval_lin, + '--in_bvecs', in_bvec_lin, '--in_bdeltas', '1', + '--fa', fa, '--do_weight_bvals', + '--do_weight_pa', '--do_multiple_s0', + '--processes', '1', '-f']) assert (not ret.success) - ret = script_runner.run('scil_btensor_metrics.py', '--in_dwis', - in_dwi_lin, in_dwi_plan, '--in_bvals', - in_bval_lin, in_bval_plan, '--in_bvecs', - in_bvec_lin, in_bvec_plan, '--in_bdeltas', '1', - '-0.5', '0', '--fa', fa, '--do_weight_bvals', - '--do_weight_pa', '--do_multiple_s0', - '--processes', '1', '-f') + ret = script_runner.run(['scil_btensor_metrics', '--in_dwis', + in_dwi_lin, in_dwi_plan, '--in_bvals', + in_bval_lin, in_bval_plan, '--in_bvecs', + in_bvec_lin, in_bvec_plan, '--in_bdeltas', '1', + '-0.5', '0', '--fa', fa, '--do_weight_bvals', + '--do_weight_pa', '--do_multiple_s0', + '--processes', '1', '-f']) assert (not ret.success) - ret = script_runner.run('scil_btensor_metrics.py', '--in_dwis', - in_dwi_lin, in_dwi_plan, '--in_bvals', - in_bval_lin, in_bval_plan, '--in_bvecs', - in_bvec_lin, in_bvec_plan, '--in_bdeltas', '1', - '-0.5', '--op', fa, '--do_weight_bvals', - '--do_weight_pa', '--do_multiple_s0', - '--processes', '1', '-f') + ret = script_runner.run(['scil_btensor_metrics', '--in_dwis', + in_dwi_lin, in_dwi_plan, '--in_bvals', + in_bval_lin, in_bval_plan, '--in_bvecs', + in_bvec_lin, in_bvec_plan, '--in_bdeltas', '1', + '-0.5', '--op', fa, '--do_weight_bvals', + '--do_weight_pa', '--do_multiple_s0', + '--processes', '1', '-f']) assert (not ret.success) @@ -118,12 +120,12 @@ def test_execution_processing(script_runner, monkeypatch): fa = os.path.join(SCILPY_HOME, 'btensor_testdata', 'fa.nii.gz') - ret = script_runner.run('scil_btensor_metrics.py', '--in_dwis', - in_dwi_lin, in_dwi_plan, in_dwi_sph, - '--in_bvals', in_bval_lin, in_bval_plan, - in_bval_sph, '--in_bvecs', in_bvec_lin, - in_bvec_plan, in_bvec_sph, '--in_bdeltas', - '1', '-0.5', '0', '--fa', fa, '--do_weight_bvals', - '--do_weight_pa', '--do_multiple_s0', - '--processes', '1', '-f') + ret = script_runner.run(['scil_btensor_metrics', '--in_dwis', + in_dwi_lin, in_dwi_plan, in_dwi_sph, + '--in_bvals', in_bval_lin, in_bval_plan, + in_bval_sph, '--in_bvecs', in_bvec_lin, + in_bvec_plan, in_bvec_sph, '--in_bdeltas', + '1', '-0.5', '0', '--fa', fa, '--do_weight_bvals', + '--do_weight_pa', '--do_multiple_s0', + '--processes', '1', '-f']) assert (ret.success) diff --git a/scripts/tests/test_bundle_alter_to_target_dice.py b/src/scilpy/cli/tests/test_bundle_alter_to_target_dice.py similarity index 53% rename from scripts/tests/test_bundle_alter_to_target_dice.py rename to src/scilpy/cli/tests/test_bundle_alter_to_target_dice.py index c2e476787..6f387cf4d 100644 --- a/scripts/tests/test_bundle_alter_to_target_dice.py +++ b/src/scilpy/cli/tests/test_bundle_alter_to_target_dice.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_bundle_alter_to_target_dice.py', '--help') + ret = script_runner.run(['scil_bundle_alter_to_target_dice', '--help']) assert ret.success @@ -21,10 +21,10 @@ def test_execution_subsample(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM_uni.trk') - ret = script_runner.run('scil_bundle_alter_to_target_dice.py', - in_bundle, 'out_tractogram_subsample.trk', - '--min_dice', '0.75', '--epsilon', '0.01', - '--subsample', '--shuffle', '-v') + ret = script_runner.run(['scil_bundle_alter_to_target_dice', + in_bundle, 'out_tractogram_subsample.trk', + '--min_dice', '0.75', '--epsilon', '0.01', + '--subsample', '--shuffle', '-v']) assert ret.success @@ -32,10 +32,10 @@ def test_execution_trim(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM_uni.trk') - ret = script_runner.run('scil_bundle_alter_to_target_dice.py', - in_bundle, 'out_tractogram_trim.trk', - '--min_dice', '0.75', '--epsilon', '0.01', - '--trim', '-v') + ret = script_runner.run(['scil_bundle_alter_to_target_dice', + in_bundle, 'out_tractogram_trim.trk', + '--min_dice', '0.75', '--epsilon', '0.01', + '--trim', '-v']) assert ret.success @@ -43,10 +43,10 @@ def test_execution_cut(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM_uni.trk') - ret = script_runner.run('scil_bundle_alter_to_target_dice.py', - in_bundle, 'out_tractogram_cut.trk', - '--min_dice', '0.75', '--epsilon', '0.01', - '--cut', '-v', 'DEBUG') + ret = script_runner.run(['scil_bundle_alter_to_target_dice', + in_bundle, 'out_tractogram_cut.trk', + '--min_dice', '0.75', '--epsilon', '0.01', + '--cut', '-v', 'DEBUG']) assert ret.success @@ -54,10 +54,10 @@ def test_execution_replace(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM_uni.trk') - ret = script_runner.run('scil_bundle_alter_to_target_dice.py', - in_bundle, 'out_tractogram_replace.trk', - '--min_dice', '0.75', '--epsilon', '0.01', - '--replace', '-v') + ret = script_runner.run(['scil_bundle_alter_to_target_dice', + in_bundle, 'out_tractogram_replace.trk', + '--min_dice', '0.75', '--epsilon', '0.01', + '--replace', '-v']) assert ret.success @@ -65,10 +65,10 @@ def test_execution_transform(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM_uni.trk') - ret = script_runner.run('scil_bundle_alter_to_target_dice.py', - in_bundle, 'out_tractogram_transform.trk', - '--min_dice', '0.75', '--epsilon', '0.01', - '--transform', '--save_transform', - 'transform.txt', '-v') + ret = script_runner.run(['scil_bundle_alter_to_target_dice', + in_bundle, 'out_tractogram_transform.trk', + '--min_dice', '0.75', '--epsilon', '0.01', + '--transform', '--save_transform', + 'transform.txt', '-v']) assert ret.success assert os.path.isfile('transform.txt') diff --git a/src/scilpy/cli/tests/test_bundle_clean_qbx_clusters.py b/src/scilpy/cli/tests/test_bundle_clean_qbx_clusters.py new file mode 100644 index 000000000..4d6895180 --- /dev/null +++ b/src/scilpy/cli/tests/test_bundle_clean_qbx_clusters.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +def test_help_option(script_runner): + ret = script_runner.run(['scil_json_harmonize_entries', '--help']) + assert ret.success diff --git a/scripts/tests/test_bundle_compute_centroid.py b/src/scilpy/cli/tests/test_bundle_compute_centroid.py similarity index 76% rename from scripts/tests/test_bundle_compute_centroid.py rename to src/scilpy/cli/tests/test_bundle_compute_centroid.py index 227354517..703f38e52 100644 --- a/scripts/tests/test_bundle_compute_centroid.py +++ b/src/scilpy/cli/tests/test_bundle_compute_centroid.py @@ -13,13 +13,13 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_bundle_compute_centroid.py', '--help') + ret = script_runner.run(['scil_bundle_compute_centroid', '--help']) assert ret.success def test_execution_tractometry(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM_uni.trk') - ret = script_runner.run('scil_bundle_compute_centroid.py', - in_bundle, 'IFGWM_uni_c.trk') + ret = script_runner.run(['scil_bundle_compute_centroid', + in_bundle, 'IFGWM_uni_c.trk']) assert ret.success diff --git a/scripts/tests/test_bundle_compute_endpoints_map.py b/src/scilpy/cli/tests/test_bundle_compute_endpoints_map.py similarity index 65% rename from scripts/tests/test_bundle_compute_endpoints_map.py rename to src/scilpy/cli/tests/test_bundle_compute_endpoints_map.py index 041a9f436..eba75e4f5 100644 --- a/scripts/tests/test_bundle_compute_endpoints_map.py +++ b/src/scilpy/cli/tests/test_bundle_compute_endpoints_map.py @@ -13,15 +13,15 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_bundle_compute_endpoints_map.py', '--help') + ret = script_runner.run(['scil_bundle_compute_endpoints_map', '--help']) assert ret.success def test_execution_tractometry(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM_uni.trk') - ret = script_runner.run('scil_bundle_compute_endpoints_map.py', in_bundle, - 'head.nii.gz', 'tail.nii.gz', '--binary', '-f') + ret = script_runner.run(['scil_bundle_compute_endpoints_map', in_bundle, + 'head.nii.gz', 'tail.nii.gz', '--binary', '-f']) assert ret.success @@ -29,8 +29,8 @@ def test_execution_tractometry(script_runner, monkeypatch): def test_execution_tractometry_mm_distance5(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM_uni.trk') - ret = script_runner.run('scil_bundle_compute_endpoints_map.py', in_bundle, - 'head.nii.gz', 'tail.nii.gz', '--binary', - '--distance', '5', '--unit', 'mm', '-f') + ret = script_runner.run(['scil_bundle_compute_endpoints_map', in_bundle, + 'head.nii.gz', 'tail.nii.gz', '--binary', + '--distance', '5', '--unit', 'mm', '-f']) assert ret.success diff --git a/scripts/tests/test_bundle_diameter.py b/src/scilpy/cli/tests/test_bundle_diameter.py similarity index 72% rename from scripts/tests/test_bundle_diameter.py rename to src/scilpy/cli/tests/test_bundle_diameter.py index 172a09270..e82adbc66 100644 --- a/scripts/tests/test_bundle_diameter.py +++ b/src/scilpy/cli/tests/test_bundle_diameter.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_bundle_diameter.py', '--help') + ret = script_runner.run(['scil_bundle_diameter', '--help']) assert ret.success @@ -22,6 +22,7 @@ def test_execution_tractometry(script_runner, monkeypatch): in_bundle = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM.trk') in_labels = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM_labels_map.nii.gz') - ret = script_runner.run('scil_bundle_diameter.py', in_bundle, in_labels, - '--wireframe', '--fitting_func', 'lin_up') + ret = script_runner.run(['scil_bundle_diameter', in_bundle, in_labels, + '--wireframe', '--fitting_func', 'lin_up', + '--save_rendering', tmp_dir.name]) assert ret.success diff --git a/src/scilpy/cli/tests/test_bundle_explore_bundleseg.py b/src/scilpy/cli/tests/test_bundle_explore_bundleseg.py new file mode 100644 index 000000000..c1072f385 --- /dev/null +++ b/src/scilpy/cli/tests/test_bundle_explore_bundleseg.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + + +def test_help_option(script_runner): + ret = script_runner.run(['scil_bundle_explore_bundleseg', '--help']) + assert ret.success diff --git a/scripts/tests/test_bundle_filter_by_occurence.py b/src/scilpy/cli/tests/test_bundle_filter_by_occurence.py similarity index 80% rename from scripts/tests/test_bundle_filter_by_occurence.py rename to src/scilpy/cli/tests/test_bundle_filter_by_occurence.py index 89386a49c..92781ba6d 100644 --- a/scripts/tests/test_bundle_filter_by_occurence.py +++ b/src/scilpy/cli/tests/test_bundle_filter_by_occurence.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_bundle_filter_by_occurence.py', '--help') + ret = script_runner.run(['scil_bundle_filter_by_occurence', '--help']) assert ret.success @@ -25,7 +25,7 @@ def test_execution(script_runner, monkeypatch): 'bundle_4_filtered_no_loops.trk') prefix = 'test_voting_' - ret = script_runner.run('scil_bundle_filter_by_occurence.py', in_1, in_2, + ret = script_runner.run(['scil_bundle_filter_by_occurence', in_1, in_2, in_3, prefix, '--ratio_streamlines', '0.5', - '--ratio_voxels', '0.5') + '--ratio_voxels', '0.5']) assert ret.success diff --git a/scripts/tests/test_bundle_fixel_analysis.py b/src/scilpy/cli/tests/test_bundle_fixel_analysis.py similarity index 66% rename from scripts/tests/test_bundle_fixel_analysis.py rename to src/scilpy/cli/tests/test_bundle_fixel_analysis.py index 21101de10..7636daf04 100644 --- a/scripts/tests/test_bundle_fixel_analysis.py +++ b/src/scilpy/cli/tests/test_bundle_fixel_analysis.py @@ -12,7 +12,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_bundle_fixel_analysis.py', '--help') + ret = script_runner.run(['scil_bundle_fixel_analysis', '--help']) assert ret.success @@ -22,9 +22,9 @@ def test_default_parameters(script_runner, monkeypatch): in_bundle = os.path.join(SCILPY_HOME, 'commit_amico', 'tracking.trk') # Using multiprocessing in this test, single in following tests. - ret = script_runner.run('scil_bundle_fixel_analysis.py', in_peaks, - '--in_bundles', in_bundle, - '--processes', '4', '-f') + ret = script_runner.run(['scil_bundle_fixel_analysis', in_peaks, + '--in_bundles', in_bundle, + '--processes', '4', '-f']) assert ret.success @@ -33,15 +33,15 @@ def test_all_parameters(script_runner, monkeypatch): in_peaks = os.path.join(SCILPY_HOME, 'commit_amico', 'peaks.nii.gz') in_bundle = os.path.join(SCILPY_HOME, 'commit_amico', 'tracking.trk') - ret = script_runner.run('scil_bundle_fixel_analysis.py', in_peaks, - '--in_bundles', in_bundle, - '--in_bundles_names', 'test', - '--abs_thr', '5', - '--rel_thr', '0.05', - '--norm', 'fixel', - '--split_bundles', '--split_fixels', - '--single_bundle', - '--processes', '1', '-f') + ret = script_runner.run(['scil_bundle_fixel_analysis', in_peaks, + '--in_bundles', in_bundle, + '--in_bundles_names', 'test', + '--abs_thr', '5', + '--rel_thr', '0.05', + '--norm', 'fixel', + '--split_bundles', '--split_fixels', + '--single_bundle', + '--processes', '1', '-f']) assert ret.success @@ -50,16 +50,16 @@ def test_multiple_norm(script_runner, monkeypatch): in_peaks = os.path.join(SCILPY_HOME, 'commit_amico', 'peaks.nii.gz') in_bundle = os.path.join(SCILPY_HOME, 'commit_amico', 'tracking.trk') - ret = script_runner.run('scil_bundle_fixel_analysis.py', in_peaks, - '--in_bundles', in_bundle, - '--in_bundles_names', 'test', - '--abs_thr', '5', - '--rel_thr', '0.05', - '--norm', 'fixel', 'none', 'voxel', - '--split_bundles', '--split_fixels', - '--single_bundle', - '--out_dir', '.', - '--processes', '1', '-f') + ret = script_runner.run(['scil_bundle_fixel_analysis', in_peaks, + '--in_bundles', in_bundle, + '--in_bundles_names', 'test', + '--abs_thr', '5', + '--rel_thr', '0.05', + '--norm', 'fixel', 'none', 'voxel', + '--split_bundles', '--split_fixels', + '--single_bundle', + '--out_dir', '.', + '--processes', '1', '-f']) assert ret.success assert os.path.isfile('bundles_LUT.txt') for n in ['voxel', 'fixel', 'none']: @@ -77,7 +77,7 @@ def test_multiple_norm(script_runner, monkeypatch): 'norm_WM.nii.gz'.format(n)) assert os.path.isfile('single_bundle_mask_{}-' 'norm_test.nii.gz'.format(n)) - + assert os.path.isfile('voxel_density_maps_voxel-norm.nii.gz') assert not os.path.isfile('voxel_density_maps_fixel-norm.nii.gz') assert os.path.isfile('voxel_density_maps_none-norm.nii.gz') diff --git a/scripts/tests/test_bundle_generate_priors.py b/src/scilpy/cli/tests/test_bundle_generate_priors.py similarity index 68% rename from scripts/tests/test_bundle_generate_priors.py rename to src/scilpy/cli/tests/test_bundle_generate_priors.py index 426bef83d..8c636346e 100644 --- a/scripts/tests/test_bundle_generate_priors.py +++ b/src/scilpy/cli/tests/test_bundle_generate_priors.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_bundle_generate_priors.py', '--help') + ret = script_runner.run(['scil_bundle_generate_priors', '--help']) assert ret.success @@ -22,8 +22,8 @@ def test_execution_bst(script_runner, monkeypatch): in_bundle = os.path.join(SCILPY_HOME, 'bst', 'rpt_m_lin.trk') in_fodf = os.path.join(SCILPY_HOME, 'bst', 'fodf.nii.gz') in_mask = os.path.join(SCILPY_HOME, 'bst', 'mask.nii.gz') - ret = script_runner.run('scil_bundle_generate_priors.py', - in_bundle, in_fodf, in_mask, - '--todi_sigma', '1', '--out_prefix', 'rpt_m', - '--sh_basis', 'descoteaux07') + ret = script_runner.run(['scil_bundle_generate_priors', + in_bundle, in_fodf, in_mask, + '--todi_sigma', '1', '--out_prefix', 'rpt_m', + '--sh_basis', 'descoteaux07']) assert ret.success diff --git a/scripts/tests/test_bundle_label_map.py b/src/scilpy/cli/tests/test_bundle_label_map.py similarity index 67% rename from scripts/tests/test_bundle_label_map.py rename to src/scilpy/cli/tests/test_bundle_label_map.py index 797ec6f39..1da506c51 100644 --- a/scripts/tests/test_bundle_label_map.py +++ b/src/scilpy/cli/tests/test_bundle_label_map.py @@ -14,7 +14,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_bundle_label_map.py', '--help') + ret = script_runner.run(['scil_bundle_label_map', '--help']) assert ret.success @@ -24,10 +24,10 @@ def test_execution_tractometry_euclidian(script_runner, monkeypatch): 'IFGWM.trk') in_centroid = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM_uni_c_10.trk') - ret = script_runner.run('scil_bundle_label_map.py', - in_bundle, in_centroid, - 'results_euc/', - '--colormap', 'viridis') + ret = script_runner.run(['scil_bundle_label_map', + in_bundle, in_centroid, + 'results_euc/', + '--colormap', 'viridis']) assert ret.success @@ -37,9 +37,9 @@ def test_execution_tractometry_hyperplane(script_runner, monkeypatch): 'IFGWM.trk') in_centroid = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM_uni_c_10.trk') - ret = script_runner.run('scil_bundle_label_map.py', - in_bundle, in_centroid, - 'results_man/', - '--colormap', 'viridis', - '--hyperplane', '--use_manhattan') + ret = script_runner.run(['scil_bundle_label_map', + in_bundle, in_centroid, + 'results_man/', + '--colormap', 'viridis', + '--hyperplane', '--use_manhattan']) assert ret.success diff --git a/scripts/tests/test_bundle_mean_fixel_afd.py b/src/scilpy/cli/tests/test_bundle_mean_fixel_afd.py similarity index 70% rename from scripts/tests/test_bundle_mean_fixel_afd.py rename to src/scilpy/cli/tests/test_bundle_mean_fixel_afd.py index b9877ff3e..405a8903d 100644 --- a/scripts/tests/test_bundle_mean_fixel_afd.py +++ b/src/scilpy/cli/tests/test_bundle_mean_fixel_afd.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_bundle_mean_fixel_afd.py', '--help') + ret = script_runner.run(['scil_bundle_mean_fixel_afd', '--help']) assert ret.success @@ -22,7 +22,8 @@ def test_execution_processing(script_runner, monkeypatch): in_tracking = os.path.join(SCILPY_HOME, 'processing', 'tracking.trk') in_fodf = os.path.join(SCILPY_HOME, 'processing', 'fodf_descoteaux07.nii.gz') - ret = script_runner.run('scil_bundle_mean_fixel_afd.py', in_tracking, - in_fodf, 'afd_test.nii.gz', - '--sh_basis', 'descoteaux07', '--length_weighting') + ret = script_runner.run(['scil_bundle_mean_fixel_afd', in_tracking, + in_fodf, 'afd_test.nii.gz', + '--sh_basis', 'descoteaux07', + '--length_weighting']) assert ret.success diff --git a/scripts/tests/test_bundle_mean_fixel_afd_from_hdf5.py b/src/scilpy/cli/tests/test_bundle_mean_fixel_afd_from_hdf5.py similarity index 62% rename from scripts/tests/test_bundle_mean_fixel_afd_from_hdf5.py rename to src/scilpy/cli/tests/test_bundle_mean_fixel_afd_from_hdf5.py index 000699955..804a10128 100644 --- a/scripts/tests/test_bundle_mean_fixel_afd_from_hdf5.py +++ b/src/scilpy/cli/tests/test_bundle_mean_fixel_afd_from_hdf5.py @@ -13,8 +13,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_bundle_mean_fixel_afd_from_hdf5.py', - '--help') + ret = script_runner.run(['scil_bundle_mean_fixel_afd_from_hdf5', + '--help']) assert ret.success @@ -22,8 +22,9 @@ def test_execution_connectivity(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_h5 = os.path.join(SCILPY_HOME, 'connectivity', 'decompose.h5') in_fodf = os.path.join(SCILPY_HOME, 'connectivity', 'fodf.nii.gz') - ret = script_runner.run('scil_bundle_mean_fixel_afd_from_hdf5.py', - in_h5, in_fodf, 'decompose_afd.nii.gz', - '--length_weighting', '--sh_basis', 'descoteaux07', - '--processes', '1') + ret = script_runner.run(['scil_bundle_mean_fixel_afd_from_hdf5', + in_h5, in_fodf, 'decompose_afd.nii.gz', + '--length_weighting', + '--sh_basis', 'descoteaux07', + '--processes', '1']) assert ret.success diff --git a/scripts/tests/test_bundle_mean_fixel_bingham_metric.py b/src/scilpy/cli/tests/test_bundle_mean_fixel_bingham_metric.py similarity index 78% rename from scripts/tests/test_bundle_mean_fixel_bingham_metric.py rename to src/scilpy/cli/tests/test_bundle_mean_fixel_bingham_metric.py index 929cef9c2..c1f95ffa9 100644 --- a/scripts/tests/test_bundle_mean_fixel_bingham_metric.py +++ b/src/scilpy/cli/tests/test_bundle_mean_fixel_bingham_metric.py @@ -13,8 +13,8 @@ def test_help_option(script_runner): - ret = script_runner.run( - 'scil_bundle_mean_fixel_bingham_metric.py', '--help') + ret = script_runner.run([ + 'scil_bundle_mean_fixel_bingham_metric', '--help']) assert ret.success @@ -25,9 +25,9 @@ def test_execution_processing(script_runner, monkeypatch): in_metric = os.path.join(SCILPY_HOME, 'processing', 'fd.nii.gz') in_bundles = os.path.join(SCILPY_HOME, 'processing', 'tracking.trk') - ret = script_runner.run( - 'scil_bundle_mean_fixel_bingham_metric.py', + ret = script_runner.run([ + 'scil_bundle_mean_fixel_bingham_metric', in_bundles, in_bingham, in_metric, - 'fixel_mean_fd.nii.gz', '--length_weighting') + 'fixel_mean_fd.nii.gz', '--length_weighting']) assert ret.success diff --git a/scripts/tests/test_bundle_clean_qbx_clusters.py b/src/scilpy/cli/tests/test_bundle_mean_fixel_mrds_metric.py similarity index 55% rename from scripts/tests/test_bundle_clean_qbx_clusters.py rename to src/scilpy/cli/tests/test_bundle_mean_fixel_mrds_metric.py index 53df060a1..5013a9a07 100644 --- a/scripts/tests/test_bundle_clean_qbx_clusters.py +++ b/src/scilpy/cli/tests/test_bundle_mean_fixel_mrds_metric.py @@ -1,7 +1,8 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- - def test_help_option(script_runner): - ret = script_runner.run('scil_bundle_clean_qbx_clusters.py', '--help') + ret = script_runner.run([ + 'scil_bundle_mean_fixel_mrds_metric', '--help']) + assert ret.success diff --git a/scripts/tests/test_bundle_mean_std.py b/src/scilpy/cli/tests/test_bundle_mean_std.py similarity index 84% rename from scripts/tests/test_bundle_mean_std.py rename to src/scilpy/cli/tests/test_bundle_mean_std.py index bbd484cd0..4e3e11872 100644 --- a/scripts/tests/test_bundle_mean_std.py +++ b/src/scilpy/cli/tests/test_bundle_mean_std.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_bundle_mean_std.py', '--help') + ret = script_runner.run(['scil_bundle_mean_std', '--help']) assert ret.success @@ -21,8 +21,8 @@ def test_execution_tractometry_whole(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM.trk') in_ref = os.path.join(SCILPY_HOME, 'tractometry', 'mni_masked.nii.gz') - ret = script_runner.run('scil_bundle_mean_std.py', in_bundle, in_ref, - '--density_weighting', '--include_dps') + ret = script_runner.run(['scil_bundle_mean_std', in_bundle, in_ref, + '--density_weighting', '--include_dps']) assert ret.success @@ -32,7 +32,7 @@ def test_execution_tractometry_per_point(script_runner, monkeypatch): in_label = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM_labels_map.nii.gz') in_ref = os.path.join(SCILPY_HOME, 'tractometry', 'mni_masked.nii.gz') - ret = script_runner.run('scil_bundle_mean_std.py', in_bundle, in_ref, - '--per_point', in_label, '--density_weighting') + ret = script_runner.run(['scil_bundle_mean_std', in_bundle, in_ref, + '--per_point', in_label, '--density_weighting']) assert ret.success diff --git a/scripts/tests/test_bundle_pairwise_comparison.py b/src/scilpy/cli/tests/test_bundle_pairwise_comparison.py similarity index 83% rename from scripts/tests/test_bundle_pairwise_comparison.py rename to src/scilpy/cli/tests/test_bundle_pairwise_comparison.py index 131980840..2d36417c1 100644 --- a/scripts/tests/test_bundle_pairwise_comparison.py +++ b/src/scilpy/cli/tests/test_bundle_pairwise_comparison.py @@ -13,8 +13,8 @@ def test_help_option(script_runner): - ret = script_runner.run( - 'scil_bundle_pairwise_comparison.py', '--help') + ret = script_runner.run([ + 'scil_bundle_pairwise_comparison', '--help']) assert ret.success @@ -24,11 +24,11 @@ def test_execution_bundles(script_runner, monkeypatch): in_2 = os.path.join(SCILPY_HOME, 'bundles', 'voting_results', 'bundle_0.trk') in_ref = os.path.join(SCILPY_HOME, 'bundles', 'bundle_all_1mm.nii.gz') - ret = script_runner.run( - 'scil_bundle_pairwise_comparison.py', + ret = script_runner.run([ + 'scil_bundle_pairwise_comparison', in_1, in_2, 'AF_L_similarity.json', '--streamline_dice', '--reference', in_ref, - '--processes', '1') + '--processes', '1']) assert ret.success @@ -38,12 +38,12 @@ def test_single(script_runner, monkeypatch): in_2 = os.path.join(SCILPY_HOME, 'bundles', 'voting_results', 'bundle_0.trk') in_ref = os.path.join(SCILPY_HOME, 'bundles', 'bundle_all_1mm.nii.gz') - ret = script_runner.run( - 'scil_bundle_pairwise_comparison.py', + ret = script_runner.run([ + 'scil_bundle_pairwise_comparison', in_2, 'AF_L_similarity_single.json', '--streamline_dice', '--reference', in_ref, '--single_compare', in_1, - '--processes', '1') + '--processes', '1']) assert ret.success @@ -53,12 +53,12 @@ def test_no_overlap(script_runner, monkeypatch): in_2 = os.path.join(SCILPY_HOME, 'bundles', 'voting_results', 'bundle_0.trk') in_ref = os.path.join(SCILPY_HOME, 'bundles', 'bundle_all_1mm.nii.gz') - ret = script_runner.run( - 'scil_bundle_pairwise_comparison.py', in_1, + ret = script_runner.run([ + 'scil_bundle_pairwise_comparison', in_1, in_2, 'AF_L_similarity_no_overlap.json', '--streamline_dice', '--reference', in_ref, '--ignore_zeros_in_BA', - '--processes', '1') + '--processes', '1']) assert ret.success @@ -68,13 +68,13 @@ def test_ratio(script_runner, monkeypatch): in_2 = os.path.join(SCILPY_HOME, 'bundles', 'voting_results', 'bundle_0.trk') in_ref = os.path.join(SCILPY_HOME, 'bundles', 'bundle_all_1mm.nii.gz') - ret = script_runner.run( - 'scil_bundle_pairwise_comparison.py', + ret = script_runner.run([ + 'scil_bundle_pairwise_comparison', in_2, 'AF_L_similarity_ratio.json', '--streamline_dice', '--reference', in_ref, '--single_compare', in_1, '--processes', '1', - '--ratio') + '--ratio']) assert ret.success @@ -87,10 +87,10 @@ def test_ratio_fail(script_runner, monkeypatch): in_2 = os.path.join(SCILPY_HOME, 'bundles', 'voting_results', 'bundle_0.trk') in_ref = os.path.join(SCILPY_HOME, 'bundles', 'bundle_all_1mm.nii.gz') - ret = script_runner.run( - 'scil_bundle_pairwise_comparison.py', + ret = script_runner.run([ + 'scil_bundle_pairwise_comparison', in_1, in_2, 'AF_L_similarity_fail.json', '--streamline_dice', '--reference', in_ref, '--processes', '1', - '--ratio') + '--ratio']) assert not ret.success diff --git a/scripts/tests/test_bundle_reject_outliers.py b/src/scilpy/cli/tests/test_bundle_reject_outliers.py similarity index 61% rename from scripts/tests/test_bundle_reject_outliers.py rename to src/scilpy/cli/tests/test_bundle_reject_outliers.py index 47f3f4d51..5d050b6ad 100644 --- a/scripts/tests/test_bundle_reject_outliers.py +++ b/src/scilpy/cli/tests/test_bundle_reject_outliers.py @@ -13,16 +13,16 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_bundle_reject_outliers.py', '--help') + ret = script_runner.run(['scil_bundle_reject_outliers', '--help']) assert ret.success def test_execution_filtering(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'filtering', 'bundle_all_1mm.trk') - ret = script_runner.run('scil_bundle_reject_outliers.py', in_bundle, - 'inliers.trk', '--alpha', '0.6', - '--remaining_bundle', 'outliers.trk', - '--display_counts', '--indent', '4', - '--sort_keys') + ret = script_runner.run(['scil_bundle_reject_outliers', in_bundle, + 'inliers.trk', '--alpha', '0.6', + '--remaining_bundle', 'outliers.trk', + '--display_counts', '--indent', '4', + '--sort_keys']) assert ret.success diff --git a/scripts/tests/test_bundle_score_many_bundles_one_tractogram.py b/src/scilpy/cli/tests/test_bundle_score_many_bundles_one_tractogram.py similarity index 87% rename from scripts/tests/test_bundle_score_many_bundles_one_tractogram.py rename to src/scilpy/cli/tests/test_bundle_score_many_bundles_one_tractogram.py index 82cd62c37..49419f594 100644 --- a/scripts/tests/test_bundle_score_many_bundles_one_tractogram.py +++ b/src/scilpy/cli/tests/test_bundle_score_many_bundles_one_tractogram.py @@ -12,8 +12,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_bundle_score_many_bundles_one_tractogram.py', - '--help') + ret = script_runner.run(['scil_bundle_score_many_bundles_one_tractogram', + '--help']) assert ret.success @@ -42,7 +42,7 @@ def test_score_bundles(script_runner, monkeypatch): with open(os.path.join("config_file.json"), "w") as f: json.dump(json_contents, f) - ret = script_runner.run('scil_bundle_score_many_bundles_one_tractogram.py', - "config_file.json", "./", '--no_bbox_check') + ret = script_runner.run(['scil_bundle_score_many_bundles_one_tractogram', + "config_file.json", "./", '--no_bbox_check']) assert ret.success diff --git a/scripts/tests/test_bundle_score_same_bundle_many_segmentations.py b/src/scilpy/cli/tests/test_bundle_score_same_bundle_many_segmentations.py similarity index 85% rename from scripts/tests/test_bundle_score_same_bundle_many_segmentations.py rename to src/scilpy/cli/tests/test_bundle_score_same_bundle_many_segmentations.py index 784a7c414..17e96a162 100644 --- a/scripts/tests/test_bundle_score_same_bundle_many_segmentations.py +++ b/src/scilpy/cli/tests/test_bundle_score_same_bundle_many_segmentations.py @@ -13,8 +13,8 @@ def test_help_option(script_runner): - ret = script_runner.run( - 'scil_bundle_score_same_bundle_many_segmentations.py', '--help') + ret = script_runner.run([ + 'scil_bundle_score_same_bundle_many_segmentations', '--help']) assert ret.success @@ -27,8 +27,8 @@ def test_execution_bundles(script_runner, monkeypatch): in_tractogram = os.path.join(SCILPY_HOME, 'bundles', 'bundle_all_1mm.trk') in_model = os.path.join(SCILPY_HOME, 'bundles', 'fibercup_atlas', 'subj_1', 'bundle_0.trk') - ret = script_runner.run( - 'scil_bundle_score_same_bundle_many_segmentations.py', + ret = script_runner.run([ + 'scil_bundle_score_same_bundle_many_segmentations', in_1, in_2, 'AF_L_binary.json', '--streamlines_measures', in_model, - in_tractogram, '--processes', '1', '--reference', in_ref) + in_tractogram, '--processes', '1', '--reference', in_ref]) assert ret.success diff --git a/scripts/tests/test_bundle_shape_measures.py b/src/scilpy/cli/tests/test_bundle_shape_measures.py similarity index 86% rename from scripts/tests/test_bundle_shape_measures.py rename to src/scilpy/cli/tests/test_bundle_shape_measures.py index 10e29331d..b9e120fe8 100644 --- a/scripts/tests/test_bundle_shape_measures.py +++ b/src/scilpy/cli/tests/test_bundle_shape_measures.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_bundle_shape_measures.py', '--help') + ret = script_runner.run(['scil_bundle_shape_measures', '--help']) assert ret.success @@ -23,7 +23,7 @@ def test_execution_bundles(script_runner, monkeypatch): in_2 = os.path.join(SCILPY_HOME, 'bundles', 'voting_results', 'bundle_0.trk') in_ref = os.path.join(SCILPY_HOME, 'bundles', 'bundle_all_1mm.nii.gz') - ret = script_runner.run('scil_bundle_shape_measures.py', + ret = script_runner.run(['scil_bundle_shape_measures', in_1, in_2, '--out_json', 'AF_L_measures.json', - '--reference', in_ref, '--processes', '1') + '--reference', in_ref, '--processes', '1']) assert ret.success diff --git a/scripts/tests/test_bundle_uniformize_endpoints.py b/src/scilpy/cli/tests/test_bundle_uniformize_endpoints.py similarity index 78% rename from scripts/tests/test_bundle_uniformize_endpoints.py rename to src/scilpy/cli/tests/test_bundle_uniformize_endpoints.py index d022be7ce..43c757b52 100644 --- a/scripts/tests/test_bundle_uniformize_endpoints.py +++ b/src/scilpy/cli/tests/test_bundle_uniformize_endpoints.py @@ -13,16 +13,16 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_bundle_uniformize_endpoints.py', - '--help') + ret = script_runner.run(['scil_bundle_uniformize_endpoints', + '--help']) assert ret.success def test_execution_auto(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM.trk') - ret = script_runner.run('scil_bundle_uniformize_endpoints.py', - in_bundle, 'IFGWM_uni.trk', '--auto') + ret = script_runner.run(['scil_bundle_uniformize_endpoints', + in_bundle, 'IFGWM_uni.trk', '--auto']) assert ret.success @@ -30,7 +30,7 @@ def test_execution_target_atlas(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM.trk') label = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM_labels_map.nii.gz') - ret = script_runner.run('scil_bundle_uniformize_endpoints.py', + ret = script_runner.run(['scil_bundle_uniformize_endpoints', in_bundle, 'IFGWM_uni2.trk', '--target_roi', label, - '3', '10') + '3', '10']) assert ret.success diff --git a/scripts/tests/test_bundle_volume_per_label.py b/src/scilpy/cli/tests/test_bundle_volume_per_label.py similarity index 75% rename from scripts/tests/test_bundle_volume_per_label.py rename to src/scilpy/cli/tests/test_bundle_volume_per_label.py index 13d836c0a..760f2188a 100644 --- a/scripts/tests/test_bundle_volume_per_label.py +++ b/src/scilpy/cli/tests/test_bundle_volume_per_label.py @@ -13,8 +13,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_bundle_volume_per_label.py', - '--help') + ret = script_runner.run(['scil_bundle_volume_per_label', + '--help']) assert ret.success @@ -22,6 +22,6 @@ def test_execution_tractometry(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_label_map = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM_labels_map.nii.gz') - ret = script_runner.run('scil_bundle_volume_per_label.py', - in_label_map, 'IFGWM') + ret = script_runner.run(['scil_bundle_volume_per_label', + in_label_map, 'IFGWM']) assert ret.success diff --git a/scripts/tests/test_connectivity_compare_populations.py b/src/scilpy/cli/tests/test_connectivity_compare_populations.py similarity index 70% rename from scripts/tests/test_connectivity_compare_populations.py rename to src/scilpy/cli/tests/test_connectivity_compare_populations.py index c66b812b0..de92545eb 100644 --- a/scripts/tests/test_connectivity_compare_populations.py +++ b/src/scilpy/cli/tests/test_connectivity_compare_populations.py @@ -13,8 +13,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_connectivity_compare_populations.py', - '--help') + ret = script_runner.run(['scil_connectivity_compare_populations', + '--help']) assert ret.success @@ -23,7 +23,7 @@ def test_execution_connectivity(script_runner, monkeypatch): in_1 = os.path.join(SCILPY_HOME, 'connectivity', 'sc.npy') in_2 = os.path.join(SCILPY_HOME, 'connectivity', 'sc_norm.npy') in_mask = os.path.join(SCILPY_HOME, 'connectivity', 'mask.npy') - ret = script_runner.run('scil_connectivity_compare_populations.py', - 'pval.npy', '--in_g1', in_1, '--in_g2', in_2, - '--filtering_mask', in_mask) + ret = script_runner.run(['scil_connectivity_compare_populations', + 'pval.npy', '--in_g1', in_1, '--in_g2', in_2, + '--filtering_mask', in_mask]) assert ret.success diff --git a/scripts/tests/test_connectivity_compute_matrices.py b/src/scilpy/cli/tests/test_connectivity_compute_matrices.py similarity index 60% rename from scripts/tests/test_connectivity_compute_matrices.py rename to src/scilpy/cli/tests/test_connectivity_compute_matrices.py index becb1ed7d..019476472 100644 --- a/scripts/tests/test_connectivity_compute_matrices.py +++ b/src/scilpy/cli/tests/test_connectivity_compute_matrices.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_connectivity_compute_matrices.py', '--help') + ret = script_runner.run(['scil_connectivity_compute_matrices', '--help']) assert ret.success @@ -24,12 +24,12 @@ def test_execution_connectivity(script_runner, monkeypatch): 'endpoints_atlas.nii.gz') in_avg = os.path.join(SCILPY_HOME, 'connectivity', 'avg_density_maps/') in_afd = os.path.join(SCILPY_HOME, 'connectivity', 'afd_max.nii.gz') - ret = script_runner.run('scil_connectivity_compute_matrices.py', in_h5, - in_atlas, '--volume', 'vol.npy', - '--streamline_count', 'sc.npy', - '--length', 'len.npy', - '--similarity', in_avg, 'sim.npy', - '--metrics', in_afd, 'afd_max.npy', - '--density_weighting', '--no_self_connection', - '--processes', '1') + ret = script_runner.run(['scil_connectivity_compute_matrices', in_h5, + in_atlas, '--volume', 'vol.npy', + '--streamline_count', 'sc.npy', + '--length', 'len.npy', + '--similarity', in_avg, 'sim.npy', + '--metrics', in_afd, 'afd_max.npy', + '--density_weighting', '--no_self_connection', + '--processes', '1']) assert ret.success diff --git a/scripts/tests/test_connectivity_compute_pca.py b/src/scilpy/cli/tests/test_connectivity_compute_pca.py similarity index 79% rename from scripts/tests/test_connectivity_compute_pca.py rename to src/scilpy/cli/tests/test_connectivity_compute_pca.py index d0dbe381b..af0c3cde2 100644 --- a/scripts/tests/test_connectivity_compute_pca.py +++ b/src/scilpy/cli/tests/test_connectivity_compute_pca.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_connectivity_compute_pca.py', '--help') + ret = script_runner.run(['scil_connectivity_compute_pca', '--help']) assert ret.success @@ -22,8 +22,8 @@ def test_execution_pca(script_runner, monkeypatch): input_folder = os.path.join(SCILPY_HOME, 'stats/pca') output_folder = os.path.join(SCILPY_HOME, 'stats/pca_out') ids = os.path.join(SCILPY_HOME, 'stats/pca', 'list_id.txt') - ret = script_runner.run( - 'scil_connectivity_compute_pca.py', input_folder, output_folder, + ret = script_runner.run([ + 'scil_connectivity_compute_pca', input_folder, output_folder, '--metrics', 'ad', 'fa', 'md', 'rd', 'nufo', 'afd_total', 'afd_fixel', - '--list_ids', ids, '-f') + '--list_ids', ids, '-f']) assert ret.success diff --git a/scripts/tests/test_connectivity_compute_simple_matrix.py b/src/scilpy/cli/tests/test_connectivity_compute_simple_matrix.py similarity index 80% rename from scripts/tests/test_connectivity_compute_simple_matrix.py rename to src/scilpy/cli/tests/test_connectivity_compute_simple_matrix.py index 33411c60e..2e96436e5 100644 --- a/scripts/tests/test_connectivity_compute_simple_matrix.py +++ b/src/scilpy/cli/tests/test_connectivity_compute_simple_matrix.py @@ -13,8 +13,8 @@ def test_help_option(script_runner): - ret = script_runner.run( - 'scil_connectivity_compute_simple_matrix.py', '--help') + ret = script_runner.run([ + 'scil_connectivity_compute_simple_matrix', '--help']) assert ret.success @@ -24,8 +24,8 @@ def test_script(script_runner, monkeypatch): 'IFGWM_labels_map.nii.gz') in_sft = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM.trk') - ret = script_runner.run( - 'scil_connectivity_compute_simple_matrix.py', in_sft, in_labels, + ret = script_runner.run([ + 'scil_connectivity_compute_simple_matrix', in_sft, in_labels, 'out_matrix.npy', 'out_labels.txt', '--hide_labels', '10', - '--percentage', '--hide_fig', '--out_fig', 'matrices.png') + '--percentage', '--hide_fig', '--out_fig', 'matrices.png']) assert ret.success diff --git a/scripts/tests/test_connectivity_filter.py b/src/scilpy/cli/tests/test_connectivity_filter.py similarity index 69% rename from scripts/tests/test_connectivity_filter.py rename to src/scilpy/cli/tests/test_connectivity_filter.py index cb365d93b..02ee698b6 100644 --- a/scripts/tests/test_connectivity_filter.py +++ b/src/scilpy/cli/tests/test_connectivity_filter.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_connectivity_filter.py', '--help') + ret = script_runner.run(['scil_connectivity_filter', '--help']) assert ret.success @@ -23,8 +23,8 @@ def test_execution_connectivity(script_runner, monkeypatch): 'sc.npy') in_sim = os.path.join(SCILPY_HOME, 'connectivity', 'len.npy') - ret = script_runner.run('scil_connectivity_filter.py', 'mask.npy', - '--greater_than', in_sc, '5', '1', - '--greater_than', in_sim, '0', '1', - '--keep_condition_count') + ret = script_runner.run(['scil_connectivity_filter', 'mask.npy', + '--greater_than', in_sc, '5', '1', + '--greater_than', in_sim, '0', '1', + '--keep_condition_count']) assert ret.success diff --git a/scripts/tests/test_connectivity_graph_measures.py b/src/scilpy/cli/tests/test_connectivity_graph_measures.py similarity index 79% rename from scripts/tests/test_connectivity_graph_measures.py rename to src/scilpy/cli/tests/test_connectivity_graph_measures.py index faf836476..b4c044b8f 100644 --- a/scripts/tests/test_connectivity_graph_measures.py +++ b/src/scilpy/cli/tests/test_connectivity_graph_measures.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_connectivity_graph_measures.py', '--help') + ret = script_runner.run(['scil_connectivity_graph_measures', '--help']) assert ret.success @@ -21,7 +21,7 @@ def test_execution_connectivity(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_sc = os.path.join(SCILPY_HOME, 'connectivity', 'sc_norm.npy') in_len = os.path.join(SCILPY_HOME, 'connectivity', 'len.npy') - ret = script_runner.run('scil_connectivity_graph_measures.py', in_sc, + ret = script_runner.run(['scil_connectivity_graph_measures', in_sc, in_len, 'gtm.json', '--avg_node_wise', - '--small_world') + '--small_world']) assert ret.success diff --git a/scripts/tests/test_connectivity_hdf5_average_density_map.py b/src/scilpy/cli/tests/test_connectivity_hdf5_average_density_map.py similarity index 74% rename from scripts/tests/test_connectivity_hdf5_average_density_map.py rename to src/scilpy/cli/tests/test_connectivity_hdf5_average_density_map.py index f059f909f..575fc411d 100644 --- a/scripts/tests/test_connectivity_hdf5_average_density_map.py +++ b/src/scilpy/cli/tests/test_connectivity_hdf5_average_density_map.py @@ -13,17 +13,17 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_connectivity_hdf5_average_density_map.py', - '--help') + ret = script_runner.run(['scil_connectivity_hdf5_average_density_map', + '--help']) assert ret.success def test_execution_connectivity(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_h5 = os.path.join(SCILPY_HOME, 'connectivity', 'decompose.h5') - ret = script_runner.run('scil_connectivity_hdf5_average_density_map.py', + ret = script_runner.run(['scil_connectivity_hdf5_average_density_map', in_h5, 'avg_density_map/', '--binary', - '--processes', '1') + '--processes', '1']) assert ret.success @@ -31,7 +31,7 @@ def test_execution_connectivity_(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_h5_1 = os.path.join(SCILPY_HOME, 'connectivity', 'decompose.h5') in_h5_2 = os.path.join(SCILPY_HOME, 'connectivity', 'decompose_afd_rd.h5') - ret = script_runner.run('scil_connectivity_hdf5_average_density_map.py', + ret = script_runner.run(['scil_connectivity_hdf5_average_density_map', in_h5_1, in_h5_2, 'avg_density_maps/', - '--processes', '1') + '--processes', '1']) assert ret.success diff --git a/scripts/tests/test_connectivity_math.py b/src/scilpy/cli/tests/test_connectivity_math.py similarity index 76% rename from scripts/tests/test_connectivity_math.py rename to src/scilpy/cli/tests/test_connectivity_math.py index bd640349c..2d7907a71 100644 --- a/scripts/tests/test_connectivity_math.py +++ b/src/scilpy/cli/tests/test_connectivity_math.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_connectivity_math.py', '--help') + ret = script_runner.run(['scil_connectivity_math', '--help']) assert ret.success @@ -23,8 +23,8 @@ def test_execution_connectivity_div(script_runner, monkeypatch): 'sc.npy') in_vol = os.path.join(SCILPY_HOME, 'connectivity', 'vol.npy') - ret = script_runner.run('scil_connectivity_math.py', 'division', - in_sc, in_vol, 'sc_norm_vol.npy') + ret = script_runner.run(['scil_connectivity_math', 'division', + in_sc, in_vol, 'sc_norm_vol.npy']) assert ret.success @@ -32,8 +32,8 @@ def test_execution_connectivity_add(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_sc = os.path.join(SCILPY_HOME, 'connectivity', 'sc.npy') - ret = script_runner.run('scil_connectivity_math.py', 'addition', - in_sc, '10', 'sc_add_10.npy') + ret = script_runner.run(['scil_connectivity_math', 'addition', + in_sc, '10', 'sc_add_10.npy']) assert ret.success @@ -41,6 +41,6 @@ def test_execution_connectivity_lower_threshold(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_sc = os.path.join(SCILPY_HOME, 'connectivity', 'sc.npy') - ret = script_runner.run('scil_connectivity_math.py', 'lower_threshold', - in_sc, '5', 'sc_lower_threshold.npy') + ret = script_runner.run(['scil_connectivity_math', 'lower_threshold', + in_sc, '5', 'sc_lower_threshold.npy']) assert ret.success diff --git a/scripts/tests/test_connectivity_normalize.py b/src/scilpy/cli/tests/test_connectivity_normalize.py similarity index 76% rename from scripts/tests/test_connectivity_normalize.py rename to src/scilpy/cli/tests/test_connectivity_normalize.py index 0a32e26d6..495077360 100644 --- a/scripts/tests/test_connectivity_normalize.py +++ b/src/scilpy/cli/tests/test_connectivity_normalize.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_connectivity_normalize.py', '--help') + ret = script_runner.run(['scil_connectivity_normalize', '--help']) assert ret.success @@ -25,7 +25,7 @@ def test_execution_connectivity(script_runner, monkeypatch): 'endpoints_atlas.nii.gz') in_labels_list = os.path.join(SCILPY_HOME, 'connectivity', 'labels_list.txt') - ret = script_runner.run('scil_connectivity_normalize.py', in_sc, - 'sc_norm.npy', '--length', in_len, - '--parcel_volume', in_atlas, in_labels_list) + ret = script_runner.run(['scil_connectivity_normalize', in_sc, + 'sc_norm.npy', '--length', in_len, + '--parcel_volume', in_atlas, in_labels_list]) assert ret.success diff --git a/scripts/tests/test_connectivity_pairwise_agreement.py b/src/scilpy/cli/tests/test_connectivity_pairwise_agreement.py similarity index 78% rename from scripts/tests/test_connectivity_pairwise_agreement.py rename to src/scilpy/cli/tests/test_connectivity_pairwise_agreement.py index 0a271c637..8f82f2dce 100644 --- a/scripts/tests/test_connectivity_pairwise_agreement.py +++ b/src/scilpy/cli/tests/test_connectivity_pairwise_agreement.py @@ -13,8 +13,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_connectivity_pairwise_agreement.py', - '--help') + ret = script_runner.run(['scil_connectivity_pairwise_agreement', + '--help']) assert ret.success @@ -22,6 +22,6 @@ def test_execution_connectivity(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_sc = os.path.join(SCILPY_HOME, 'connectivity', 'sc_norm.npy') in_len = os.path.join(SCILPY_HOME, 'connectivity', 'len.npy') - ret = script_runner.run('scil_connectivity_pairwise_agreement.py', in_sc, - in_len, 'diff.json', '--single_compare', in_sc) + ret = script_runner.run(['scil_connectivity_pairwise_agreement', in_sc, + in_len, 'diff.json', '--single_compare', in_sc]) assert ret.success diff --git a/scripts/tests/test_connectivity_print_filenames.py b/src/scilpy/cli/tests/test_connectivity_print_filenames.py similarity index 78% rename from scripts/tests/test_connectivity_print_filenames.py rename to src/scilpy/cli/tests/test_connectivity_print_filenames.py index 24d01ea8d..1f6259e05 100644 --- a/scripts/tests/test_connectivity_print_filenames.py +++ b/src/scilpy/cli/tests/test_connectivity_print_filenames.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_connectivity_print_filenames.py', '--help') + ret = script_runner.run(['scil_connectivity_print_filenames', '--help']) assert ret.success @@ -23,6 +23,6 @@ def test_execution_connectivity(script_runner, monkeypatch): 'sc_norm.npy') in_labels_list = os.path.join(SCILPY_HOME, 'connectivity', 'labels_list.txt') - ret = script_runner.run('scil_connectivity_print_filenames.py', in_sc, - in_labels_list, 'success.txt') + ret = script_runner.run(['scil_connectivity_print_filenames', in_sc, + in_labels_list, 'success.txt']) assert ret.success diff --git a/scripts/tests/test_connectivity_reorder_rois.py b/src/scilpy/cli/tests/test_connectivity_reorder_rois.py similarity index 65% rename from scripts/tests/test_connectivity_reorder_rois.py rename to src/scilpy/cli/tests/test_connectivity_reorder_rois.py index 0d2e37269..625f18b19 100644 --- a/scripts/tests/test_connectivity_reorder_rois.py +++ b/src/scilpy/cli/tests/test_connectivity_reorder_rois.py @@ -15,7 +15,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_connectivity_reorder_rois.py', '--help') + ret = script_runner.run(['scil_connectivity_reorder_rois', '--help']) assert ret.success @@ -26,10 +26,10 @@ def test_execution_compute_OLO(script_runner, monkeypatch): 'sc_norm.npy') in_labels_list = os.path.join(SCILPY_HOME, 'connectivity', 'labels_list.txt') - ret = script_runner.run('scil_connectivity_reorder_rois.py', in_sc, - '--optimal_leaf_ordering', 'OLO.txt', - '--out_dir', os.path.expanduser(tmp_dir.name), - '--labels_list', in_labels_list, '-f') + ret = script_runner.run(['scil_connectivity_reorder_rois', in_sc, + '--optimal_leaf_ordering', 'OLO.txt', + '--out_dir', os.path.expanduser(tmp_dir.name), + '--labels_list', in_labels_list, '-f']) assert ret.success @@ -39,9 +39,9 @@ def test_execution_apply_ordering(script_runner, monkeypatch): in_txt = os.path.join(SCILPY_HOME, 'connectivity', 'reorder.txt') in_labels_list = os.path.join(SCILPY_HOME, 'connectivity', 'labels_list.txt') - ret = script_runner.run('scil_connectivity_reorder_rois.py', in_sc, - '--in_ordering', in_txt, - '--out_suffix', '_sc_reo', - '--out_dir', os.path.expanduser(tmp_dir.name), - '--labels_list', in_labels_list, '-f') + ret = script_runner.run(['scil_connectivity_reorder_rois', in_sc, + '--in_ordering', in_txt, + '--out_suffix', '_sc_reo', + '--out_dir', os.path.expanduser(tmp_dir.name), + '--labels_list', in_labels_list, '-f']) assert ret.success diff --git a/scripts/tests/test_denoising_nlmeans.py b/src/scilpy/cli/tests/test_denoising_nlmeans.py similarity index 53% rename from scripts/tests/test_denoising_nlmeans.py rename to src/scilpy/cli/tests/test_denoising_nlmeans.py index 45e0ffacb..41cc2bc9f 100644 --- a/scripts/tests/test_denoising_nlmeans.py +++ b/src/scilpy/cli/tests/test_denoising_nlmeans.py @@ -13,27 +13,27 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_denoising_nlmeans.py', '--help') + ret = script_runner.run(['scil_denoising_nlmeans', '--help']) assert ret.success def test_execution_user_sigma(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_img = os.path.join(SCILPY_HOME, 'others', 't1_resample.nii.gz') - ret = script_runner.run('scil_denoising_nlmeans.py', in_img, - 'denoised.nii.gz', '--processes', '1', - '--sigma', '8', '--number_coils', 0, - '--gaussian') + ret = script_runner.run(['scil_denoising_nlmeans', in_img, + 'denoised.nii.gz', '--processes', '1', + '--sigma', '8', '--number_coils', 0, + '--gaussian']) assert ret.success def test_execution_basic_3d(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_img = os.path.join(SCILPY_HOME, 'others', 't1_resample.nii.gz') - ret = script_runner.run('scil_denoising_nlmeans.py', in_img, - 't1_denoised.nii.gz', '--processes', '1', - '--basic_sigma', '--number_coils', 0, - '--gaussian') + ret = script_runner.run(['scil_denoising_nlmeans', in_img, + 't1_denoised.nii.gz', '--processes', '1', + '--basic_sigma', '--number_coils', 0, + '--gaussian']) assert ret.success @@ -41,17 +41,20 @@ def test_execution_basic_4d_mask(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_img = os.path.join(SCILPY_HOME, 'processing', 'dwi_crop_1000.nii.gz') in_mask = os.path.join(SCILPY_HOME, 'processing', 'fa_thr.nii.gz') - ret = script_runner.run('scil_denoising_nlmeans.py', in_img, - 't1_denoised2.nii.gz', '--processes', '1', - '--basic_sigma', '--number_coils', 0, - '--gaussian', '--mask_sigma', in_mask) + ret = script_runner.run(['scil_denoising_nlmeans', in_img, + 't1_denoised2.nii.gz', '--processes', '1', + '--basic_sigma', '--number_coils', 0, + '--gaussian', '--mask_sigma', in_mask]) assert ret.success def test_execution_piesno(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_img = os.path.join(SCILPY_HOME, 'processing', 'dwi.nii.gz') - ret = script_runner.run('scil_denoising_nlmeans.py', in_img, - 'dwi_denoised.nii.gz', '--processes', '1', - '--piesno', '--number_coils', '4') + in_mask = os.path.join(SCILPY_HOME, 'processing', + 'small_roi_gm_mask.nii.gz') + ret = script_runner.run(['scil_denoising_nlmeans', in_img, + 'dwi_denoised.nii.gz', '--processes', '1', + '--mask_denoise', in_mask, + '--piesno', '--number_coils', '4']) assert ret.success diff --git a/scripts/tests/test_dki_metrics.py b/src/scilpy/cli/tests/test_dki_metrics.py similarity index 53% rename from scripts/tests/test_dki_metrics.py rename to src/scilpy/cli/tests/test_dki_metrics.py index 617c1b7af..30a0ee086 100644 --- a/scripts/tests/test_dki_metrics.py +++ b/src/scilpy/cli/tests/test_dki_metrics.py @@ -13,23 +13,26 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_dki_metrics.py', '--help') + ret = script_runner.run(['scil_dki_metrics', '--help']) assert ret.success def test_execution_processing(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_dwi = os.path.join(SCILPY_HOME, 'processing', - 'dwi_crop.nii.gz') + 'dwi.nii.gz') in_bval = os.path.join(SCILPY_HOME, 'processing', 'dwi.bval') in_bvec = os.path.join(SCILPY_HOME, 'processing', 'dwi.bvec') - ret = script_runner.run('scil_dki_metrics.py', in_dwi, - in_bval, in_bvec, '--not_all', - '--dki_fa', 'dki_fa.nii.gz', - '--dki_md', 'dki_md.nii.gz', - '--dki_rd', 'dki_rd.nii.gz', - '--dki_ad', 'dki_ad.nii.gz', - '--dki_residual', 'dki_res.nii.gz') + in_mask = os.path.join(SCILPY_HOME, 'processing', + 'small_roi_gm_mask.nii.gz') + ret = script_runner.run(['scil_dki_metrics', in_dwi, + in_bval, in_bvec, '--not_all', + '--dki_fa', 'dki_fa.nii.gz', + '--dki_md', 'dki_md.nii.gz', + '--dki_rd', 'dki_rd.nii.gz', + '--dki_ad', 'dki_ad.nii.gz', + '--dki_residual', 'dki_res.nii.gz', + '--mask', in_mask]) assert ret.success diff --git a/scripts/tests/test_dti_convert_tensors.py b/src/scilpy/cli/tests/test_dti_convert_tensors.py similarity index 82% rename from scripts/tests/test_dti_convert_tensors.py rename to src/scilpy/cli/tests/test_dti_convert_tensors.py index 9d66d8345..e8094e7c1 100644 --- a/scripts/tests/test_dti_convert_tensors.py +++ b/src/scilpy/cli/tests/test_dti_convert_tensors.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_dti_convert_tensors.py', '--help') + ret = script_runner.run(['scil_dti_convert_tensors', '--help']) assert ret.success @@ -25,11 +25,11 @@ def test_execution_processing(script_runner, monkeypatch): in_dwi = os.path.join(SCILPY_HOME, 'processing', 'dwi_crop_1000.nii.gz') in_bval = os.path.join(SCILPY_HOME, 'processing', '1000.bval') in_bvec = os.path.join(SCILPY_HOME, 'processing', '1000.bvec') - script_runner.run('scil_dti_metrics.py', in_dwi, + script_runner.run(['scil_dti_metrics', in_dwi, in_bval, in_bvec, '--not_all', - '--tensor', 'tensors.nii.gz', '--tensor_format', 'fsl') + '--tensor', 'tensors.nii.gz', '--tensor_format', 'fsl']) - ret = script_runner.run('scil_dti_convert_tensors.py', 'tensors.nii.gz', - 'converted_tensors.nii.gz', 'fsl', 'mrtrix') + ret = script_runner.run(['scil_dti_convert_tensors', 'tensors.nii.gz', + 'converted_tensors.nii.gz', 'fsl', 'mrtrix']) assert ret.success diff --git a/scripts/tests/test_dti_metrics.py b/src/scilpy/cli/tests/test_dti_metrics.py similarity index 62% rename from scripts/tests/test_dti_metrics.py rename to src/scilpy/cli/tests/test_dti_metrics.py index 96c002ea5..0175e05ec 100644 --- a/scripts/tests/test_dti_metrics.py +++ b/src/scilpy/cli/tests/test_dti_metrics.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_dti_metrics.py', '--help') + ret = script_runner.run(['scil_dti_metrics', '--help']) assert ret.success @@ -26,17 +26,17 @@ def test_execution_processing_diff_metrics(script_runner, monkeypatch): # No mask fitting with this data? Creating our own. mask = os.path.join(SCILPY_HOME, 'processing', 'ad.nii.gz') mask_uint8 = os.path.join('mask_uint8.nii.gz') - script_runner.run('scil_volume_math.py', 'convert', - mask, mask_uint8, '--data_type', 'uint8') - - ret = script_runner.run('scil_dti_metrics.py', in_dwi, - in_bval, in_bvec, '--not_all', - '--fa', 'fa.nii.gz', - '--md', 'md.nii.gz', - '--ad', 'ad.nii.gz', - '--rd', 'rd.nii.gz', - '--residual', 'residual.nii.gz', - '--mask', mask_uint8) + script_runner.run(['scil_volume_math', 'convert', + mask, mask_uint8, '--data_type', 'uint8']) + + ret = script_runner.run(['scil_dti_metrics', in_dwi, + in_bval, in_bvec, '--not_all', + '--fa', 'fa.nii.gz', + '--md', 'md.nii.gz', + '--ad', 'ad.nii.gz', + '--rd', 'rd.nii.gz', + '--residual', 'residual.nii.gz', + '--mask', mask_uint8]) assert ret.success @@ -49,12 +49,12 @@ def test_execution_processing_b0_threshold(script_runner, monkeypatch): # No mask fitting with this data? Creating our own. mask = os.path.join(SCILPY_HOME, 'processing', 'ad.nii.gz') mask_uint8 = os.path.join('mask_uint8.nii.gz') - script_runner.run('scil_volume_math.py', 'convert', - mask, mask_uint8, '--data_type', 'uint8') + script_runner.run(['scil_volume_math', 'convert', + mask, mask_uint8, '--data_type', 'uint8']) - ret = script_runner.run('scil_dti_metrics.py', in_dwi, - in_bval, in_bvec, '--not_all', - '--fa', 'fa.nii.gz', '--b0_threshold', '1', '-f') + ret = script_runner.run(['scil_dti_metrics', in_dwi, + in_bval, in_bvec, '--not_all', + '--fa', 'fa.nii.gz', '--b0_threshold', '1', '-f']) assert not ret.success @@ -67,10 +67,10 @@ def test_execution_processing_rgb(script_runner, monkeypatch): # No mask fitting with this data? Creating our own. mask = os.path.join(SCILPY_HOME, 'processing', 'ad.nii.gz') mask_uint8 = os.path.join('mask_uint8.nii.gz') - script_runner.run('scil_volume_math.py', 'convert', - mask, mask_uint8, '--data_type', 'uint8') + script_runner.run(['scil_volume_math', 'convert', + mask, mask_uint8, '--data_type', 'uint8']) - ret = script_runner.run('scil_dti_metrics.py', in_dwi, - in_bval, in_bvec, '--not_all', - '--rgb', 'rgb.nii.gz', '-f') + ret = script_runner.run(['scil_dti_metrics', in_dwi, + in_bval, in_bvec, '--not_all', + '--rgb', 'rgb.nii.gz', '-f']) assert ret.success diff --git a/scripts/tests/test_dwi_apply_bias_field.py b/src/scilpy/cli/tests/test_dwi_apply_bias_field.py similarity index 79% rename from scripts/tests/test_dwi_apply_bias_field.py rename to src/scilpy/cli/tests/test_dwi_apply_bias_field.py index c3b91993d..e0e922384 100644 --- a/scripts/tests/test_dwi_apply_bias_field.py +++ b/src/scilpy/cli/tests/test_dwi_apply_bias_field.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_dwi_apply_bias_field.py', '--help') + ret = script_runner.run(['scil_dwi_apply_bias_field', '--help']) assert ret.success @@ -23,6 +23,6 @@ def test_execution_processing(script_runner, monkeypatch): 'dwi_crop.nii.gz') in_bias = os.path.join(SCILPY_HOME, 'processing', 'bias_field_b0.nii.gz') - ret = script_runner.run('scil_dwi_apply_bias_field.py', in_dwi, - in_bias, 'dwi_crop_n4.nii.gz') + ret = script_runner.run(['scil_dwi_apply_bias_field', in_dwi, + in_bias, 'dwi_crop_n4.nii.gz']) assert ret.success diff --git a/scripts/tests/test_dwi_compute_snr.py b/src/scilpy/cli/tests/test_dwi_compute_snr.py similarity index 76% rename from scripts/tests/test_dwi_compute_snr.py rename to src/scilpy/cli/tests/test_dwi_compute_snr.py index 1bfad3352..dd41c5028 100644 --- a/scripts/tests/test_dwi_compute_snr.py +++ b/src/scilpy/cli/tests/test_dwi_compute_snr.py @@ -12,7 +12,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_dwi_compute_snr.py', '--help') + ret = script_runner.run(['scil_dwi_compute_snr', '--help']) assert ret.success @@ -29,8 +29,8 @@ def test_snr(script_runner, monkeypatch): noise_mask = os.path.join(SCILPY_HOME, 'processing', 'small_roi_gm_mask.nii.gz') - ret = script_runner.run('scil_dwi_compute_snr.py', in_dwi, - in_bval, in_bvec, in_mask, - '--noise_mask', noise_mask, - '--b0_thr', '10') + ret = script_runner.run(['scil_dwi_compute_snr', in_dwi, + in_bval, in_bvec, in_mask, + '--noise_mask', noise_mask, + '--b0_thr', '10']) assert ret.success diff --git a/scripts/tests/test_dwi_concatenate.py b/src/scilpy/cli/tests/test_dwi_concatenate.py similarity index 68% rename from scripts/tests/test_dwi_concatenate.py rename to src/scilpy/cli/tests/test_dwi_concatenate.py index 743e8a014..e0a8ce69d 100644 --- a/scripts/tests/test_dwi_concatenate.py +++ b/src/scilpy/cli/tests/test_dwi_concatenate.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_dwi_concatenate.py', '--help') + ret = script_runner.run(['scil_dwi_concatenate', '--help']) assert ret.success @@ -25,9 +25,9 @@ def test_execution_processing_concatenate(script_runner, monkeypatch): 'dwi.bval') in_bvec = os.path.join(SCILPY_HOME, 'processing', 'dwi.bvec') - ret = script_runner.run('scil_dwi_concatenate.py', 'dwi_concat.nii.gz', - 'concat.bval', 'concat.bvec', - '--in_dwi', in_dwi, in_dwi, - '--in_bvals', in_bval, in_bval, - '--in_bvecs', in_bvec, in_bvec) + ret = script_runner.run(['scil_dwi_concatenate', 'dwi_concat.nii.gz', + 'concat.bval', 'concat.bvec', + '--in_dwi', in_dwi, in_dwi, + '--in_bvals', in_bval, in_bval, + '--in_bvecs', in_bvec, in_bvec]) assert ret.success diff --git a/scripts/tests/test_freewater_priors.py b/src/scilpy/cli/tests/test_dwi_convert_FDF.py similarity index 61% rename from scripts/tests/test_freewater_priors.py rename to src/scilpy/cli/tests/test_dwi_convert_FDF.py index b2ff43fd6..303da46a0 100644 --- a/scripts/tests/test_freewater_priors.py +++ b/src/scilpy/cli/tests/test_dwi_convert_FDF.py @@ -3,5 +3,5 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_freewater_priors.py', '--help') + ret = script_runner.run(['scil_viz_dti_screenshot', '--help']) assert ret.success diff --git a/scripts/tests/test_dwi_detect_volume_outliers.py b/src/scilpy/cli/tests/test_dwi_detect_volume_outliers.py similarity index 77% rename from scripts/tests/test_dwi_detect_volume_outliers.py rename to src/scilpy/cli/tests/test_dwi_detect_volume_outliers.py index c32b21ede..7b2904442 100644 --- a/scripts/tests/test_dwi_detect_volume_outliers.py +++ b/src/scilpy/cli/tests/test_dwi_detect_volume_outliers.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_dwi_detect_volume_outliers.py', '--help') + ret = script_runner.run(['scil_dwi_detect_volume_outliers', '--help']) assert ret.success @@ -25,11 +25,11 @@ def test_execution(script_runner, monkeypatch): 'dwi.bval') in_bvec = os.path.join(SCILPY_HOME, 'processing', 'dwi.bvec') - ret = script_runner.run('scil_dwi_detect_volume_outliers.py', in_dwi, - in_bval, in_bvec, '-v') + ret = script_runner.run(['scil_dwi_detect_volume_outliers', in_dwi, + in_bval, in_bvec, '-v']) assert ret.success # Test wrong b0. Current minimal b-value is 5. - ret = script_runner.run('scil_dwi_detect_volume_outliers.py', in_dwi, - in_bval, in_bvec, '--b0_threshold', '1') + ret = script_runner.run(['scil_dwi_detect_volume_outliers', in_dwi, + in_bval, in_bvec, '--b0_threshold', '1']) assert not ret.success diff --git a/scripts/tests/test_dwi_extract_b0.py b/src/scilpy/cli/tests/test_dwi_extract_b0.py similarity index 81% rename from scripts/tests/test_dwi_extract_b0.py rename to src/scilpy/cli/tests/test_dwi_extract_b0.py index 34447870d..79402b90c 100644 --- a/scripts/tests/test_dwi_extract_b0.py +++ b/src/scilpy/cli/tests/test_dwi_extract_b0.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_dwi_extract_b0.py', '--help') + ret = script_runner.run(['scil_dwi_extract_b0', '--help']) assert ret.success @@ -25,11 +25,11 @@ def test_execution_processing(script_runner, monkeypatch): 'dwi.bval') in_bvec = os.path.join(SCILPY_HOME, 'processing', 'dwi.bvec') - ret = script_runner.run('scil_dwi_extract_b0.py', in_dwi, in_bval, in_bvec, - 'b0_mean.nii.gz', '--mean', '--b0', '20') + ret = script_runner.run(['scil_dwi_extract_b0', in_dwi, in_bval, in_bvec, + 'b0_mean.nii.gz', '--mean', '--b0', '20']) assert ret.success # Test wrong b0. Current minimal b-value is 5. - ret = script_runner.run('scil_dwi_extract_b0.py', in_dwi, in_bval, in_bvec, - 'b0_mean.nii.gz', '--mean', '--b0', '1', '-f') + ret = script_runner.run(['scil_dwi_extract_b0', in_dwi, in_bval, in_bvec, + 'b0_mean.nii.gz', '--mean', '--b0', '1', '-f']) assert not ret.success diff --git a/scripts/tests/test_dwi_extract_shell.py b/src/scilpy/cli/tests/test_dwi_extract_shell.py similarity index 65% rename from scripts/tests/test_dwi_extract_shell.py rename to src/scilpy/cli/tests/test_dwi_extract_shell.py index b0a824e7c..6817463cc 100644 --- a/scripts/tests/test_dwi_extract_shell.py +++ b/src/scilpy/cli/tests/test_dwi_extract_shell.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_dwi_extract_shell.py', '--help') + ret = script_runner.run(['scil_dwi_extract_shell', '--help']) assert ret.success @@ -25,10 +25,10 @@ def test_execution_processing_1000(script_runner, monkeypatch): 'dwi.bval') in_bvec = os.path.join(SCILPY_HOME, 'processing', 'dwi.bvec') - ret = script_runner.run('scil_dwi_extract_shell.py', in_dwi, - in_bval, in_bvec, '0', '1000', - 'dwi_crop_1000.nii.gz', '1000.bval', '1000.bvec', - '-t', '30') + ret = script_runner.run(['scil_dwi_extract_shell', in_dwi, + in_bval, in_bvec, '0', '1000', + 'dwi_crop_1000.nii.gz', '1000.bval', '1000.bvec', + '-t', '30']) assert ret.success @@ -40,11 +40,11 @@ def test_execution_out_indices(script_runner, monkeypatch): 'dwi.bval') in_bvec = os.path.join(SCILPY_HOME, 'processing', 'dwi.bvec') - ret = script_runner.run('scil_dwi_extract_shell.py', in_dwi, - in_bval, in_bvec, '0', '1000', - 'dwi_crop_1000__1.nii.gz', '1000__1.bval', - '1000__1.bvec', '-t', '30', '--out_indices', - 'out_indices.txt') + ret = script_runner.run(['scil_dwi_extract_shell', in_dwi, + in_bval, in_bvec, '0', '1000', + 'dwi_crop_1000__1.nii.gz', '1000__1.bval', + '1000__1.bvec', '-t', '30', '--out_indices', + 'out_indices.txt']) assert ret.success @@ -56,8 +56,8 @@ def test_execution_processing_3000(script_runner, monkeypatch): 'dwi.bval') in_bvec = os.path.join(SCILPY_HOME, 'processing', 'dwi.bvec') - ret = script_runner.run('scil_dwi_extract_shell.py', in_dwi, - in_bval, in_bvec, '0', '3000', - 'dwi_crop_3000.nii.gz', '3000.bval', '3000.bvec', - '-t', '30') + ret = script_runner.run(['scil_dwi_extract_shell', in_dwi, + in_bval, in_bvec, '0', '3000', + 'dwi_crop_3000.nii.gz', '3000.bval', '3000.bvec', + '-t', '30']) assert ret.success diff --git a/scripts/tests/test_dwi_powder_average.py b/src/scilpy/cli/tests/test_dwi_powder_average.py similarity index 84% rename from scripts/tests/test_dwi_powder_average.py rename to src/scilpy/cli/tests/test_dwi_powder_average.py index f388d9f79..d3fc81337 100644 --- a/scripts/tests/test_dwi_powder_average.py +++ b/src/scilpy/cli/tests/test_dwi_powder_average.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_dwi_powder_average.py', '--help') + ret = script_runner.run(['scil_dwi_powder_average', '--help']) assert ret.success @@ -25,6 +25,6 @@ def test_execution_processing(script_runner, monkeypatch): in_bval = os.path.join(SCILPY_HOME, 'processing', '1000.bval') - ret = script_runner.run('scil_dwi_powder_average.py', in_dwi, - in_bval, 'out_pwd_avg.nii.gz', '--shells', '1000') + ret = script_runner.run(['scil_dwi_powder_average', in_dwi, + in_bval, 'out_pwd_avg.nii.gz', '--shells', '1000']) assert ret.success diff --git a/src/scilpy/cli/tests/test_dwi_prepare_eddy_command.py b/src/scilpy/cli/tests/test_dwi_prepare_eddy_command.py new file mode 100644 index 000000000..6af858542 --- /dev/null +++ b/src/scilpy/cli/tests/test_dwi_prepare_eddy_command.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + + +def test_help_option(script_runner): + ret = script_runner.run(['scil_dwi_prepare_eddy_command', '--help']) + assert ret.success diff --git a/scripts/tests/test_dwi_prepare_eddy_command.py b/src/scilpy/cli/tests/test_dwi_prepare_topup_command.py similarity index 59% rename from scripts/tests/test_dwi_prepare_eddy_command.py rename to src/scilpy/cli/tests/test_dwi_prepare_topup_command.py index cb5334864..335e8b8c0 100644 --- a/scripts/tests/test_dwi_prepare_eddy_command.py +++ b/src/scilpy/cli/tests/test_dwi_prepare_topup_command.py @@ -3,5 +3,5 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_dwi_prepare_eddy_command.py', '--help') + ret = script_runner.run(['scil_dwi_prepare_topup_command', '--help']) assert ret.success diff --git a/scripts/tests/test_dwi_reorder_philips.py b/src/scilpy/cli/tests/test_dwi_reorder_philips.py similarity index 88% rename from scripts/tests/test_dwi_reorder_philips.py rename to src/scilpy/cli/tests/test_dwi_reorder_philips.py index 0903d1ed0..52e2f8fe5 100644 --- a/scripts/tests/test_dwi_reorder_philips.py +++ b/src/scilpy/cli/tests/test_dwi_reorder_philips.py @@ -17,7 +17,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_dwi_reorder_philips.py', '--help') + ret = script_runner.run(['scil_dwi_reorder_philips', '--help']) assert ret.success @@ -35,8 +35,8 @@ def test_reorder(script_runner, monkeypatch): table[30] = tmp in_table = os.path.expanduser(tmp_dir.name) + "/in_table.txt" np.savetxt(in_table, table, header="Test") - ret = script_runner.run('scil_dwi_reorder_philips.py', in_dwi, in_bval, - in_bvec, in_table, 'out1', '-f') + ret = script_runner.run(['scil_dwi_reorder_philips', in_dwi, in_bval, + in_bvec, in_table, 'out1', '-f']) assert ret.success @@ -58,8 +58,8 @@ def test_reorder_w_json_old_version(script_runner, monkeypatch): info = {'SoftwareVersions': '5.5'} with open(in_json, 'w') as f: json.dump(info, f) - ret = script_runner.run('scil_dwi_reorder_philips.py', in_dwi, in_bval, - in_bvec, in_table, 'out2', '--json', in_json) + ret = script_runner.run(['scil_dwi_reorder_philips', in_dwi, in_bval, + in_bvec, in_table, 'out2', '--json', in_json]) assert ret.success @@ -81,6 +81,6 @@ def test_reorder_w_json_new_version(script_runner, monkeypatch): info = {'SoftwareVersions': '5.6'} with open(in_json, 'w') as f: json.dump(info, f) - ret = script_runner.run('scil_dwi_reorder_philips.py', in_dwi, in_bval, - in_bvec, in_table, 'out3', '--json', in_json) + ret = script_runner.run(['scil_dwi_reorder_philips', in_dwi, in_bval, + in_bvec, in_table, 'out3', '--json', in_json]) assert not ret.success diff --git a/scripts/tests/test_dwi_split_by_indices.py b/src/scilpy/cli/tests/test_dwi_split_by_indices.py similarity index 82% rename from scripts/tests/test_dwi_split_by_indices.py rename to src/scilpy/cli/tests/test_dwi_split_by_indices.py index 9a89a14f3..da25b4e9a 100644 --- a/scripts/tests/test_dwi_split_by_indices.py +++ b/src/scilpy/cli/tests/test_dwi_split_by_indices.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_dwi_split_by_indices.py', '--help') + ret = script_runner.run(['scil_dwi_split_by_indices', '--help']) assert ret.success @@ -22,8 +22,8 @@ def test_execution_processing(script_runner, monkeypatch): in_dwi = os.path.join(SCILPY_HOME, 'processing', 'dwi_crop.nii.gz') in_bval = os.path.join(SCILPY_HOME, 'processing', 'dwi.bval') in_bvec = os.path.join(SCILPY_HOME, 'processing', 'dwi.bvec') - ret = script_runner.run('scil_dwi_split_by_indices.py', in_dwi, - in_bval, in_bvec, 'dwi', '5', '15', '25') + ret = script_runner.run(['scil_dwi_split_by_indices', in_dwi, + in_bval, in_bvec, 'dwi', '5', '15', '25']) assert ret.success @@ -32,9 +32,9 @@ def test_execution_processing_wrong_indices_given(script_runner, monkeypatch): in_dwi = os.path.join(SCILPY_HOME, 'processing', 'dwi_crop.nii.gz') in_bval = os.path.join(SCILPY_HOME, 'processing', 'dwi.bval') in_bvec = os.path.join(SCILPY_HOME, 'processing', 'dwi.bvec') - ret = script_runner.run('scil_dwi_split_by_indices.py', in_dwi, - in_bval, in_bvec, 'dwi', '0', '15', '25') + ret = script_runner.run(['scil_dwi_split_by_indices', in_dwi, + in_bval, in_bvec, 'dwi', '0', '15', '25']) assert (not ret.success) - ret = script_runner.run('scil_dwi_split_by_indices.py', in_dwi, - in_bval, in_bvec, 'dwi', '5', '15', '200') + ret = script_runner.run(['scil_dwi_split_by_indices', in_dwi, + in_bval, in_bvec, 'dwi', '5', '15', '200']) assert (not ret.success) diff --git a/scripts/tests/test_dwi_to_sh.py b/src/scilpy/cli/tests/test_dwi_to_sh.py similarity index 77% rename from scripts/tests/test_dwi_to_sh.py rename to src/scilpy/cli/tests/test_dwi_to_sh.py index ce417c823..1b8d81bba 100644 --- a/scripts/tests/test_dwi_to_sh.py +++ b/src/scilpy/cli/tests/test_dwi_to_sh.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_dwi_to_sh.py', '--help') + ret = script_runner.run(['scil_dwi_to_sh', '--help']) assert ret.success @@ -25,12 +25,12 @@ def test_execution_processing(script_runner, monkeypatch): '3000.bval') in_bvec = os.path.join(SCILPY_HOME, 'processing', '3000.bvec') - ret = script_runner.run('scil_dwi_to_sh.py', in_dwi, in_bval, - in_bvec, 'sh_1000.nii.gz') + ret = script_runner.run(['scil_dwi_to_sh', in_dwi, in_bval, + in_bvec, 'sh_1000.nii.gz']) assert ret.success # Test wrong b0. Current minimal b-value is 5. - ret = script_runner.run('scil_dwi_to_sh.py', in_dwi, in_bval, + ret = script_runner.run(['scil_dwi_to_sh', in_dwi, in_bval, in_bvec, 'sh_1000.nii.gz', '--b0_threshold', '1', - '-f') + '-f']) assert not ret.success diff --git a/scripts/tests/test_fibertube_compute_density.py b/src/scilpy/cli/tests/test_fibertube_compute_density.py similarity index 63% rename from scripts/tests/test_fibertube_compute_density.py rename to src/scilpy/cli/tests/test_fibertube_compute_density.py index ca05c9b0b..c2953fc2a 100644 --- a/scripts/tests/test_fibertube_compute_density.py +++ b/src/scilpy/cli/tests/test_fibertube_compute_density.py @@ -2,7 +2,6 @@ # -*- coding: utf-8 -*- import os -import json import tempfile import numpy as np import nibabel as nib @@ -31,36 +30,36 @@ def init_data(): sft_fibertubes = StatefulTractogram(streamlines, mask_img, Space.VOX, Origin.NIFTI) sft_fibertubes.data_per_streamline = { - "diameters": [0.2, 0.01] + "diameters": np.array([0.2, 0.01]) } save_tractogram(sft_fibertubes, 'fibertubes.trk', True) def test_help_option(script_runner): - ret = script_runner.run('scil_fibertube_compute_density.py', '--help') + ret = script_runner.run(['scil_fibertube_compute_density', '--help']) assert ret.success def test_execution_density(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) init_data() - ret = script_runner.run('scil_fibertube_compute_density.py', - 'fibertubes.trk', - '--out_density_map', 'density_map.nii.gz', - '--out_density_measures', - 'density_measures.json', - '-f') + ret = script_runner.run(['scil_fibertube_compute_density', + 'fibertubes.trk', + '--out_density_map', 'density_map.nii.gz', + '--out_density_measures', + 'density_measures.json', + '-f']) assert ret.success def test_execution_collisions(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) init_data() - ret = script_runner.run('scil_fibertube_compute_density.py', - 'fibertubes.trk', - '--out_collision_map', 'collision_map.nii.gz', - '--out_collision_measures', - 'collision_measures.json', - '-f') + ret = script_runner.run(['scil_fibertube_compute_density', + 'fibertubes.trk', + '--out_collision_map', 'collision_map.nii.gz', + '--out_collision_measures', + 'collision_measures.json', + '-f']) assert ret.success diff --git a/scripts/tests/test_fibertube_score_tractogram.py b/src/scilpy/cli/tests/test_fibertube_score_tractogram.py similarity index 79% rename from scripts/tests/test_fibertube_score_tractogram.py rename to src/scilpy/cli/tests/test_fibertube_score_tractogram.py index a1632993c..cdb6a533c 100644 --- a/scripts/tests/test_fibertube_score_tractogram.py +++ b/src/scilpy/cli/tests/test_fibertube_score_tractogram.py @@ -39,14 +39,14 @@ def init_data(): space=Space.VOX, origin=Origin.NIFTI) sft_fibertubes.data_per_streamline = { - "diameters": [0.002, 0.001] + "diameters": np.array([0.002, 0.001]) } sft_tracking = StatefulTractogram(streamlines, mask_img, space=Space.VOX, origin=Origin.NIFTI) sft_tracking.data_per_streamline = { - "seeds": [streamlines[0][0], streamlines[1][-1]], - "seed_ids": [0., 1.] + "seeds": np.array([streamlines[0][0], streamlines[1][-1]]), + "seed_ids": np.array([0, 1], dtype=np.uint32), } save_tractogram(sft_fibertubes, 'fibertubes.trk', True) @@ -57,14 +57,14 @@ def init_data(): def test_help_option(script_runner): - ret = script_runner.run('scil_fibertube_score_tractogram.py', '--help') + ret = script_runner.run(['scil_fibertube_score_tractogram', '--help']) assert ret.success def test_execution(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) init_data() - ret = script_runner.run('scil_fibertube_score_tractogram.py', - 'fibertubes.trk', 'tracking.trk', 'config.json', - 'metrics.json', '--save_error_tractogram', '-f') + ret = script_runner.run(['scil_fibertube_score_tractogram', + 'fibertubes.trk', 'tracking.trk', 'config.json', + 'metrics.json', '--save_error_tractogram', '-f']) assert ret.success diff --git a/src/scilpy/cli/tests/test_fibertube_tracking.py b/src/scilpy/cli/tests/test_fibertube_tracking.py new file mode 100644 index 000000000..d133bee7c --- /dev/null +++ b/src/scilpy/cli/tests/test_fibertube_tracking.py @@ -0,0 +1,151 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import os +import tempfile +import numpy as np +import nibabel as nib + +from scilpy.io.streamlines import save_tractogram +from dipy.io.stateful_tractogram import StatefulTractogram, Space, Origin + +tmp_dir = tempfile.TemporaryDirectory() + + +def init_data(): + streamlines = [[[5., 1., 5.], [5., 5., 9.], [7., 9., 9.], [13., 11., 9.], + [5., 7., 7.]], [[7., 7., 7.], [9., 9., 9.]]] + + mask = np.ones((15, 15, 15)) + affine = np.eye(4) + header = nib.nifti2.Nifti2Header() + extra = { + 'affine': affine, + 'dimensions': (15, 15, 15), + 'voxel_size': 1., + 'voxel_order': "RAS" + } + mask_img = nib.nifti2.Nifti2Image(mask, affine, header, extra) + + sft = StatefulTractogram(streamlines, mask_img, + space=Space.VOX, + origin=Origin.NIFTI) + sft.data_per_streamline = { + "diameters": np.array([0.002, 0.001]) + } + + save_tractogram(sft, 'tractogram.trk', True) + + +def test_help_option(script_runner): + ret = script_runner.run(['scil_fibertube_tracking', '--help']) + assert ret.success + + +def test_execution(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + init_data() + ret = script_runner.run(['scil_fibertube_tracking', + 'tractogram.trk', 'tracking.trk', + '--min_length', '0', '-f']) + assert ret.success + + +def test_execution_rk(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + init_data() + ret = script_runner.run(['scil_fibertube_tracking', + 'tractogram.trk', 'tracking.trk', + '--rk_order', '2', '--min_length', '0', '-f']) + assert ret.success + + +def test_execution_config(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + init_data() + ret = script_runner.run(['scil_fibertube_tracking', + 'tractogram.trk', 'tracking.trk', + '--blur_radius', '0.3', + '--step_size', '0.1', + '--out_config', 'config.json', + '--min_length', '0', '-f']) + assert ret.success + + +def test_execution_seeding(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + init_data() + ret = script_runner.run(['scil_fibertube_tracking', + 'tractogram.trk', 'tracking.trk', + '--nb_fibertubes', '1', + '--nb_seeds_per_fibertube', '3', '--skip', '3', + '--local_seeding', 'center', + '--min_length', '0', '-f']) + assert ret.success + + +def test_execution_FTODF(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + init_data() + ret = script_runner.run(['scil_fibertube_tracking', + 'tractogram.trk', 'tracking.trk', '--use_ftODF', + '--min_length', '0', '-f']) + assert ret.success + + +def test_execution_FTODF_rk(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + init_data() + ret = script_runner.run(['scil_fibertube_tracking', + 'tractogram.trk', 'tracking.trk', '--use_ftODF', + '--rk_order', '2', '--min_length', '0', '-f']) + assert ret.success + + +def test_execution_FTODF_config(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + init_data() + ret = script_runner.run(['scil_fibertube_tracking', + 'tractogram.trk', 'tracking.trk', '--use_ftODF', + '--blur_radius', '0.3', + '--step_size', '0.1', + '--out_config', 'config.json', + '--min_length', '0', '-f']) + assert ret.success + + +def test_execution_FTODF_seeding(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + init_data() + ret = script_runner.run(['scil_fibertube_tracking', + 'tractogram.trk', 'tracking.trk', '--use_ftODF', + '--nb_fibertubes', '1', + '--nb_seeds_per_fibertube', '3', '--skip', '3', + '--local_seeding', 'center', + '--min_length', '0', '-f']) + assert ret.success + + +def test_execution_FTODF_sphere(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + init_data() + ret = script_runner.run(['scil_fibertube_tracking', + 'tractogram.trk', 'tracking.trk', '--use_ftODF', + '--sh_order', '4', + '--sphere', 'symmetric362', + '--sh_basis', 'tournier07', + '--sub_sphere', '0', + '--sfthres', '0.05', + '--sfthres_init', '0.4', + '--min_length', '0', '-f']) + assert ret.success + + +def test_execution_FTODF_det(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + init_data() + ret = script_runner.run(['scil_fibertube_tracking', + 'tractogram.trk', 'tracking.trk', '--use_ftODF', + '--algo', 'det', + '--min_length', '0', '-f']) + assert ret.success diff --git a/scripts/tests/test_fodf_bundleparc.py b/src/scilpy/cli/tests/test_fodf_bundleparc.py similarity index 62% rename from scripts/tests/test_fodf_bundleparc.py rename to src/scilpy/cli/tests/test_fodf_bundleparc.py index 0107934d6..49ad7a59a 100644 --- a/scripts/tests/test_fodf_bundleparc.py +++ b/src/scilpy/cli/tests/test_fodf_bundleparc.py @@ -12,7 +12,7 @@ @pytest.mark.ml def test_help_option(script_runner, monkeypatch): - ret = script_runner.run('scil_fodf_bundleparc.py', '--help') + ret = script_runner.run(['scil_fodf_bundleparc', '--help']) assert ret.success @@ -21,8 +21,8 @@ def test_help_option(script_runner, monkeypatch): def test_execution(script_runner, monkeypatch): in_fodf = os.path.join(SCILPY_HOME, 'tracking', 'fodf.nii.gz') - ret = script_runner.run('scil_fodf_bundleparc.py', in_fodf, '-f', - '--bundles', 'FX_left') + ret = script_runner.run(['scil_fodf_bundleparc', in_fodf, '-f', + '--bundles', 'FX_left']) assert ret.success @@ -30,9 +30,9 @@ def test_execution(script_runner, monkeypatch): def test_execution_100_labels(script_runner, monkeypatch): in_fodf = os.path.join(SCILPY_HOME, 'tracking', 'fodf.nii.gz') - ret = script_runner.run('scil_fodf_bundleparc.py', in_fodf, - '--nb_pts', '100', '-f', '--bundles', - 'IFO_right') + ret = script_runner.run(['scil_fodf_bundleparc', in_fodf, + '--nb_pts', '100', '-f', '--bundles', + 'IFO_right']) assert ret.success @@ -40,9 +40,9 @@ def test_execution_100_labels(script_runner, monkeypatch): def test_execution_keep_biggest_blob(script_runner, monkeypatch): in_fodf = os.path.join(SCILPY_HOME, 'tracking', 'fodf.nii.gz') - ret = script_runner.run('scil_fodf_bundleparc.py', in_fodf, - '--keep_biggest_blob', '-f', '--bundles', - 'CA') + ret = script_runner.run(['scil_fodf_bundleparc', in_fodf, + '--keep_biggest_blob', '-f', '--bundles', + 'CA']) assert ret.success @@ -50,6 +50,6 @@ def test_execution_keep_biggest_blob(script_runner, monkeypatch): def test_execution_invalid_bundle(script_runner, monkeypatch): in_fodf = os.path.join(SCILPY_HOME, 'tracking', 'fodf.nii.gz') - ret = script_runner.run('scil_fodf_bundleparc.py', in_fodf, - '-f', '--bundles', 'CC') + ret = script_runner.run(['scil_fodf_bundleparc', in_fodf, + '-f', '--bundles', 'CC']) assert not ret.success diff --git a/scripts/tests/test_fodf_max_in_ventricles.py b/src/scilpy/cli/tests/test_fodf_max_in_ventricles.py similarity index 85% rename from scripts/tests/test_fodf_max_in_ventricles.py rename to src/scilpy/cli/tests/test_fodf_max_in_ventricles.py index 1a8b07f7c..51d69019f 100644 --- a/scripts/tests/test_fodf_max_in_ventricles.py +++ b/src/scilpy/cli/tests/test_fodf_max_in_ventricles.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_fodf_max_in_ventricles.py', '--help') + ret = script_runner.run(['scil_fodf_max_in_ventricles', '--help']) assert ret.success @@ -25,6 +25,6 @@ def test_execution_processing(script_runner, monkeypatch): 'fa.nii.gz') in_md = os.path.join(SCILPY_HOME, 'processing', 'md.nii.gz') - ret = script_runner.run('scil_fodf_max_in_ventricles.py', in_fodf, - in_fa, in_md, '--sh_basis', 'tournier07') + ret = script_runner.run(['scil_fodf_max_in_ventricles', in_fodf, + in_fa, in_md, '--sh_basis', 'tournier07']) assert ret.success diff --git a/scripts/tests/test_fodf_memsmt.py b/src/scilpy/cli/tests/test_fodf_memsmt.py similarity index 58% rename from scripts/tests/test_fodf_memsmt.py rename to src/scilpy/cli/tests/test_fodf_memsmt.py index 16ce86540..c649acaf9 100644 --- a/scripts/tests/test_fodf_memsmt.py +++ b/src/scilpy/cli/tests/test_fodf_memsmt.py @@ -12,7 +12,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_fodf_memsmt.py', '--help') + ret = script_runner.run(['scil_fodf_memsmt', '--help']) assert ret.success @@ -37,29 +37,29 @@ def test_inputs_check(script_runner, monkeypatch): in_csf_frf = os.path.join(SCILPY_HOME, 'btensor_testdata', 'csf_frf.txt') - ret = script_runner.run('scil_fodf_memsmt.py', in_wm_frf, - in_gm_frf, in_csf_frf, '--in_dwis', - in_dwi_lin, in_dwi_plan, '--in_bvals', - in_bval_lin, '--in_bvecs', in_bvec_lin, - '--in_bdeltas', '1', - '--wm_out_fODF', 'wm_fodf.nii.gz', - '--gm_out_fODF', 'gm_fodf.nii.gz', - '--csf_out_fODF', 'csf_fodf.nii.gz', '--vf', - 'vf.nii.gz', '--sh_order', '4', '--sh_basis', - 'tournier07', '--processes', '1', '-f') + ret = script_runner.run(['scil_fodf_memsmt', in_wm_frf, + in_gm_frf, in_csf_frf, '--in_dwis', + in_dwi_lin, in_dwi_plan, '--in_bvals', + in_bval_lin, '--in_bvecs', in_bvec_lin, + '--in_bdeltas', '1', + '--wm_out_fODF', 'wm_fodf.nii.gz', + '--gm_out_fODF', 'gm_fodf.nii.gz', + '--csf_out_fODF', 'csf_fodf.nii.gz', '--vf', + 'vf.nii.gz', '--sh_order', '4', '--sh_basis', + 'tournier07', '--processes', '1', '-f']) assert (not ret.success) - ret = script_runner.run('scil_fodf_memsmt.py', in_wm_frf, - in_gm_frf, in_csf_frf, '--in_dwis', - in_dwi_lin, in_dwi_plan, '--in_bvals', - in_bval_lin, in_bval_plan, '--in_bvecs', - in_bvec_lin, in_bvec_plan, '--in_bdeltas', - '1', '-0.5', '0', - '--wm_out_fODF', 'wm_fodf.nii.gz', - '--gm_out_fODF', 'gm_fodf.nii.gz', - '--csf_out_fODF', 'csf_fodf.nii.gz', '--vf', - 'vf.nii.gz', '--sh_order', '4', '--sh_basis', - 'tournier07', '--processes', '1', '-f') + ret = script_runner.run(['scil_fodf_memsmt', in_wm_frf, + in_gm_frf, in_csf_frf, '--in_dwis', + in_dwi_lin, in_dwi_plan, '--in_bvals', + in_bval_lin, in_bval_plan, '--in_bvecs', + in_bvec_lin, in_bvec_plan, '--in_bdeltas', + '1', '-0.5', '0', + '--wm_out_fODF', 'wm_fodf.nii.gz', + '--gm_out_fODF', 'gm_fodf.nii.gz', + '--csf_out_fODF', 'csf_fodf.nii.gz', '--vf', + 'vf.nii.gz', '--sh_order', '4', '--sh_basis', + 'tournier07', '--processes', '1', '-f']) assert (not ret.success) @@ -84,11 +84,11 @@ def test_execution_processing(script_runner, monkeypatch): in_csf_frf = os.path.join(SCILPY_HOME, 'btensor_testdata', 'csf_frf.txt') - ret = script_runner.run('scil_fodf_memsmt.py', in_wm_frf, - in_gm_frf, in_csf_frf, '--in_dwis', - in_dwi_lin, in_dwi_sph, '--in_bvals', - in_bval_lin, in_bval_sph, - '--in_bvecs', in_bvec_lin, - in_bvec_sph, '--in_bdeltas', '1', '0', - '--sh_order', '8', '--processes', '8', '-f') + ret = script_runner.run(['scil_fodf_memsmt', in_wm_frf, + in_gm_frf, in_csf_frf, '--in_dwis', + in_dwi_lin, in_dwi_sph, '--in_bvals', + in_bval_lin, in_bval_sph, + '--in_bvecs', in_bvec_lin, + in_bvec_sph, '--in_bdeltas', '1', '0', + '--sh_order', '8', '--processes', '8', '-f']) assert ret.success diff --git a/scripts/tests/test_fodf_metrics.py b/src/scilpy/cli/tests/test_fodf_metrics.py similarity index 59% rename from scripts/tests/test_fodf_metrics.py rename to src/scilpy/cli/tests/test_fodf_metrics.py index 3b1bc536e..48ac1e928 100644 --- a/scripts/tests/test_fodf_metrics.py +++ b/src/scilpy/cli/tests/test_fodf_metrics.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_fodf_metrics.py', '--help') + ret = script_runner.run(['scil_fodf_metrics', '--help']) assert ret.success @@ -21,10 +21,10 @@ def test_execution_processing(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_fodf = os.path.join(SCILPY_HOME, 'processing', 'fodf_descoteaux07.nii.gz') - ret = script_runner.run('scil_fodf_metrics.py', in_fodf, '--not_al', - '--peaks', 'peaks.nii.gz', - '--afd_max', 'afd_max.nii.gz', - '--afd_total', 'afd_tot.nii.gz', - '--afd_sum', 'afd_sum.nii.gz', - '--nufo', 'nufo.nii.gz', '--processes', '1') + ret = script_runner.run(['scil_fodf_metrics', in_fodf, '--not_al', + '--peaks', 'peaks.nii.gz', + '--afd_max', 'afd_max.nii.gz', + '--afd_total', 'afd_tot.nii.gz', + '--afd_sum', 'afd_sum.nii.gz', + '--nufo', 'nufo.nii.gz', '--processes', '1']) assert ret.success diff --git a/scripts/tests/test_fodf_msmt.py b/src/scilpy/cli/tests/test_fodf_msmt.py similarity index 61% rename from scripts/tests/test_fodf_msmt.py rename to src/scilpy/cli/tests/test_fodf_msmt.py index d2adfdab2..1cba71d7a 100644 --- a/scripts/tests/test_fodf_msmt.py +++ b/src/scilpy/cli/tests/test_fodf_msmt.py @@ -12,7 +12,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_fodf_msmt.py', '--help') + ret = script_runner.run(['scil_fodf_msmt', '--help']) assert ret.success @@ -26,13 +26,13 @@ def test_execution_processing(script_runner, monkeypatch): in_csf_frf = os.path.join(SCILPY_HOME, 'commit_amico', 'csf_frf.txt') mask = os.path.join(SCILPY_HOME, 'commit_amico', 'mask.nii.gz') - ret = script_runner.run('scil_fodf_msmt.py', in_dwi, in_bval, - in_bvec, in_wm_frf, in_gm_frf, in_csf_frf, - '--mask', mask, - '--wm_out_fODF', 'wm_fodf.nii.gz', - '--gm_out_fODF', 'gm_fodf.nii.gz', - '--csf_out_fODF', 'csf_fodf.nii.gz', - '--vf', 'vf.nii.gz', '--sh_order', '4', - '--sh_basis', 'tournier07', - '--processes', '1', '-f') + ret = script_runner.run(['scil_fodf_msmt', in_dwi, in_bval, + in_bvec, in_wm_frf, in_gm_frf, in_csf_frf, + '--mask', mask, + '--wm_out_fODF', 'wm_fodf.nii.gz', + '--gm_out_fODF', 'gm_fodf.nii.gz', + '--csf_out_fODF', 'csf_fodf.nii.gz', + '--vf', 'vf.nii.gz', '--sh_order', '4', + '--sh_basis', 'tournier07', + '--processes', '1', '-f']) assert ret.success diff --git a/scripts/tests/test_fodf_ssst.py b/src/scilpy/cli/tests/test_fodf_ssst.py similarity index 73% rename from scripts/tests/test_fodf_ssst.py rename to src/scilpy/cli/tests/test_fodf_ssst.py index b1a79cf9b..9e8278fcb 100644 --- a/scripts/tests/test_fodf_ssst.py +++ b/src/scilpy/cli/tests/test_fodf_ssst.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_fodf_ssst.py', '--help') + ret = script_runner.run(['scil_fodf_ssst', '--help']) assert ret.success @@ -27,14 +27,14 @@ def test_execution_processing(script_runner, monkeypatch): '3000.bvec') in_frf = os.path.join(SCILPY_HOME, 'processing', 'frf.txt') - ret = script_runner.run('scil_fodf_ssst.py', in_dwi, in_bval, + ret = script_runner.run(['scil_fodf_ssst', in_dwi, in_bval, in_bvec, in_frf, 'fodf.nii.gz', '--sh_order', '4', - '--sh_basis', 'tournier07', '--processes', '1') + '--sh_basis', 'tournier07', '--processes', '1']) assert ret.success # Test wrong b0. Current minimal b-value is 5. - ret = script_runner.run('scil_fodf_ssst.py', in_dwi, in_bval, - in_bvec, in_frf, 'fodf.nii.gz', '--sh_order', '4', - '--sh_basis', 'tournier07', '--processes', '1', - '--b0_threshold', '1', '-f') + ret = script_runner.run(['scil_fodf_ssst', in_dwi, in_bval, + in_bvec, in_frf, 'fodf.nii.gz', '--sh_order', '4', + '--sh_basis', 'tournier07', '--processes', '1', + '--b0_threshold', '1', '-f']) assert not ret.success diff --git a/scripts/tests/test_fodf_to_bingham.py b/src/scilpy/cli/tests/test_fodf_to_bingham.py similarity index 51% rename from scripts/tests/test_fodf_to_bingham.py rename to src/scilpy/cli/tests/test_fodf_to_bingham.py index c0a27a667..5fdbace46 100644 --- a/scripts/tests/test_fodf_to_bingham.py +++ b/src/scilpy/cli/tests/test_fodf_to_bingham.py @@ -13,8 +13,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_fodf_to_bingham.py', - '--help') + ret = script_runner.run(['scil_fodf_to_bingham', + '--help']) assert ret.success @@ -22,14 +22,14 @@ def test_execution_processing(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_fodf = os.path.join(SCILPY_HOME, 'processing', 'fodf_descoteaux07.nii.gz') - ret = script_runner.run('scil_fodf_to_bingham.py', - in_fodf, 'bingham.nii.gz', - '--max_lobes', '1', - '--at', '0.0', - '--rt', '0.1', - '--min_sep_angle', '25.', - '--max_fit_angle', '15.', - '--processes', '1') + ret = script_runner.run(['scil_fodf_to_bingham', + in_fodf, 'bingham.nii.gz', + '--max_lobes', '1', + '--at', '0.0', + '--rt', '0.1', + '--min_sep_angle', '25.', + '--max_fit_angle', '15.', + '--processes', '1']) assert ret.success @@ -39,13 +39,13 @@ def test_execution_processing_mask(script_runner, monkeypatch): 'fodf_descoteaux07.nii.gz') in_mask = os.path.join(SCILPY_HOME, 'processing', 'seed.nii.gz') - ret = script_runner.run('scil_fodf_to_bingham.py', - in_fodf, 'bingham.nii.gz', - '--max_lobes', '1', - '--at', '0.0', - '--rt', '0.1', - '--min_sep_angle', '25.', - '--max_fit_angle', '15.', - '--processes', '1', - '--mask', in_mask, '-f') + ret = script_runner.run(['scil_fodf_to_bingham', + in_fodf, 'bingham.nii.gz', + '--max_lobes', '1', + '--at', '0.0', + '--rt', '0.1', + '--min_sep_angle', '25.', + '--max_fit_angle', '15.', + '--processes', '1', + '--mask', in_mask, '-f']) assert ret.success diff --git a/scripts/tests/test_freewater_maps.py b/src/scilpy/cli/tests/test_freewater_maps.py similarity index 62% rename from scripts/tests/test_freewater_maps.py rename to src/scilpy/cli/tests/test_freewater_maps.py index 54b4f6746..156b0adee 100644 --- a/scripts/tests/test_freewater_maps.py +++ b/src/scilpy/cli/tests/test_freewater_maps.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_freewater_maps.py', '--help') + ret = script_runner.run(['scil_freewater_maps', '--help']) assert ret.success @@ -27,12 +27,12 @@ def test_execution_commit_amico(script_runner, monkeypatch): 'dwi.bvec') mask = os.path.join(SCILPY_HOME, 'commit_amico', 'mask.nii.gz') - ret = script_runner.run('scil_freewater_maps.py', in_dwi, - in_bval, in_bvec, '--mask', mask, - '--out_dir', 'freewater', '--b_thr', '30', - '--para_diff', '0.0015', - '--perp_diff_min', '0.0001', - '--perp_diff_max', '0.0007', - '--lambda1', '0.0', '--lambda2', '0.001', - '--processes', '1') + ret = script_runner.run(['scil_freewater_maps', in_dwi, + in_bval, in_bvec, '--mask', mask, + '--out_dir', 'freewater', '--b_thr', '30', + '--para_diff', '0.0015', + '--perp_diff_min', '0.0001', + '--perp_diff_max', '0.0007', + '--lambda1', '0.0', '--lambda2', '0.001', + '--processes', '1']) assert ret.success diff --git a/scripts/tests/test_dwi_convert_FDF.py b/src/scilpy/cli/tests/test_freewater_priors.py similarity index 63% rename from scripts/tests/test_dwi_convert_FDF.py rename to src/scilpy/cli/tests/test_freewater_priors.py index 582473264..1a056ea72 100644 --- a/scripts/tests/test_dwi_convert_FDF.py +++ b/src/scilpy/cli/tests/test_freewater_priors.py @@ -3,5 +3,5 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_dwi_convert_FDF.py', '--help') + ret = script_runner.run(['scil_freewater_priors', '--help']) assert ret.success diff --git a/scripts/tests/test_frf_mean.py b/src/scilpy/cli/tests/test_frf_mean.py similarity index 74% rename from scripts/tests/test_frf_mean.py rename to src/scilpy/cli/tests/test_frf_mean.py index 436d7c144..21ba45688 100644 --- a/scripts/tests/test_frf_mean.py +++ b/src/scilpy/cli/tests/test_frf_mean.py @@ -14,29 +14,29 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_frf_mean.py', '--help') + ret = script_runner.run(['scil_frf_mean', '--help']) assert ret.success def test_execution_processing_ssst(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_frf = os.path.join(SCILPY_HOME, 'processing', 'frf.txt') - ret = script_runner.run('scil_frf_mean.py', in_frf, in_frf, 'mfrf1.txt') + ret = script_runner.run(['scil_frf_mean', in_frf, in_frf, 'mfrf1.txt']) assert ret.success def test_execution_processing_msmt(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_frf = os.path.join(SCILPY_HOME, 'commit_amico', 'wm_frf.txt') - ret = script_runner.run('scil_frf_mean.py', in_frf, in_frf, 'mfrf2.txt') + ret = script_runner.run(['scil_frf_mean', in_frf, in_frf, 'mfrf2.txt']) assert ret.success def test_outputs_precision(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_frf = os.path.join(SCILPY_HOME, 'commit_amico', 'wm_frf.txt') - ret = script_runner.run('scil_frf_mean.py', in_frf, in_frf, 'mfrfp.txt', - '--precision', '4') + ret = script_runner.run(['scil_frf_mean', in_frf, in_frf, 'mfrfp.txt', + '--precision', '4']) assert ret.success expected = [ @@ -45,13 +45,13 @@ def test_outputs_precision(script_runner, monkeypatch): "0.0009 0.0003 0.0003 3076.7249" ] with open('mfrfp.txt', 'r') as result: - for i, line in enumerate(result.readlines()): - assert line.strip("\n") == expected[i] + for i, line in enumerate(result.readlines()): + assert line.strip("\n") == expected[i] def test_execution_processing_bad_input(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_wm_frf = os.path.join(SCILPY_HOME, 'commit_amico', 'wm_frf.txt') in_frf = os.path.join(SCILPY_HOME, 'processing', 'frf.txt') - ret = script_runner.run('scil_frf_mean.py', in_wm_frf, in_frf, 'mfrf3.txt') + ret = script_runner.run(['scil_frf_mean', in_wm_frf, in_frf, 'mfrf3.txt']) assert not ret.success diff --git a/scripts/tests/test_frf_memsmt.py b/src/scilpy/cli/tests/test_frf_memsmt.py similarity index 61% rename from scripts/tests/test_frf_memsmt.py rename to src/scilpy/cli/tests/test_frf_memsmt.py index e60de7607..0a443f5f4 100644 --- a/scripts/tests/test_frf_memsmt.py +++ b/src/scilpy/cli/tests/test_frf_memsmt.py @@ -12,7 +12,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_frf_memsmt.py', '--help') + ret = script_runner.run(['scil_frf_memsmt', '--help']) assert ret.success @@ -37,13 +37,13 @@ def test_roi_center_shape_parameter(script_runner, monkeypatch): in_bvec_sph = os.path.join(SCILPY_HOME, 'btensor_testdata', 'spherical.bvecs') - ret = script_runner.run('scil_frf_memsmt.py', 'wm_frf.txt', - 'gm_frf.txt', 'csf_frf.txt', '--in_dwis', - in_dwi_lin, in_dwi_plan, in_dwi_sph, '--in_bvals', - in_bval_lin, in_bval_plan, in_bval_sph, - '--in_bvecs', in_bvec_lin, in_bvec_plan, - in_bvec_sph, '--in_bdeltas', '1', '-0.5', '0', - '--roi_center', '1', '--min_nvox', '1', '-f') + ret = script_runner.run(['scil_frf_memsmt', 'wm_frf.txt', + 'gm_frf.txt', 'csf_frf.txt', '--in_dwis', + in_dwi_lin, in_dwi_plan, in_dwi_sph, '--in_bvals', + in_bval_lin, in_bval_plan, in_bval_sph, + '--in_bvecs', in_bvec_lin, in_bvec_plan, + in_bvec_sph, '--in_bdeltas', '1', '-0.5', '0', + '--roi_center', '1', '--min_nvox', '1', '-f']) assert (not ret.success) @@ -68,33 +68,33 @@ def test_roi_radii_shape_parameter(script_runner, monkeypatch): 'spherical.bvals') in_bvec_sph = os.path.join(SCILPY_HOME, 'btensor_testdata', 'spherical.bvecs') - ret = script_runner.run('scil_frf_memsmt.py', 'wm_frf.txt', - 'gm_frf.txt', 'csf_frf.txt', '--in_dwis', - in_dwi_lin, in_dwi_plan, in_dwi_sph, '--in_bvals', - in_bval_lin, in_bval_plan, in_bval_sph, - '--in_bvecs', in_bvec_lin, in_bvec_plan, - in_bvec_sph, '--in_bdeltas', '1', '-0.5', '0', - '--roi_radii', '37', '--min_nvox', '1', '-f') + ret = script_runner.run(['scil_frf_memsmt', 'wm_frf.txt', + 'gm_frf.txt', 'csf_frf.txt', '--in_dwis', + in_dwi_lin, in_dwi_plan, in_dwi_sph, '--in_bvals', + in_bval_lin, in_bval_plan, in_bval_sph, + '--in_bvecs', in_bvec_lin, in_bvec_plan, + in_bvec_sph, '--in_bdeltas', '1', '-0.5', '0', + '--roi_radii', '37', '--min_nvox', '1', '-f']) assert ret.success - ret = script_runner.run('scil_frf_memsmt.py', 'wm_frf.txt', - 'gm_frf.txt', 'csf_frf.txt', '--in_dwis', - in_dwi_lin, in_dwi_plan, in_dwi_sph, '--in_bvals', - in_bval_lin, in_bval_plan, in_bval_sph, - '--in_bvecs', in_bvec_lin, in_bvec_plan, - in_bvec_sph, '--in_bdeltas', '1', '-0.5', '0', - '--roi_radii', '37', '37', '37', - '--min_nvox', '1', '-f') + ret = script_runner.run(['scil_frf_memsmt', 'wm_frf.txt', + 'gm_frf.txt', 'csf_frf.txt', '--in_dwis', + in_dwi_lin, in_dwi_plan, in_dwi_sph, '--in_bvals', + in_bval_lin, in_bval_plan, in_bval_sph, + '--in_bvecs', in_bvec_lin, in_bvec_plan, + in_bvec_sph, '--in_bdeltas', '1', '-0.5', '0', + '--roi_radii', '37', '37', '37', + '--min_nvox', '1', '-f']) assert ret.success - ret = script_runner.run('scil_frf_memsmt.py', 'wm_frf.txt', - 'gm_frf.txt', 'csf_frf.txt', '--in_dwis', - in_dwi_lin, in_dwi_plan, in_dwi_sph, '--in_bvals', - in_bval_lin, in_bval_plan, in_bval_sph, - '--in_bvecs', in_bvec_lin, in_bvec_plan, - in_bvec_sph, '--in_bdeltas', '1', '-0.5', '0', - '--roi_radii', '37', '37', '37', '37', '37', - '--min_nvox', '1', '-f') + ret = script_runner.run(['scil_frf_memsmt', 'wm_frf.txt', + 'gm_frf.txt', 'csf_frf.txt', '--in_dwis', + in_dwi_lin, in_dwi_plan, in_dwi_sph, '--in_bvals', + in_bval_lin, in_bval_plan, in_bval_sph, + '--in_bvecs', in_bvec_lin, in_bvec_plan, + in_bvec_sph, '--in_bdeltas', '1', '-0.5', '0', + '--roi_radii', '37', '37', '37', '37', '37', + '--min_nvox', '1', '-f']) assert (not ret.success) @@ -114,19 +114,19 @@ def test_inputs_check(script_runner, monkeypatch): in_bvec_plan = os.path.join(SCILPY_HOME, 'btensor_testdata', 'planar.bvecs') - ret = script_runner.run('scil_frf_memsmt.py', 'wm_frf.txt', - 'gm_frf.txt', 'csf_frf.txt', '--in_dwis', - in_dwi_lin, in_dwi_plan, '--in_bvals', - in_bval_lin, '--in_bvecs', in_bvec_lin, - '--in_bdeltas', '1', '--min_nvox', '1', '-f') + ret = script_runner.run(['scil_frf_memsmt', 'wm_frf.txt', + 'gm_frf.txt', 'csf_frf.txt', '--in_dwis', + in_dwi_lin, in_dwi_plan, '--in_bvals', + in_bval_lin, '--in_bvecs', in_bvec_lin, + '--in_bdeltas', '1', '--min_nvox', '1', '-f']) assert (not ret.success) - ret = script_runner.run('scil_frf_memsmt.py', 'wm_frf.txt', - 'gm_frf.txt', 'csf_frf.txt', '--in_dwis', - in_dwi_lin, in_dwi_plan, '--in_bvals', - in_bval_lin, in_bval_plan, '--in_bvecs', - in_bvec_lin, in_bvec_plan, '--in_bdeltas', - '1', '-0.5', '0', '--min_nvox', '1', '-f') + ret = script_runner.run(['scil_frf_memsmt', 'wm_frf.txt', + 'gm_frf.txt', 'csf_frf.txt', '--in_dwis', + in_dwi_lin, in_dwi_plan, '--in_bvals', + in_bval_lin, in_bval_plan, '--in_bvecs', + in_bvec_lin, in_bvec_plan, '--in_bdeltas', + '1', '-0.5', '0', '--min_nvox', '1', '-f']) assert (not ret.success) @@ -150,13 +150,13 @@ def test_outputs_precision(script_runner, monkeypatch): 'spherical.bvals') in_bvec_sph = os.path.join(SCILPY_HOME, 'btensor_testdata', 'spherical.bvecs') - ret = script_runner.run('scil_frf_memsmt.py', 'wm_frf.txt', - 'gm_frf.txt', 'csf_frf.txt', '--in_dwis', - in_dwi_lin, in_dwi_plan, in_dwi_sph, '--in_bvals', - in_bval_lin, in_bval_plan, in_bval_sph, - '--in_bvecs', in_bvec_lin, in_bvec_plan, - in_bvec_sph, '--in_bdeltas', '1', '-0.5', '0', - '--min_nvox', '1', '--precision', '4', '-f') + ret = script_runner.run(['scil_frf_memsmt', 'wm_frf.txt', + 'gm_frf.txt', 'csf_frf.txt', '--in_dwis', + in_dwi_lin, in_dwi_plan, in_dwi_sph, '--in_bvals', + in_bval_lin, in_bval_plan, in_bval_sph, + '--in_bvecs', in_bvec_lin, in_bvec_plan, + in_bvec_sph, '--in_bdeltas', '1', '-0.5', '0', + '--min_nvox', '1', '--precision', '4', '-f']) assert ret.success @@ -186,11 +186,11 @@ def test_execution_processing(script_runner, monkeypatch): 'spherical.bvals') in_bvec_sph = os.path.join(SCILPY_HOME, 'btensor_testdata', 'spherical.bvecs') - ret = script_runner.run('scil_frf_memsmt.py', 'wm_frf.txt', - 'gm_frf.txt', 'csf_frf.txt', '--in_dwis', - in_dwi_lin, in_dwi_plan, in_dwi_sph, '--in_bvals', - in_bval_lin, in_bval_plan, in_bval_sph, - '--in_bvecs', in_bvec_lin, in_bvec_plan, - in_bvec_sph, '--in_bdeltas', '1', '-0.5', '0', - '--min_nvox', '1', '-f') + ret = script_runner.run(['scil_frf_memsmt', 'wm_frf.txt', + 'gm_frf.txt', 'csf_frf.txt', '--in_dwis', + in_dwi_lin, in_dwi_plan, in_dwi_sph, '--in_bvals', + in_bval_lin, in_bval_plan, in_bval_sph, + '--in_bvecs', in_bvec_lin, in_bvec_plan, + in_bvec_sph, '--in_bdeltas', '1', '-0.5', '0', + '--min_nvox', '1', '-f']) assert ret.success diff --git a/scripts/tests/test_frf_msmt.py b/src/scilpy/cli/tests/test_frf_msmt.py similarity index 56% rename from scripts/tests/test_frf_msmt.py rename to src/scilpy/cli/tests/test_frf_msmt.py index a919e5afc..ee19db8e6 100644 --- a/scripts/tests/test_frf_msmt.py +++ b/src/scilpy/cli/tests/test_frf_msmt.py @@ -12,7 +12,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_frf_msmt.py', '--help') + ret = script_runner.run(['scil_frf_msmt', '--help']) assert ret.success @@ -25,23 +25,23 @@ def test_roi_radii_shape_parameter(script_runner, monkeypatch): in_bvec = os.path.join(SCILPY_HOME, 'commit_amico', 'dwi.bvec') mask = os.path.join(SCILPY_HOME, 'commit_amico', 'mask.nii.gz') - ret = script_runner.run('scil_frf_msmt.py', in_dwi, - in_bval, in_bvec, 'wm_frf.txt', 'gm_frf.txt', - 'csf_frf.txt', '--mask', mask, '--roi_center', - '15', '15', '15', '-f') + ret = script_runner.run(['scil_frf_msmt', in_dwi, + in_bval, in_bvec, 'wm_frf.txt', 'gm_frf.txt', + 'csf_frf.txt', '--mask', mask, '--roi_center', + '15', '15', '15', '-f']) assert ret.success # Test wrong tolerance, leading to no b0. Current minimal b-val is 5. - ret = script_runner.run('scil_frf_msmt.py', in_dwi, - in_bval, in_bvec, 'wm_frf.txt', 'gm_frf.txt', - 'csf_frf.txt', '--mask', mask, '--roi_center', - '15', '15', '15', '-f', '--tol', '1') + ret = script_runner.run(['scil_frf_msmt', in_dwi, + in_bval, in_bvec, 'wm_frf.txt', 'gm_frf.txt', + 'csf_frf.txt', '--mask', mask, '--roi_center', + '15', '15', '15', '-f', '--tol', '1']) assert not ret.success - ret = script_runner.run('scil_frf_msmt.py', in_dwi, - in_bval, in_bvec, 'wm_frf.txt', 'gm_frf.txt', - 'csf_frf.txt', '--mask', mask, '--roi_center', - '15', '-f') + ret = script_runner.run(['scil_frf_msmt', in_dwi, + in_bval, in_bvec, 'wm_frf.txt', 'gm_frf.txt', + 'csf_frf.txt', '--mask', mask, '--roi_center', + '15', '-f']) assert (not ret.success) @@ -55,22 +55,22 @@ def test_roi_radii_shape_parameter2(script_runner, monkeypatch): in_bvec = os.path.join(SCILPY_HOME, 'commit_amico', 'dwi.bvec') mask = os.path.join(SCILPY_HOME, 'commit_amico', 'mask.nii.gz') - ret = script_runner.run('scil_frf_msmt.py', in_dwi, - in_bval, in_bvec, 'wm_frf.txt', 'gm_frf.txt', - 'csf_frf.txt', '--mask', mask, '--roi_radii', - '37', '-f') + ret = script_runner.run(['scil_frf_msmt', in_dwi, + in_bval, in_bvec, 'wm_frf.txt', 'gm_frf.txt', + 'csf_frf.txt', '--mask', mask, '--roi_radii', + '37', '-f']) assert ret.success - ret = script_runner.run('scil_frf_msmt.py', in_dwi, - in_bval, in_bvec, 'wm_frf.txt', 'gm_frf.txt', - 'csf_frf.txt', '--mask', mask, '--roi_radii', - '37', '37', '37', '-f') + ret = script_runner.run(['scil_frf_msmt', in_dwi, + in_bval, in_bvec, 'wm_frf.txt', 'gm_frf.txt', + 'csf_frf.txt', '--mask', mask, '--roi_radii', + '37', '37', '37', '-f']) assert ret.success - ret = script_runner.run('scil_frf_msmt.py', in_dwi, - in_bval, in_bvec, 'wm_frf.txt', 'gm_frf.txt', - 'csf_frf.txt', '--mask', mask, '--roi_radii', - '37', '37', '37', '37', '37', '-f') + ret = script_runner.run(['scil_frf_msmt', in_dwi, + in_bval, in_bvec, 'wm_frf.txt', 'gm_frf.txt', + 'csf_frf.txt', '--mask', mask, '--roi_radii', + '37', '37', '37', '37', '37', '-f']) assert (not ret.success) @@ -84,10 +84,10 @@ def test_outputs_precision(script_runner, monkeypatch): in_bvec = os.path.join(SCILPY_HOME, 'commit_amico', 'dwi.bvec') mask = os.path.join(SCILPY_HOME, 'commit_amico', 'mask.nii.gz') - ret = script_runner.run('scil_frf_msmt.py', in_dwi, - in_bval, in_bvec, 'wm_frf.txt', 'gm_frf.txt', - 'csf_frf.txt', '--mask', mask, '--min_nvox', '20', - '--precision', '4', '-f') + ret = script_runner.run(['scil_frf_msmt', in_dwi, + in_bval, in_bvec, 'wm_frf.txt', 'gm_frf.txt', + 'csf_frf.txt', '--mask', mask, '--min_nvox', '20', + '--precision', '4', '-f']) assert ret.success for frf_file in ['wm_frf.txt', 'gm_frf.txt', 'csf_frf.txt']: @@ -105,8 +105,8 @@ def test_execution_processing(script_runner, monkeypatch): in_bvec = os.path.join(SCILPY_HOME, 'commit_amico', 'dwi.bvec') mask = os.path.join(SCILPY_HOME, 'commit_amico', 'mask.nii.gz') - ret = script_runner.run('scil_frf_msmt.py', in_dwi, - in_bval, in_bvec, 'wm_frf.txt', 'gm_frf.txt', - 'csf_frf.txt', '--mask', mask, '--min_nvox', '20', - '-f') + ret = script_runner.run(['scil_frf_msmt', in_dwi, + in_bval, in_bvec, 'wm_frf.txt', 'gm_frf.txt', + 'csf_frf.txt', '--mask', mask, '--min_nvox', '20', + '-f']) assert ret.success diff --git a/scripts/tests/test_frf_set_diffusivities.py b/src/scilpy/cli/tests/test_frf_set_diffusivities.py similarity index 67% rename from scripts/tests/test_frf_set_diffusivities.py rename to src/scilpy/cli/tests/test_frf_set_diffusivities.py index de40559fa..3cc7b0685 100644 --- a/scripts/tests/test_frf_set_diffusivities.py +++ b/src/scilpy/cli/tests/test_frf_set_diffusivities.py @@ -3,7 +3,6 @@ import os import tempfile -import numpy as np from scilpy import SCILPY_HOME from scilpy.io.fetcher import fetch_data, get_testing_files_dict @@ -15,32 +14,32 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_frf_set_diffusivities.py', '--help') + ret = script_runner.run(['scil_frf_set_diffusivities', '--help']) assert ret.success def test_execution_processing_ssst(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_frf = os.path.join(SCILPY_HOME, 'processing', 'frf.txt') - ret = script_runner.run('scil_frf_set_diffusivities.py', in_frf, - '15,4,4', 'new_frf.txt', '-f') + ret = script_runner.run(['scil_frf_set_diffusivities', in_frf, + '15,4,4', 'new_frf.txt', '-f']) assert ret.success def test_execution_processing_msmt(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_frf = os.path.join(SCILPY_HOME, 'commit_amico', 'wm_frf.txt') - ret = script_runner.run('scil_frf_set_diffusivities.py', in_frf, - '15,4,4,13,4,4,12,5,5', 'new_frf.txt', '-f') + ret = script_runner.run(['scil_frf_set_diffusivities', in_frf, + '15,4,4,13,4,4,12,5,5', 'new_frf.txt', '-f']) assert ret.success def test_outputs_precision(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_frf = os.path.join(SCILPY_HOME, 'commit_amico', 'wm_frf.txt') - ret = script_runner.run('scil_frf_set_diffusivities.py', in_frf, - '15,4,4,13,4,4,12,5,5', 'new_frf.txt', - '--precision', '4', '-f') + ret = script_runner.run(['scil_frf_set_diffusivities', in_frf, + '15,4,4,13,4,4,12,5,5', 'new_frf.txt', + '--precision', '4', '-f']) assert ret.success expected = [ @@ -50,12 +49,12 @@ def test_outputs_precision(script_runner, monkeypatch): ] with open('new_frf.txt', 'r') as result: for i, line in enumerate(result.readlines()): - assert line.strip("\n") == expected[i] + assert line.strip("\n") == expected[i] def test_execution_processing__wrong_input(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_frf = os.path.join(SCILPY_HOME, 'commit_amico', 'wm_frf.txt') - ret = script_runner.run('scil_frf_set_diffusivities.py', in_frf, - '15,4,4,13,4,4', 'new_frf.txt', '-f') + ret = script_runner.run(['scil_frf_set_diffusivities', in_frf, + '15,4,4,13,4,4', 'new_frf.txt', '-f']) assert not ret.success diff --git a/scripts/tests/test_frf_ssst.py b/src/scilpy/cli/tests/test_frf_ssst.py similarity index 69% rename from scripts/tests/test_frf_ssst.py rename to src/scilpy/cli/tests/test_frf_ssst.py index 5f02d018e..482518312 100644 --- a/scripts/tests/test_frf_ssst.py +++ b/src/scilpy/cli/tests/test_frf_ssst.py @@ -16,55 +16,55 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_frf_ssst.py', '--help') + ret = script_runner.run(['scil_frf_ssst', '--help']) assert ret.success def test_roi_center_parameter(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_frf_ssst.py', in_dwi, + ret = script_runner.run(['scil_frf_ssst', in_dwi, in_bval, in_bvec, 'frf.txt', '--roi_center', - '15', '15', '15', '-f') + '15', '15', '15', '-f']) assert ret.success - ret = script_runner.run('scil_frf_ssst.py', in_dwi, + ret = script_runner.run(['scil_frf_ssst', in_dwi, in_bval, in_bvec, 'frf.txt', '--roi_center', - '15', '-f') + '15', '-f']) assert (not ret.success) # Test wrong b0 threshold. Current minimal b-value is 5. - ret = script_runner.run('scil_frf_ssst.py', in_dwi, + ret = script_runner.run(['scil_frf_ssst', in_dwi, in_bval, in_bvec, 'frf.txt', '--roi_center', - '15', '15', '15', '-f', '--b0_threshold', '1') + '15', '15', '15', '-f', '--b0_threshold', '1']) assert not ret.success def test_roi_radii_shape_parameter(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_frf_ssst.py', in_dwi, + ret = script_runner.run(['scil_frf_ssst', in_dwi, in_bval, in_bvec, 'frf.txt', '--roi_radii', - '37', '-f') + '37', '-f']) assert ret.success - ret = script_runner.run('scil_frf_ssst.py', in_dwi, + ret = script_runner.run(['scil_frf_ssst', in_dwi, in_bval, in_bvec, 'frf.txt', '--roi_radii', - '37', '37', '37', '-f') + '37', '37', '37', '-f']) assert ret.success - ret = script_runner.run('scil_frf_ssst.py', in_dwi, + ret = script_runner.run(['scil_frf_ssst', in_dwi, in_bval, in_bvec, 'frf.txt', '--roi_radii', - '37', '37', '37', '37', '37', '-f') + '37', '37', '37', '37', '37', '-f']) assert (not ret.success) def test_outputs_precision(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_frf_ssst.py', in_dwi, + ret = script_runner.run(['scil_frf_ssst', in_dwi, in_bval, in_bvec, 'frf.txt', - '--precision', '4', '-f') + '--precision', '4', '-f']) assert ret.success with open("frf.txt", "r") as f: @@ -74,6 +74,6 @@ def test_outputs_precision(script_runner, monkeypatch): def test_execution_processing(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_frf_ssst.py', in_dwi, - in_bval, in_bvec, 'frf.txt', '-f') + ret = script_runner.run(['scil_frf_ssst', in_dwi, + in_bval, in_bvec, 'frf.txt', '-f']) assert ret.success diff --git a/src/scilpy/cli/tests/test_get_version.py b/src/scilpy/cli/tests/test_get_version.py new file mode 100644 index 000000000..bfba0f043 --- /dev/null +++ b/src/scilpy/cli/tests/test_get_version.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + + +def test_help_option(script_runner): + ret = script_runner.run(['scil_get_version', '--help']) + assert ret.success + + +def test_execution(script_runner): + ret = script_runner.run(['scil_get_version']) + assert ret.success diff --git a/scripts/tests/test_gradients_apply_transform.py b/src/scilpy/cli/tests/test_gradients_apply_transform.py similarity index 86% rename from scripts/tests/test_gradients_apply_transform.py rename to src/scilpy/cli/tests/test_gradients_apply_transform.py index 8d27063cb..74f315866 100644 --- a/scripts/tests/test_gradients_apply_transform.py +++ b/src/scilpy/cli/tests/test_gradients_apply_transform.py @@ -14,7 +14,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_gradients_apply_transform.py', '--help') + ret = script_runner.run(['scil_gradients_apply_transform', '--help']) assert ret.success @@ -24,7 +24,7 @@ def test_execution_bst(script_runner, monkeypatch): 'dwi.bvec') in_aff = os.path.join(SCILPY_HOME, 'bst', 'output0GenericAffine.mat') - ret = script_runner.run('scil_gradients_apply_transform.py', + ret = script_runner.run(['scil_gradients_apply_transform', in_bvecs, in_aff, - 'bvecs_transformed.bvec', '--inverse') + 'bvecs_transformed.bvec', '--inverse']) assert ret.success diff --git a/scripts/tests/test_gradients_convert.py b/src/scilpy/cli/tests/test_gradients_convert.py similarity index 76% rename from scripts/tests/test_gradients_convert.py rename to src/scilpy/cli/tests/test_gradients_convert.py index 6f4addbb8..879e5c22f 100644 --- a/scripts/tests/test_gradients_convert.py +++ b/src/scilpy/cli/tests/test_gradients_convert.py @@ -13,8 +13,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_gradients_convert.py', - '--help') + ret = script_runner.run(['scil_gradients_convert', + '--help']) assert ret.success @@ -24,9 +24,9 @@ def test_execution_processing_fsl(script_runner, monkeypatch): '1000.bval') in_bvec = os.path.join(SCILPY_HOME, 'processing', '1000.bvec') - ret = script_runner.run('scil_gradients_convert.py', - '--input_fsl', - in_bval, in_bvec, '1000') + ret = script_runner.run(['scil_gradients_convert', + '--input_fsl', + in_bval, in_bvec, '1000']) assert ret.success @@ -34,9 +34,9 @@ def test_execution_processing_mrtrix(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_encoding = os.path.join(SCILPY_HOME, 'processing', '1000.b') - ret = script_runner.run('scil_gradients_convert.py', - '--input_mrtrix', - in_encoding, '1000') + ret = script_runner.run(['scil_gradients_convert', + '--input_mrtrix', + in_encoding, '1000']) assert ret.success @@ -46,9 +46,9 @@ def test_name_validation_mrtrix(script_runner, monkeypatch): '1000.bval') in_bvec = os.path.join(SCILPY_HOME, 'processing', '1000.bvec') - ret = script_runner.run('scil_gradients_convert.py', - '--input_fsl', - in_bval, in_bvec, '1000_test.b') + ret = script_runner.run(['scil_gradients_convert', + '--input_fsl', + in_bval, in_bvec, '1000_test.b']) assert ret.success wrong_path = os.path.join(tmp_dir.name, '1000_test.b.b') @@ -62,9 +62,9 @@ def test_name_validation_fsl_bval(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_encoding = os.path.join(SCILPY_HOME, 'processing', '1000.b') - ret = script_runner.run('scil_gradients_convert.py', - '--input_mrtrix', - in_encoding, '1000_test.bval') + ret = script_runner.run(['scil_gradients_convert', + '--input_mrtrix', + in_encoding, '1000_test.bval']) assert ret.success wrong_path_bval = os.path.join(tmp_dir.name, '1000_test.bval.bval') @@ -82,9 +82,9 @@ def test_name_validation_fsl_bvec(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_encoding = os.path.join(SCILPY_HOME, 'processing', '1000.b') - ret = script_runner.run('scil_gradients_convert.py', - '--input_mrtrix', - in_encoding, '1000_test.bvec') + ret = script_runner.run(['scil_gradients_convert', + '--input_mrtrix', + in_encoding, '1000_test.bvec']) assert ret.success wrong_path_bval = os.path.join(tmp_dir.name, '1000_test.bvec.bval') diff --git a/scripts/tests/test_gradients_generate_sampling.py b/src/scilpy/cli/tests/test_gradients_generate_sampling.py similarity index 59% rename from scripts/tests/test_gradients_generate_sampling.py rename to src/scilpy/cli/tests/test_gradients_generate_sampling.py index 2ee25ebb4..f4d8ba619 100644 --- a/scripts/tests/test_gradients_generate_sampling.py +++ b/src/scilpy/cli/tests/test_gradients_generate_sampling.py @@ -13,14 +13,14 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_gradients_generate_sampling.py', '--help') + ret = script_runner.run(['scil_gradients_generate_sampling', '--help']) assert ret.success def test_execution_others(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_gradients_generate_sampling.py', - '6', '6', 'encoding.b', '--mrtrix', '--eddy', - '--duty', '--b0_every', '25', '--b0_end', - '--bvals', '800', '1200') + ret = script_runner.run(['scil_gradients_generate_sampling', + '6', '6', 'encoding.b', '--mrtrix', '--eddy', + '--duty', '--b0_every', '25', '--b0_end', + '--bvals', '800', '1200']) assert ret.success diff --git a/scripts/tests/test_gradients_modify_axes.py b/src/scilpy/cli/tests/test_gradients_modify_axes.py similarity index 68% rename from scripts/tests/test_gradients_modify_axes.py rename to src/scilpy/cli/tests/test_gradients_modify_axes.py index c2b89c99b..5f66f3bdd 100644 --- a/scripts/tests/test_gradients_modify_axes.py +++ b/src/scilpy/cli/tests/test_gradients_modify_axes.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_gradients_modify_axes.py', '--help') + ret = script_runner.run(['scil_gradients_modify_axes', '--help']) assert ret.success @@ -22,12 +22,12 @@ def test_execution_processing(script_runner, monkeypatch): # mrtrix in_encoding = os.path.join(SCILPY_HOME, 'processing', '1000.b') - ret = script_runner.run('scil_gradients_modify_axes.py', in_encoding, - '1000_flip.b', '-1', '3', '2') + ret = script_runner.run(['scil_gradients_modify_axes', in_encoding, + '1000_flip.b', '-1', '3', '2']) assert ret.success # FSL in_encoding = os.path.join(SCILPY_HOME, 'processing', '1000.bvec') - ret = script_runner.run('scil_gradients_modify_axes.py', in_encoding, - '1000_flip.bvec', '1', '-3', '2') + ret = script_runner.run(['scil_gradients_modify_axes', in_encoding, + '1000_flip.bvec', '1', '-3', '2']) assert ret.success diff --git a/scripts/tests/test_gradients_normalize_bvecs.py b/src/scilpy/cli/tests/test_gradients_normalize_bvecs.py similarity index 74% rename from scripts/tests/test_gradients_normalize_bvecs.py rename to src/scilpy/cli/tests/test_gradients_normalize_bvecs.py index d05c236cb..d8ad1b1bf 100644 --- a/scripts/tests/test_gradients_normalize_bvecs.py +++ b/src/scilpy/cli/tests/test_gradients_normalize_bvecs.py @@ -13,8 +13,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_gradients_normalize_bvecs.py', - '--help') + ret = script_runner.run(['scil_gradients_normalize_bvecs', + '--help']) assert ret.success @@ -22,6 +22,6 @@ def test_execution_processing_fsl(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bvec = os.path.join(SCILPY_HOME, 'processing', '1000.bvec') - ret = script_runner.run('scil_gradients_normalize_bvecs.py', - in_bvec, '1000_norm.bvec') + ret = script_runner.run(['scil_gradients_normalize_bvecs', + in_bvec, '1000_norm.bvec']) assert ret.success diff --git a/scripts/tests/test_gradients_round_bvals.py b/src/scilpy/cli/tests/test_gradients_round_bvals.py similarity index 77% rename from scripts/tests/test_gradients_round_bvals.py rename to src/scilpy/cli/tests/test_gradients_round_bvals.py index 8fc930a81..978d8d21c 100644 --- a/scripts/tests/test_gradients_round_bvals.py +++ b/src/scilpy/cli/tests/test_gradients_round_bvals.py @@ -13,15 +13,15 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_gradients_round_bvals.py', - '--help') + ret = script_runner.run(['scil_gradients_round_bvals', + '--help']) assert ret.success def test_execution_processing(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bval = os.path.join(SCILPY_HOME, 'processing', '1000.bval') - ret = script_runner.run('scil_gradients_round_bvals.py', + ret = script_runner.run(['scil_gradients_round_bvals', in_bval, '0', '1000', '1000_resample.b', "20", - "-v") + "-v"]) assert ret.success diff --git a/scripts/tests/test_gradients_validate_correct.py b/src/scilpy/cli/tests/test_gradients_validate_correct.py similarity index 70% rename from scripts/tests/test_gradients_validate_correct.py rename to src/scilpy/cli/tests/test_gradients_validate_correct.py index 04e032dd3..8c79a6f41 100644 --- a/scripts/tests/test_gradients_validate_correct.py +++ b/src/scilpy/cli/tests/test_gradients_validate_correct.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_gradients_validate_correct.py', '--help') + ret = script_runner.run(['scil_gradients_validate_correct', '--help']) assert ret.success @@ -27,12 +27,13 @@ def test_execution_processing_dti_peaks(script_runner, monkeypatch): '1000.bvec') # generate the peaks file and fa map we'll use to test our script - script_runner.run('scil_dti_metrics.py', in_dwi, in_bval, in_bvec, - '--not_all', '--fa', 'fa.nii.gz', - '--evecs', 'evecs.nii.gz') + script_runner.run(['scil_dti_metrics', in_dwi, in_bval, in_bvec, + '--not_all', '--fa', 'fa.nii.gz', + '--evecs', 'evecs.nii.gz']) # test the actual script - ret = script_runner.run('scil_gradients_validate_correct.py', in_bvec, - 'evecs_v1.nii.gz', 'fa.nii.gz', 'bvec_corr', '-v') + ret = script_runner.run(['scil_gradients_validate_correct', in_bvec, + 'evecs_v1.nii.gz', 'fa.nii.gz', + 'bvec_corr', '-v']) assert ret.success @@ -46,6 +47,6 @@ def test_execution_processing_fodf_peaks(script_runner, monkeypatch): 'fa.nii.gz') # test the actual script - ret = script_runner.run('scil_gradients_validate_correct.py', in_bvec, - in_peaks, in_fa, 'bvec_corr_fodf', '-v') + ret = script_runner.run(['scil_gradients_validate_correct', in_bvec, + in_peaks, in_fa, 'bvec_corr_fodf', '-v']) assert ret.success diff --git a/scripts/tests/test_gradients_validate_correct_eddy.py b/src/scilpy/cli/tests/test_gradients_validate_correct_eddy.py similarity index 61% rename from scripts/tests/test_gradients_validate_correct_eddy.py rename to src/scilpy/cli/tests/test_gradients_validate_correct_eddy.py index 91b36626c..e01b6a12b 100644 --- a/scripts/tests/test_gradients_validate_correct_eddy.py +++ b/src/scilpy/cli/tests/test_gradients_validate_correct_eddy.py @@ -13,8 +13,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_gradients_validate_correct_eddy.py', - '--help') + ret = script_runner.run(['scil_gradients_validate_correct_eddy', + '--help']) assert ret.success @@ -22,20 +22,21 @@ def test_execution_extract_half(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bvec = os.path.join(SCILPY_HOME, 'processing', 'dwi.bvec') in_bval = os.path.join(SCILPY_HOME, 'processing', 'dwi.bval') - ret = script_runner.run('scil_gradients_validate_correct_eddy.py', - in_bvec, in_bval, "32", - 'out.bvec', - 'out.bval', - '-f') + ret = script_runner.run(['scil_gradients_validate_correct_eddy', + in_bvec, in_bval, "32", + 'out.bvec', + 'out.bval', + '-f']) assert ret.success + def test_execution_extract_total(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bvec = os.path.join(SCILPY_HOME, 'processing', 'dwi.bvec') in_bval = os.path.join(SCILPY_HOME, 'processing', 'dwi.bval') - ret = script_runner.run('scil_gradients_validate_correct_eddy.py', - in_bvec, in_bval, "64", - 'out.bvec', - 'out.bval', - '-f') + ret = script_runner.run(['scil_gradients_validate_correct_eddy', + in_bvec, in_bval, "64", + 'out.bvec', + 'out.bval', + '-f']) assert ret.success diff --git a/scripts/tests/test_gradients_validate_sampling.py b/src/scilpy/cli/tests/test_gradients_validate_sampling.py similarity index 75% rename from scripts/tests/test_gradients_validate_sampling.py rename to src/scilpy/cli/tests/test_gradients_validate_sampling.py index 59e1a4063..218e92232 100644 --- a/scripts/tests/test_gradients_validate_sampling.py +++ b/src/scilpy/cli/tests/test_gradients_validate_sampling.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_gradients_validate_sampling.py', '--help') + ret = script_runner.run(['scil_gradients_validate_sampling', '--help']) assert ret.success @@ -24,15 +24,15 @@ def test_execution_normal(script_runner, monkeypatch): in_bvec = os.path.join(SCILPY_HOME, 'processing', '1000.bvec') - ret = script_runner.run('scil_gradients_validate_sampling.py', in_bval, - in_bvec) + ret = script_runner.run(['scil_gradients_validate_sampling', in_bval, + in_bvec]) assert ret.success def test_execution_mrtrix(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_b = os.path.join(SCILPY_HOME, 'processing', - '1000.b') + '1000.b') - ret = script_runner.run('scil_gradients_validate_sampling.py', in_b) + ret = script_runner.run(['scil_gradients_validate_sampling', in_b]) assert ret.success diff --git a/scripts/tests/test_header_print_info.py b/src/scilpy/cli/tests/test_header_print_info.py similarity index 79% rename from scripts/tests/test_header_print_info.py rename to src/scilpy/cli/tests/test_header_print_info.py index 77c9d11a0..3aa31f5aa 100644 --- a/scripts/tests/test_header_print_info.py +++ b/src/scilpy/cli/tests/test_header_print_info.py @@ -13,19 +13,19 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_header_print_info.py', '--help') + ret = script_runner.run(['scil_header_print_info', '--help']) assert ret.success def test_execution_img(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_img = os.path.join(SCILPY_HOME, 'others', 'fa.nii.gz') - ret = script_runner.run('scil_header_print_info.py', in_img) + ret = script_runner.run(['scil_header_print_info', in_img]) assert ret.success def test_execution_tractogram(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracto = os.path.join(SCILPY_HOME, 'others', 'IFGWM.trk') - ret = script_runner.run('scil_header_print_info.py', in_tracto) + ret = script_runner.run(['scil_header_print_info', in_tracto]) assert ret.success diff --git a/scripts/tests/test_header_validate_compatibility.py b/src/scilpy/cli/tests/test_header_validate_compatibility.py similarity index 77% rename from scripts/tests/test_header_validate_compatibility.py rename to src/scilpy/cli/tests/test_header_validate_compatibility.py index eeb124a4b..fea53f0d3 100644 --- a/scripts/tests/test_header_validate_compatibility.py +++ b/src/scilpy/cli/tests/test_header_validate_compatibility.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_header_validate_compatibility.py', '--help') + ret = script_runner.run(['scil_header_validate_compatibility', '--help']) assert ret.success @@ -21,6 +21,6 @@ def test_execution_filtering(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'filtering', 'bundle_all_1mm.trk') in_roi = os.path.join(SCILPY_HOME, 'filtering', 'mask.nii.gz') - ret = script_runner.run('scil_header_validate_compatibility.py', - in_bundle, in_roi) + ret = script_runner.run(['scil_header_validate_compatibility', + in_bundle, in_roi]) assert ret.success diff --git a/scripts/tests/test_json_convert_entries_to_xlsx.py b/src/scilpy/cli/tests/test_json_convert_entries_to_xlsx.py similarity index 76% rename from scripts/tests/test_json_convert_entries_to_xlsx.py rename to src/scilpy/cli/tests/test_json_convert_entries_to_xlsx.py index 24bc117b7..2ad7054f6 100644 --- a/scripts/tests/test_json_convert_entries_to_xlsx.py +++ b/src/scilpy/cli/tests/test_json_convert_entries_to_xlsx.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_json_convert_entries_to_xlsx.py', '--help') + ret = script_runner.run(['scil_json_convert_entries_to_xlsx', '--help']) assert ret.success @@ -21,7 +21,7 @@ def test_execution_tractometry(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_json = os.path.join(SCILPY_HOME, 'tractometry', 'length_stats_1.json') - ret = script_runner.run('scil_json_convert_entries_to_xlsx.py', in_json, - 'length_stats.xlsx') + ret = script_runner.run(['scil_json_convert_entries_to_xlsx', in_json, + 'length_stats.xlsx']) assert ret.success diff --git a/src/scilpy/cli/tests/test_json_harmonize_entries.py b/src/scilpy/cli/tests/test_json_harmonize_entries.py new file mode 100644 index 000000000..4b52cad7f --- /dev/null +++ b/src/scilpy/cli/tests/test_json_harmonize_entries.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import os +import tempfile + +from scilpy import SCILPY_HOME +from scilpy.io.fetcher import fetch_data, get_testing_files_dict + +# If they already exist, this only takes 5 seconds (check md5sum) +fetch_data(get_testing_files_dict(), keys=['tractometry.zip']) +tmp_dir = tempfile.TemporaryDirectory() + + +def test_help_option(script_runner): + ret = script_runner.run(['scil_json_harmonize_entries', '--help']) + assert ret.success + + +def test_execution(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + in_json = os.path.join(SCILPY_HOME, 'tractometry', + 'metric_label.json') + ret = script_runner.run(['scil_json_harmonize_entries', in_json, + 'tmp.json', '--indent', '3', + '--sort_keys', '-f']) + assert ret.success diff --git a/scripts/tests/test_json_merge_entries.py b/src/scilpy/cli/tests/test_json_merge_entries.py similarity index 67% rename from scripts/tests/test_json_merge_entries.py rename to src/scilpy/cli/tests/test_json_merge_entries.py index 7f24c5025..f65a23361 100644 --- a/scripts/tests/test_json_merge_entries.py +++ b/src/scilpy/cli/tests/test_json_merge_entries.py @@ -13,17 +13,17 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_json_merge_entries.py', '--help') + ret = script_runner.run(['scil_json_merge_entries', '--help']) assert ret.success def test_execution_tractometry(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_json_1 = os.path.join(SCILPY_HOME, 'tractometry', - 'length_stats_1.json') + 'length_stats_1.json') in_json_2 = os.path.join(SCILPY_HOME, 'tractometry', - 'length_stats_2.json') - ret = script_runner.run('scil_json_merge_entries.py', in_json_1, - in_json_2, 'merge.json', '--keep_separate') + 'length_stats_2.json') + ret = script_runner.run(['scil_json_merge_entries', in_json_1, + in_json_2, 'merge.json', '--keep_separate']) assert ret.success diff --git a/scripts/tests/test_labels_combine.py b/src/scilpy/cli/tests/test_labels_combine.py similarity index 56% rename from scripts/tests/test_labels_combine.py rename to src/scilpy/cli/tests/test_labels_combine.py index 0dbbb89e6..cb15e8780 100644 --- a/scripts/tests/test_labels_combine.py +++ b/src/scilpy/cli/tests/test_labels_combine.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_labels_combine.py', '--help') + ret = script_runner.run(['scil_labels_combine', '--help']) assert ret.success @@ -22,11 +22,11 @@ def test_execution_atlas(script_runner, monkeypatch): in_atlas_1 = os.path.join(SCILPY_HOME, 'atlas', 'atlas_freesurfer_v2.nii.gz') in_brainstem = os.path.join(SCILPY_HOME, 'atlas', 'brainstem.nii.gz') - ret = script_runner.run('scil_labels_combine.py', - 'atlas_freesurfer_v2_single_brainstem.nii.gz', - '--volume_ids', in_atlas_1, '8', '47', '251', - '252', '253', '254', '1022', '1024', '2022', - '2024', '--volume_ids', in_brainstem, '16') + ret = script_runner.run(['scil_labels_combine', + 'atlas_freesurfer_v2_single_brainstem.nii.gz', + '--volume_ids', in_atlas_1, '8', '47', '251', + '252', '253', '254', '1022', '1024', '2022', + '2024', '--volume_ids', in_brainstem, '16']) assert ret.success @@ -35,10 +35,10 @@ def test_execution_atlas_merge(script_runner, monkeypatch): in_atlas_1 = os.path.join(SCILPY_HOME, 'atlas', 'atlas_freesurfer_v2.nii.gz') in_brainstem = os.path.join(SCILPY_HOME, 'atlas', 'brainstem.nii.gz') - ret = script_runner.run('scil_labels_combine.py', - 'atlas_freesurfer_v2_merge_brainstem.nii.gz', - '--volume_ids', in_atlas_1, '8', '47', '251', - '252', '253', '254', '1022', '1024', '2022', - '2024', '--volume_ids', in_brainstem, '16', - '--merge_groups') + ret = script_runner.run(['scil_labels_combine', + 'atlas_freesurfer_v2_merge_brainstem.nii.gz', + '--volume_ids', in_atlas_1, '8', '47', '251', + '252', '253', '254', '1022', '1024', '2022', + '2024', '--volume_ids', in_brainstem, '16', + '--merge_groups']) assert ret.success diff --git a/scripts/tests/test_labels_dilate.py b/src/scilpy/cli/tests/test_labels_dilate.py similarity index 70% rename from scripts/tests/test_labels_dilate.py rename to src/scilpy/cli/tests/test_labels_dilate.py index eed7ec737..0c24904a8 100644 --- a/scripts/tests/test_labels_dilate.py +++ b/src/scilpy/cli/tests/test_labels_dilate.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_labels_dilate.py', '--help') + ret = script_runner.run(['scil_labels_dilate', '--help']) assert ret.success @@ -21,7 +21,7 @@ def test_execution_atlas(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_atlas = os.path.join(SCILPY_HOME, 'atlas', 'atlas_freesurfer_v2_single_brainstem.nii.gz') - ret = script_runner.run('scil_labels_dilate.py', in_atlas, - 'atlas_freesurfer_v2_single_brainstem_dil.nii.gz', - '--processes', '1', '--distance', '2') + ret = script_runner.run(['scil_labels_dilate', in_atlas, + 'atlas_freesurfer_v2_single_brainstem_dil.nii.gz', + '--processes', '1', '--distance', '2']) assert ret.success diff --git a/scripts/tests/test_labels_from_mask.py b/src/scilpy/cli/tests/test_labels_from_mask.py similarity index 70% rename from scripts/tests/test_labels_from_mask.py rename to src/scilpy/cli/tests/test_labels_from_mask.py index dc6cb53d7..fdf41e5b7 100644 --- a/scripts/tests/test_labels_from_mask.py +++ b/src/scilpy/cli/tests/test_labels_from_mask.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_labels_from_mask.py', '--help') + ret = script_runner.run(['scil_labels_from_mask', '--help']) assert ret.success @@ -22,9 +22,9 @@ def test_execution(script_runner, monkeypatch): in_mask = os.path.join(SCILPY_HOME, 'tractograms', 'streamline_and_mask_operations', 'bundle_4_head_tail_offset.nii.gz') - ret = script_runner.run('scil_labels_from_mask.py', - in_mask, 'labels_from_mask.nii.gz', - '--min_volume', '0', '-f') + ret = script_runner.run(['scil_labels_from_mask', + in_mask, 'labels_from_mask.nii.gz', + '--min_volume', '0', '-f']) assert ret.success @@ -33,9 +33,9 @@ def test_execution_labels(script_runner, monkeypatch): in_mask = os.path.join(SCILPY_HOME, 'tractograms', 'streamline_and_mask_operations', 'bundle_4_head_tail_offset.nii.gz') - ret = script_runner.run('scil_labels_from_mask.py', - in_mask, 'labels_from_mask.nii.gz', - '--labels', '4', '6', '-f') + ret = script_runner.run(['scil_labels_from_mask', + in_mask, 'labels_from_mask.nii.gz', + '--labels', '4', '6', '-f']) assert ret.success @@ -44,9 +44,9 @@ def test_execution_background(script_runner, monkeypatch): in_mask = os.path.join(SCILPY_HOME, 'tractograms', 'streamline_and_mask_operations', 'bundle_4_head_tail_offset.nii.gz') - ret = script_runner.run('scil_labels_from_mask.py', - in_mask, 'labels_from_mask.nii.gz', - '--background_label', '9', '-f') + ret = script_runner.run(['scil_labels_from_mask', + in_mask, 'labels_from_mask.nii.gz', + '--background_label', '9', '-f']) assert ret.success @@ -55,9 +55,9 @@ def test_execution_error(script_runner, monkeypatch): in_mask = os.path.join(SCILPY_HOME, 'tractograms', 'streamline_and_mask_operations', 'bundle_4_head_tail_offset.nii.gz') - ret = script_runner.run('scil_labels_from_mask.py', - in_mask, 'labels_from_mask.nii.gz', - '--labels', '1') + ret = script_runner.run(['scil_labels_from_mask', + in_mask, 'labels_from_mask.nii.gz', + '--labels', '1']) assert not ret.success @@ -66,9 +66,9 @@ def test_execution_warning(script_runner, monkeypatch): in_mask = os.path.join(SCILPY_HOME, 'tractograms', 'streamline_and_mask_operations', 'bundle_4_head_tail_offset.nii.gz') - ret = script_runner.run('scil_labels_from_mask.py', - in_mask, 'labels_from_mask.nii.gz', - '--labels', '1', '2', '3', '-f') + ret = script_runner.run(['scil_labels_from_mask', + in_mask, 'labels_from_mask.nii.gz', + '--labels', '1', '2', '3', '-f']) assert ret.success assert ret.stderr # Check if there is a warning message @@ -78,8 +78,8 @@ def test_execution_background_warning(script_runner, monkeypatch): in_mask = os.path.join(SCILPY_HOME, 'tractograms', 'streamline_and_mask_operations', 'bundle_4_head_tail_offset.nii.gz') - ret = script_runner.run('scil_labels_from_mask.py', + ret = script_runner.run(['scil_labels_from_mask', in_mask, 'labels_from_mask.nii.gz', - '--background_label', '1', '-f') + '--background_label', '1', '-f']) assert ret.success assert ret.stderr # Check if there is a warning message diff --git a/scripts/tests/test_labels_remove.py b/src/scilpy/cli/tests/test_labels_remove.py similarity index 71% rename from scripts/tests/test_labels_remove.py rename to src/scilpy/cli/tests/test_labels_remove.py index 31521bd37..5d2e975c6 100644 --- a/scripts/tests/test_labels_remove.py +++ b/src/scilpy/cli/tests/test_labels_remove.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_labels_remove.py', '--help') + ret = script_runner.run(['scil_labels_remove', '--help']) assert ret.success @@ -21,7 +21,7 @@ def test_execution_atlas(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_atlas = os.path.join(SCILPY_HOME, 'atlas', 'atlas_freesurfer_v2.nii.gz') - ret = script_runner.run('scil_labels_remove.py', in_atlas, - 'atlas_freesurfer_v2_no_brainstem.nii.gz', - '-i', '173', '174', '175') + ret = script_runner.run(['scil_labels_remove', in_atlas, + 'atlas_freesurfer_v2_no_brainstem.nii.gz', + '-i', '173', '174', '175']) assert ret.success diff --git a/scripts/tests/test_labels_split_volume_by_ids.py b/src/scilpy/cli/tests/test_labels_split_volume_by_ids.py similarity index 73% rename from scripts/tests/test_labels_split_volume_by_ids.py rename to src/scilpy/cli/tests/test_labels_split_volume_by_ids.py index 73c41a3e7..3beba61db 100644 --- a/scripts/tests/test_labels_split_volume_by_ids.py +++ b/src/scilpy/cli/tests/test_labels_split_volume_by_ids.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_labels_split_volume_by_ids.py', '--help') + ret = script_runner.run(['scil_labels_split_volume_by_ids', '--help']) assert ret.success @@ -21,6 +21,6 @@ def test_execution_atlas(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_atlas = os.path.join(SCILPY_HOME, 'atlas', 'atlas_freesurfer_v2.nii.gz') - ret = script_runner.run('scil_labels_split_volume_by_ids.py', in_atlas, - '--out_prefix', 'brainstem', '-r', '173', '175') + ret = script_runner.run(['scil_labels_split_volume_by_ids', in_atlas, + '--out_prefix', 'brainstem', '-r', '173', '175']) assert ret.success diff --git a/scripts/tests/test_labels_split_volume_from_lut.py b/src/scilpy/cli/tests/test_labels_split_volume_from_lut.py similarity index 73% rename from scripts/tests/test_labels_split_volume_from_lut.py rename to src/scilpy/cli/tests/test_labels_split_volume_from_lut.py index 782ed7ac8..7b2e0de9d 100644 --- a/scripts/tests/test_labels_split_volume_from_lut.py +++ b/src/scilpy/cli/tests/test_labels_split_volume_from_lut.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_labels_split_volume_from_lut.py', '--help') + ret = script_runner.run(['scil_labels_split_volume_from_lut', '--help']) assert ret.success @@ -23,7 +23,7 @@ def test_execution_atlas(script_runner, monkeypatch): 'atlas_freesurfer_v2.nii.gz') in_json = os.path.join(SCILPY_HOME, 'atlas', 'atlas_freesurfer_v2_LUT.json') - ret = script_runner.run('scil_labels_split_volume_from_lut.py', in_atlas, - '--out_prefix', 'brainstem', - '--custom_lut', in_json) + ret = script_runner.run(['scil_labels_split_volume_from_lut', in_atlas, + '--out_prefix', 'brainstem', + '--custom_lut', in_json]) assert ret.success diff --git a/scripts/tests/test_lesions_generate_nawm.py b/src/scilpy/cli/tests/test_lesions_generate_nawm.py similarity index 72% rename from scripts/tests/test_lesions_generate_nawm.py rename to src/scilpy/cli/tests/test_lesions_generate_nawm.py index 9c3134d7d..2330aa75a 100644 --- a/scripts/tests/test_lesions_generate_nawm.py +++ b/src/scilpy/cli/tests/test_lesions_generate_nawm.py @@ -15,7 +15,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_lesions_generate_nawm.py', '--help') + ret = script_runner.run(['scil_lesions_generate_nawm', '--help']) assert ret.success @@ -23,7 +23,7 @@ def test_execution_atlas(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_atlas = os.path.join(SCILPY_HOME, 'atlas', 'atlas_freesurfer_v2_single_brainstem.nii.gz') - ret = script_runner.run('scil_lesions_generate_nawm.py', in_atlas, - 'nawm.nii.gz', '--nb_ring', '3', - '--ring_thickness', '2') + ret = script_runner.run(['scil_lesions_generate_nawm', in_atlas, + 'nawm.nii.gz', '--nb_ring', '3', + '--ring_thickness', '2']) assert ret.success diff --git a/src/scilpy/cli/tests/test_lesions_harmonize_labels.py b/src/scilpy/cli/tests/test_lesions_harmonize_labels.py new file mode 100644 index 000000000..550af0328 --- /dev/null +++ b/src/scilpy/cli/tests/test_lesions_harmonize_labels.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import os +import tempfile + +from scilpy import SCILPY_HOME +from scilpy.io.fetcher import fetch_data, get_testing_files_dict + +# If they already exist, this only takes 5 seconds (check md5sum) +fetch_data(get_testing_files_dict(), keys=['lesions.zip']) +tmp_dir = tempfile.TemporaryDirectory() + + +def test_help_option(script_runner): + ret = script_runner.run(['scil_lesions_harmonize_labels', '--help']) + assert ret.success + + +def test_harmonize_label(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + t1 = os.path.join(SCILPY_HOME, 'lesions', 'S001_T1_lesions_labels.nii.gz') + t2 = os.path.join(SCILPY_HOME, 'lesions', 'S001_T2_lesions_labels.nii.gz') + ret = script_runner.run(['scil_lesions_harmonize_labels', + t1, t2, 'test', '--max_adjacency', + '5.0', '--min_voxel_overlap', '1', '-f']) + assert ret.success + + +def test_harmonize_label_incremental(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + t1 = os.path.join(SCILPY_HOME, 'lesions', 'S001_T1_lesions_labels.nii.gz') + t2 = os.path.join(SCILPY_HOME, 'lesions', 'S001_T2_lesions_labels.nii.gz') + ret = script_runner.run(['scil_lesions_harmonize_labels', + t1, t2, 'test', '--max_adjacency', + '5.0', '--min_voxel_overlap', '1', + '--incremental_lesions', '-f']) + assert ret.success diff --git a/src/scilpy/cli/tests/test_lesions_info.py b/src/scilpy/cli/tests/test_lesions_info.py new file mode 100644 index 000000000..696838d59 --- /dev/null +++ b/src/scilpy/cli/tests/test_lesions_info.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import os +import tempfile + +from scilpy import SCILPY_HOME +from scilpy.io.fetcher import fetch_data, get_testing_files_dict + +# If they already exist, this only takes 5 seconds (check md5sum) +fetch_data(get_testing_files_dict(), keys=['lesions.zip']) +tmp_dir = tempfile.TemporaryDirectory() + + +def test_help_option(script_runner): + ret = script_runner.run(['scil_lesions_info', '--help']) + assert ret.success + + +def test_execution_lesion(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + t1 = os.path.join(SCILPY_HOME, 'lesions', 'S001_T1_lesions_labels.nii.gz') + t2 = os.path.join(SCILPY_HOME, 'lesions', 'S001_T2_lesions_labels.nii.gz') + ret = script_runner.run(['scil_lesions_info', t1, + '--bundle_labels_map', t2, 'out.json']) + assert ret.success diff --git a/scripts/tests/test_mrds_metrics.py b/src/scilpy/cli/tests/test_mrds_metrics.py similarity index 61% rename from scripts/tests/test_mrds_metrics.py rename to src/scilpy/cli/tests/test_mrds_metrics.py index 62b4a8cfc..3e54473c8 100644 --- a/scripts/tests/test_mrds_metrics.py +++ b/src/scilpy/cli/tests/test_mrds_metrics.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_mrds_metrics.py', '--help') + ret = script_runner.run(['scil_mrds_metrics', '--help']) assert ret.success @@ -24,9 +24,7 @@ def test_execution_mrds_all_metrics(script_runner, monkeypatch): 'mrds', 'sub-01_MRDS_eigenvalues.nii.gz') # no option - ret = script_runner.run('scil_mrds_metrics.py', - in_evals, - '-f') + ret = script_runner.run(['scil_mrds_metrics', in_evals, '-f']) assert ret.success @@ -38,13 +36,13 @@ def test_execution_mrds_not_all_metrics(script_runner, monkeypatch): in_mask = os.path.join(SCILPY_HOME, 'mrds', 'sub-01_mask.nii.gz') # no option - ret = script_runner.run('scil_mrds_metrics.py', - in_evals, - '--mask', in_mask, - '--not_all', - '--fa', 'sub-01_MRDS_FA.nii.gz', - '--ad', 'sub-01_MRDS_AD.nii.gz', - '--rd', 'sub-01_MRDS_RD.nii.gz', - '--md', 'sub-01_MRDS_MD.nii.gz', - '-f') + ret = script_runner.run(['scil_mrds_metrics', + in_evals, + '--mask', in_mask, + '--not_all', + '--fa', 'sub-01_MRDS_FA.nii.gz', + '--ad', 'sub-01_MRDS_AD.nii.gz', + '--rd', 'sub-01_MRDS_RD.nii.gz', + '--md', 'sub-01_MRDS_MD.nii.gz', + '-f']) assert ret.success diff --git a/scripts/tests/test_mrds_select_number_of_tensors.py b/src/scilpy/cli/tests/test_mrds_select_number_of_tensors.py similarity index 65% rename from scripts/tests/test_mrds_select_number_of_tensors.py rename to src/scilpy/cli/tests/test_mrds_select_number_of_tensors.py index 7602c3104..a5ccc9504 100644 --- a/scripts/tests/test_mrds_select_number_of_tensors.py +++ b/src/scilpy/cli/tests/test_mrds_select_number_of_tensors.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_mrds_select_number_of_tensors.py', '--help') + ret = script_runner.run(['scil_mrds_select_number_of_tensors', '--help']) assert ret.success @@ -23,10 +23,10 @@ def test_execution_mrds(script_runner, monkeypatch): in_nufo = os.path.join(SCILPY_HOME, 'mrds', 'sub-01_nufo.nii.gz') # no option - ret = script_runner.run('scil_mrds_select_number_of_tensors.py', - SCILPY_HOME + '/mrds/sub-01', - in_nufo, - '-f') + ret = script_runner.run(['scil_mrds_select_number_of_tensors', + SCILPY_HOME + '/mrds/sub-01', + in_nufo, + '-f']) assert ret.success @@ -38,9 +38,9 @@ def test_execution_mrds_w_mask(script_runner, monkeypatch): in_mask = os.path.join(SCILPY_HOME, 'mrds', 'sub-01_mask.nii.gz') - ret = script_runner.run('scil_mrds_select_number_of_tensors.py', - SCILPY_HOME + '/mrds/sub-01', - in_nufo, - '--mask', in_mask, - '-f') + ret = script_runner.run(['scil_mrds_select_number_of_tensors', + SCILPY_HOME + '/mrds/sub-01', + in_nufo, + '--mask', in_mask, + '-f']) assert ret.success diff --git a/scripts/tests/test_mti_adjust_B1_header.py b/src/scilpy/cli/tests/test_mti_adjust_B1_header.py similarity index 79% rename from scripts/tests/test_mti_adjust_B1_header.py rename to src/scilpy/cli/tests/test_mti_adjust_B1_header.py index 2770403d8..872029a1c 100644 --- a/scripts/tests/test_mti_adjust_B1_header.py +++ b/src/scilpy/cli/tests/test_mti_adjust_B1_header.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_mti_adjust_B1_header.py', '--help') + ret = script_runner.run(['scil_mti_adjust_B1_header', '--help']) assert ret.success @@ -26,6 +26,6 @@ def test_execution_ihMT_no_option(script_runner, monkeypatch): 'MT', 'sub-001_run-01_B1map.json') # no option - ret = script_runner.run('scil_mti_adjust_B1_header.py', in_b1_map, - tmp_dir.name, in_b1_json, '-f') + ret = script_runner.run(['scil_mti_adjust_B1_header', in_b1_map, + tmp_dir.name, in_b1_json, '-f']) assert ret.success diff --git a/src/scilpy/cli/tests/test_mti_maps_MT.py b/src/scilpy/cli/tests/test_mti_maps_MT.py new file mode 100644 index 000000000..33e4252c2 --- /dev/null +++ b/src/scilpy/cli/tests/test_mti_maps_MT.py @@ -0,0 +1,255 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import os +import tempfile + +from scilpy import SCILPY_HOME +from scilpy.io.fetcher import fetch_data, get_testing_files_dict + +# If they already exist, this only takes 5 seconds (check md5sum) +fetch_data(get_testing_files_dict(), keys=['MT.zip']) +tmp_dir = tempfile.TemporaryDirectory() + + +# Preparing once the filenames. +in_mask = os.path.join(SCILPY_HOME, 'MT', 'mask.nii.gz') + +in_mtoff_json = os.path.join(SCILPY_HOME, + 'MT', 'sub-001_echo-1_acq-mtoff_mtsat.json') +in_t1w_json = os.path.join(SCILPY_HOME, + 'MT', 'sub-001_echo-1_acq-t1w_mtsat.json') + +in_e1_mtoff = os.path.join(SCILPY_HOME, + 'MT', 'sub-001_echo-1_acq-mtoff_mtsat.nii.gz') +in_e2_mtoff = os.path.join(SCILPY_HOME, + 'MT', 'sub-001_echo-2_acq-mtoff_mtsat.nii.gz') +in_e3_mtoff = os.path.join(SCILPY_HOME, + 'MT', 'sub-001_echo-3_acq-mtoff_mtsat.nii.gz') +in_e4_mtoff = os.path.join(SCILPY_HOME, + 'MT', 'sub-001_echo-4_acq-mtoff_mtsat.nii.gz') +in_e5_mtoff = os.path.join(SCILPY_HOME, + 'MT', 'sub-001_echo-5_acq-mtoff_mtsat.nii.gz') + +in_e1_mton = os.path.join(SCILPY_HOME, + 'MT', 'sub-001_echo-1_acq-mton_mtsat.nii.gz') +in_e2_mton = os.path.join(SCILPY_HOME, + 'MT', 'sub-001_echo-2_acq-mton_mtsat.nii.gz') +in_e3_mton = os.path.join(SCILPY_HOME, + 'MT', 'sub-001_echo-3_acq-mton_mtsat.nii.gz') +in_e4_mton = os.path.join(SCILPY_HOME, + 'MT', 'sub-001_echo-4_acq-mton_mtsat.nii.gz') +in_e5_mton = os.path.join(SCILPY_HOME, + 'MT', 'sub-001_echo-5_acq-mton_mtsat.nii.gz') + +in_e1_t1w = os.path.join(SCILPY_HOME, + 'MT', 'sub-001_echo-1_acq-t1w_mtsat.nii.gz') +in_e2_t1w = os.path.join(SCILPY_HOME, + 'MT', 'sub-001_echo-2_acq-t1w_mtsat.nii.gz') +in_e3_t1w = os.path.join(SCILPY_HOME, + 'MT', 'sub-001_echo-3_acq-t1w_mtsat.nii.gz') +in_e4_t1w = os.path.join(SCILPY_HOME, + 'MT', 'sub-001_echo-4_acq-t1w_mtsat.nii.gz') +in_e5_t1w = os.path.join(SCILPY_HOME, + 'MT', 'sub-001_echo-5_acq-t1w_mtsat.nii.gz') + +in_b1_map = os.path.join(SCILPY_HOME, 'MT', 'sub-001_run-01_B1map.nii.gz') +in_b1_json = os.path.join(SCILPY_HOME, 'MT', 'sub-001_run-01_B1map.json') + + +def test_help_option(script_runner): + ret = script_runner.run(['scil_mti_maps_MT', '--help']) + assert ret.success + + +def test_execution_MT_no_option(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + # no option + ret = script_runner.run(['scil_mti_maps_MT', tmp_dir.name, + '--mask', in_mask, + '--in_mtoff_pd', in_e1_mtoff, in_e2_mtoff, + in_e3_mtoff, in_e4_mtoff, in_e5_mtoff, + '--in_positive', in_e1_mton, in_e2_mton, + in_e3_mton, in_e4_mton, in_e5_mton, + '--in_mtoff_t1', in_e1_t1w, in_e2_t1w, in_e3_t1w, + in_e4_t1w, in_e5_t1w, + '--in_jsons', in_mtoff_json, in_t1w_json, + '-f']) + assert ret.success + + +def test_execution_MT_prefix(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + # --out_prefix + ret = script_runner.run(['scil_mti_maps_MT', tmp_dir.name, + '--mask', in_mask, + '--in_mtoff_pd', in_e1_mtoff, in_e2_mtoff, + in_e3_mtoff, in_e4_mtoff, in_e5_mtoff, + '--in_positive', in_e1_mton, in_e2_mton, + in_e3_mton, in_e4_mton, in_e5_mton, + '--in_mtoff_t1', in_e1_t1w, in_e2_t1w, in_e3_t1w, + in_e4_t1w, in_e5_t1w, + '--in_jsons', in_mtoff_json, in_t1w_json, + '--out_prefix', 'sub_01', + '-f']) + assert ret.success + + +def test_execution_MT_extended(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + # --extended + ret = script_runner.run(['scil_mti_maps_MT', tmp_dir.name, + '--mask', in_mask, + '--in_mtoff_pd', in_e1_mtoff, in_e2_mtoff, + in_e3_mtoff, in_e4_mtoff, in_e5_mtoff, + '--in_positive', in_e1_mton, in_e2_mton, + in_e3_mton, in_e4_mton, in_e5_mton, + '--in_mtoff_t1', in_e1_t1w, in_e2_t1w, in_e3_t1w, + in_e4_t1w, in_e5_t1w, + '--in_jsons', in_mtoff_json, in_t1w_json, + '--extended', + '-f']) + assert ret.success + + +def test_execution_MT_filtering(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + # --filtering + ret = script_runner.run(['scil_mti_maps_MT', tmp_dir.name, + '--mask', in_mask, + '--in_mtoff_pd', in_e1_mtoff, in_e2_mtoff, + in_e3_mtoff, in_e4_mtoff, in_e5_mtoff, + '--in_positive', in_e1_mton, in_e2_mton, + in_e3_mton, in_e4_mton, in_e5_mton, + '--in_mtoff_t1', in_e1_t1w, in_e2_t1w, in_e3_t1w, + in_e4_t1w, in_e5_t1w, + '--in_jsons', in_mtoff_json, in_t1w_json, + '--filtering', + '-f']) + assert ret.success + + +def test_execution_MT_B1_map(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + out_b1_map = tmp_dir.name + '/B1map.nii.gz' + + # Temporary trick to have the B1 map with proper header. + ret = script_runner.run(['scil_mti_adjust_B1_header', in_b1_map, + out_b1_map, in_b1_json, '-f']) + + # --in_B1_map + ret = script_runner.run(['scil_mti_maps_MT', tmp_dir.name, + '--mask', in_mask, + '--in_mtoff_pd', in_e1_mtoff, in_e2_mtoff, + in_e3_mtoff, in_e4_mtoff, in_e5_mtoff, + '--in_positive', in_e1_mton, in_e2_mton, + in_e3_mton, in_e4_mton, in_e5_mton, + '--in_negative', in_e1_mton, in_e2_mton, + in_e3_mton, in_e4_mton, in_e5_mton, + '--in_mtoff_t1', in_e1_t1w, in_e2_t1w, in_e3_t1w, + in_e4_t1w, in_e5_t1w, + '--in_jsons', in_mtoff_json, in_t1w_json, + '--in_B1_map', out_b1_map, + '--B1_correction_method', 'empiric', + '--out_prefix', 'sub-01', + '-f']) + assert ret.success + + +def test_execution_MT_wrong_echoes(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + # Wrong number of echoes for negative + ret = script_runner.run(['scil_mti_maps_MT', tmp_dir.name, + '--mask', in_mask, + '--in_mtoff_pd', in_e1_mtoff, in_e2_mtoff, + in_e3_mtoff, in_e4_mtoff, in_e5_mtoff, + '--in_positive', in_e1_mton, in_e2_mton, + in_e3_mton, in_e4_mton, in_e5_mton, + '--in_negative', in_e1_mton, in_e2_mton, + in_e3_mton, in_e4_mton, + '--in_mtoff_t1', in_e1_t1w, in_e2_t1w, in_e3_t1w, + in_e4_t1w, in_e5_t1w, + '--in_jsons', in_mtoff_json, in_t1w_json, + '-f']) + assert (not ret.success) + + +def test_execution_MT_single_echoe(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + # Single echoe + ret = script_runner.run(['scil_mti_maps_MT', tmp_dir.name, + '--mask', in_mask, + '--in_mtoff_pd', in_e1_mtoff, + '--in_positive', in_e1_mton, + '--in_negative', in_e1_mton, + '--in_mtoff_t1', in_e1_t1w, + '--in_jsons', in_mtoff_json, in_t1w_json, + '-f']) + assert ret.success + + +def test_execution_MT_B1_not_T1(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + out_b1_map = tmp_dir.name + '/B1map.nii.gz' + + # Temporary trick to have the B1 map with proper header. + ret = script_runner.run(['scil_mti_adjust_B1_header', in_b1_map, + out_b1_map, in_b1_json, '-f']) + + # B1 no T1 should raise warning. + ret = script_runner.run(['scil_mti_maps_MT', tmp_dir.name, + '--mask', in_mask, + '--in_mtoff_pd', in_e1_mtoff, + '--in_positive', in_e1_mton, + '--in_negative', in_e1_mton, + '--in_jsons', in_mtoff_json, in_t1w_json, + '--in_B1_map', out_b1_map, + '--B1_correction_method', 'empiric', + '-f']) + assert ret.success + + +def test_execution_MT_B1_no_fit(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + out_b1_map = tmp_dir.name + '/B1map.nii.gz' + + # Temporary trick to have the B1 map with proper header. + ret = script_runner.run(['scil_mti_adjust_B1_header', in_b1_map, + out_b1_map, in_b1_json, '-f']) + + # B1 model_based but no fit values + ret = script_runner.run(['scil_mti_maps_MT', tmp_dir.name, + '--mask', in_mask, + '--in_mtoff_pd', in_e1_mtoff, + '--in_positive', in_e1_mton, + '--in_negative', in_e1_mton, + '--in_mtoff_t1', in_e1_t1w, + '--in_jsons', in_mtoff_json, in_t1w_json, + '--in_B1_map', out_b1_map, + '--B1_correction_method', 'model_based', + '-f']) + assert (not ret.success) + + +def test_execution_MT_acq_params(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + # Acquisition parameters + ret = script_runner.run(['scil_mti_maps_MT', tmp_dir.name, + '--mask', in_mask, + '--in_mtoff_pd', in_e1_mtoff, + '--in_positive', in_e1_mton, + '--in_negative', in_e1_mton, + '--in_mtoff_t1', in_e1_t1w, + '--in_acq_parameters', "15", "15", "0.1", "0.1", + '-f']) + assert ret.success diff --git a/src/scilpy/cli/tests/test_mti_maps_ihMT.py b/src/scilpy/cli/tests/test_mti_maps_ihMT.py new file mode 100644 index 000000000..4246448d1 --- /dev/null +++ b/src/scilpy/cli/tests/test_mti_maps_ihMT.py @@ -0,0 +1,308 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import os +import tempfile + +from scilpy import SCILPY_HOME +from scilpy.io.fetcher import fetch_data, get_testing_files_dict + +# If they already exist, this only takes 5 seconds (check md5sum) +fetch_data(get_testing_files_dict(), keys=['ihMT.zip']) +tmp_dir = tempfile.TemporaryDirectory() + +# Preparing once the filenames. + +in_mask = os.path.join(SCILPY_HOME, 'ihMT', 'mask_resample.nii.gz') + +in_mtoff_pd_json = os.path.join(SCILPY_HOME, + 'ihMT', 'echo-1_acq-mtoff_ihmt.json') +in_mtoff_t1_json = os.path.join(SCILPY_HOME, + 'ihMT', 'echo-1_acq-T1w_ihmt.json') + +in_e1_altnp = os.path.join(SCILPY_HOME, + 'ihMT', 'echo-1_acq-altnp_ihmt.nii.gz') +in_e2_altnp = os.path.join(SCILPY_HOME, + 'ihMT', 'echo-2_acq-altnp_ihmt.nii.gz') +in_e3_altnp = os.path.join(SCILPY_HOME, + 'ihMT', 'echo-3_acq-altnp_ihmt.nii.gz') + +in_e1_altpn = os.path.join(SCILPY_HOME, + 'ihMT', 'echo-1_acq-altpn_ihmt.nii.gz') +in_e2_altpn = os.path.join(SCILPY_HOME, + 'ihMT', 'echo-2_acq-altpn_ihmt.nii.gz') +in_e3_altpn = os.path.join(SCILPY_HOME, + 'ihMT', 'echo-3_acq-altpn_ihmt.nii.gz') + +in_e1_mtoff_pd = os.path.join(SCILPY_HOME, + 'ihMT', 'echo-1_acq-mtoff_ihmt.nii.gz') +in_e2_mtoff_pd = os.path.join(SCILPY_HOME, + 'ihMT', 'echo-2_acq-mtoff_ihmt.nii.gz') +in_e3_mtoff_pd = os.path.join(SCILPY_HOME, + 'ihMT', 'echo-3_acq-mtoff_ihmt.nii.gz') + +in_e1_neg = os.path.join(SCILPY_HOME, + 'ihMT', 'echo-1_acq-neg_ihmt.nii.gz') +in_e2_neg = os.path.join(SCILPY_HOME, + 'ihMT', 'echo-2_acq-neg_ihmt.nii.gz') +in_e3_neg = os.path.join(SCILPY_HOME, + 'ihMT', 'echo-3_acq-neg_ihmt.nii.gz') + +in_e1_pos = os.path.join(SCILPY_HOME, + 'ihMT', 'echo-1_acq-pos_ihmt.nii.gz') +in_e2_pos = os.path.join(SCILPY_HOME, + 'ihMT', 'echo-2_acq-pos_ihmt.nii.gz') +in_e3_pos = os.path.join(SCILPY_HOME, + 'ihMT', 'echo-3_acq-pos_ihmt.nii.gz') + +in_e1_mtoff_t1 = os.path.join(SCILPY_HOME, + 'ihMT', 'echo-1_acq-T1w_ihmt.nii.gz') +in_e2_mtoff_t1 = os.path.join(SCILPY_HOME, + 'ihMT', 'echo-2_acq-T1w_ihmt.nii.gz') +in_e3_mtoff_t1 = os.path.join(SCILPY_HOME, + 'ihMT', 'echo-3_acq-T1w_ihmt.nii.gz') + +in_b1_map = os.path.join(SCILPY_HOME, 'ihMT', 'B1map.nii.gz') +in_b1_json = os.path.join(SCILPY_HOME, 'MT', 'sub-001_run-01_B1map.json') + + +def test_help_option(script_runner): + ret = script_runner.run(['scil_mti_maps_ihMT', '--help']) + assert ret.success + + +def test_execution_ihMT_no_option(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + # no option + ret = script_runner.run(['scil_mti_maps_ihMT', tmp_dir.name, + '--mask', in_mask, + '--in_altnp', in_e1_altnp, in_e2_altnp, + in_e3_altnp, + '--in_altpn', in_e1_altpn, in_e2_altpn, + in_e3_altpn, + '--in_mtoff_pd', in_e1_mtoff_pd, in_e2_mtoff_pd, + in_e3_mtoff_pd, + '--in_negative', in_e1_neg, in_e2_neg, in_e3_neg, + '--in_positive', in_e1_pos, in_e2_pos, in_e3_pos, + '--in_mtoff_t1', in_e1_mtoff_t1, in_e2_mtoff_t1, + in_e3_mtoff_t1, + '--in_jsons', in_mtoff_pd_json, + in_mtoff_t1_json, + '-f']) + assert ret.success + + +def test_execution_ihMT_prefix(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + # --out_prefix + ret = script_runner.run(['scil_mti_maps_ihMT', tmp_dir.name, + '--mask', in_mask, + '--in_altnp', in_e1_altnp, in_e2_altnp, + in_e3_altnp, + '--in_altpn', in_e1_altpn, in_e2_altpn, + in_e3_altpn, + '--in_mtoff_pd', in_e1_mtoff_pd, in_e2_mtoff_pd, + in_e3_mtoff_pd, + '--in_negative', in_e1_neg, in_e2_neg, + in_e3_neg, + '--in_positive', in_e1_pos, in_e2_pos, + in_e3_pos, + '--in_mtoff_t1', in_e1_mtoff_t1, in_e2_mtoff_t1, + in_e3_mtoff_t1, + '--in_jsons', in_mtoff_pd_json, + in_mtoff_t1_json, + '--out_prefix', 'sub_01', + '-f']) + assert ret.success + + +def test_execution_ihMT_extended(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + # --extended + ret = script_runner.run(['scil_mti_maps_ihMT', tmp_dir.name, + '--mask', in_mask, + '--in_altnp', in_e1_altnp, in_e2_altnp, + in_e3_altnp, + '--in_altpn', in_e1_altpn, in_e2_altpn, + in_e3_altpn, + '--in_mtoff_pd', in_e1_mtoff_pd, in_e2_mtoff_pd, + in_e3_mtoff_pd, + '--in_negative', in_e1_neg, in_e2_neg, + in_e3_neg, + '--in_positive', in_e1_pos, in_e2_pos, + in_e3_pos, + '--in_mtoff_t1', in_e1_mtoff_t1, in_e2_mtoff_t1, + in_e3_mtoff_t1, + '--in_jsons', in_mtoff_pd_json, + in_mtoff_t1_json, + '--extended', + '-f']) + assert ret.success + + +def test_execution_ihMT_filtering(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + # --filtering + ret = script_runner.run(['scil_mti_maps_ihMT', tmp_dir.name, + '--mask', in_mask, + '--in_altnp', in_e1_altnp, in_e2_altnp, + in_e3_altnp, + '--in_altpn', in_e1_altpn, in_e2_altpn, + in_e3_altpn, + '--in_mtoff_pd', in_e1_mtoff_pd, in_e2_mtoff_pd, + in_e3_mtoff_pd, + '--in_negative', in_e1_neg, in_e2_neg, in_e3_neg, + '--in_positive', in_e1_pos, in_e2_pos, in_e3_pos, + '--in_mtoff_t1', in_e1_mtoff_t1, in_e2_mtoff_t1, + in_e3_mtoff_t1, + '--in_jsons', in_mtoff_pd_json, + in_mtoff_t1_json, + '--out_prefix', 'sub-01', + '--filtering', + '-f']) + assert ret.success + + +def test_execution_ihMT_B1_map(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + out_b1_map = tmp_dir.name + '/B1map.nii.gz' + + # Temporary trick to have the B1 map with proper header. + ret = script_runner.run(['scil_mti_adjust_B1_header', in_b1_map, + out_b1_map, in_b1_json, '-f']) + + ret = script_runner.run(['scil_mti_maps_ihMT', tmp_dir.name, + '--mask', in_mask, + '--in_altnp', in_e1_altnp, in_e2_altnp, + in_e3_altnp, + '--in_altpn', in_e1_altpn, in_e2_altpn, + in_e3_altpn, + '--in_mtoff_pd', in_e1_mtoff_pd, in_e2_mtoff_pd, + in_e3_mtoff_pd, + '--in_negative', in_e1_neg, in_e2_neg, in_e3_neg, + '--in_positive', in_e1_pos, in_e2_pos, in_e3_pos, + '--in_mtoff_t1', in_e1_mtoff_t1, in_e2_mtoff_t1, + in_e3_mtoff_t1, + '--out_prefix', 'sub-01', + '--in_B1_map', out_b1_map, + '--B1_correction_method', 'empiric', + '--in_jsons', in_mtoff_pd_json, + in_mtoff_t1_json, + '-f']) + assert ret.success + + +def test_execution_ihMT_B1_no_T1(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + out_b1_map = tmp_dir.name + '/B1map.nii.gz' + + # Temporary trick to have the B1 map with proper header. + ret = script_runner.run(['scil_mti_adjust_B1_header', in_b1_map, + out_b1_map, in_b1_json, '-f']) + + ret = script_runner.run(['scil_mti_maps_ihMT', tmp_dir.name, + '--mask', in_mask, + '--in_altnp', in_e1_altnp, in_e2_altnp, + in_e3_altnp, + '--in_altpn', in_e1_altpn, in_e2_altpn, + in_e3_altpn, + '--in_mtoff_pd', in_e1_mtoff_pd, in_e2_mtoff_pd, + in_e3_mtoff_pd, + '--in_negative', in_e1_neg, in_e2_neg, in_e3_neg, + '--in_positive', in_e1_pos, in_e2_pos, in_e3_pos, + '--in_B1_map', out_b1_map, + '--B1_correction_method', 'empiric', + '--in_jsons', in_mtoff_pd_json, + in_mtoff_t1_json, + '-f']) + assert ret.success + + +def test_execution_ihMT_wrong_echoes(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + ret = script_runner.run(['scil_mti_maps_ihMT', tmp_dir.name, + '--mask', in_mask, + '--in_altnp', in_e1_altnp, in_e2_altnp, + in_e3_altnp, + '--in_altpn', in_e1_altpn, in_e2_altpn, + in_e3_altpn, + '--in_mtoff_pd', in_e1_mtoff_pd, in_e2_mtoff_pd, + in_e3_mtoff_pd, + '--in_negative', in_e1_neg, in_e2_neg, in_e3_neg, + '--in_positive', in_e1_pos, in_e2_pos, in_e3_pos, + '--in_mtoff_t1', in_e1_mtoff_t1, in_e2_mtoff_t1, + '--in_jsons', in_mtoff_pd_json, + in_mtoff_t1_json, + '-f']) + assert (not ret.success) + + +def test_execution_ihMT_B1_no_fit(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + out_b1_map = tmp_dir.name + '/B1map.nii.gz' + + # Temporary trick to have the B1 map with proper header. + ret = script_runner.run(['scil_mti_adjust_B1_header', in_b1_map, + out_b1_map, in_b1_json, '-f']) + + ret = script_runner.run(['scil_mti_maps_ihMT', tmp_dir.name, + '--mask', in_mask, + '--in_altnp', in_e1_altnp, in_e2_altnp, + in_e3_altnp, + '--in_altpn', in_e1_altpn, in_e2_altpn, + in_e3_altpn, + '--in_mtoff_pd', in_e1_mtoff_pd, in_e2_mtoff_pd, + in_e3_mtoff_pd, + '--in_negative', in_e1_neg, in_e2_neg, in_e3_neg, + '--in_positive', in_e1_pos, in_e2_pos, in_e3_pos, + '--in_mtoff_t1', in_e1_mtoff_t1, in_e2_mtoff_t1, + in_e3_mtoff_t1, + '--out_prefix', 'sub-01', + '--in_B1_map', out_b1_map, + '--B1_correction_method', 'model_based', + '--in_jsons', in_mtoff_pd_json, + in_mtoff_t1_json, + '-f']) + assert (not ret.success) + + +def test_execution_ihMT_single_echo(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + ret = script_runner.run(['scil_mti_maps_ihMT', tmp_dir.name, + '--mask', in_mask, + '--in_altnp', in_e1_altnp, + '--in_altpn', in_e1_altpn, + '--in_mtoff_pd', in_e1_mtoff_pd, + '--in_negative', in_e1_neg, + '--in_positive', in_e1_pos, + '--in_mtoff_t1', in_e1_mtoff_t1, + '--out_prefix', 'sub_01', + '--in_jsons', in_mtoff_pd_json, + in_mtoff_t1_json, '-f']) + assert ret.success + + +def test_execution_ihMT_acq_params(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + ret = script_runner.run(['scil_mti_maps_ihMT', tmp_dir.name, + '--mask', in_mask, + '--in_altnp', in_e1_altnp, + '--in_altpn', in_e1_altpn, + '--in_mtoff_pd', in_e1_mtoff_pd, + '--in_negative', in_e1_neg, + '--in_positive', in_e1_pos, + '--in_mtoff_t1', in_e1_mtoff_t1, + '--out_prefix', 'sub_01', + '--in_acq_parameters', '15', '15', '0.1', '0.1', + '-f']) + assert ret.success diff --git a/scripts/tests/test_plot_stats_per_point.py b/src/scilpy/cli/tests/test_plot_stats_per_point.py similarity index 76% rename from scripts/tests/test_plot_stats_per_point.py rename to src/scilpy/cli/tests/test_plot_stats_per_point.py index 3c72c7721..0d2516822 100644 --- a/scripts/tests/test_plot_stats_per_point.py +++ b/src/scilpy/cli/tests/test_plot_stats_per_point.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_plot_stats_per_point.py', '--help') + ret = script_runner.run(['scil_plot_stats_per_point', '--help']) assert ret.success @@ -21,7 +21,7 @@ def test_execution_tractometry(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_json = os.path.join(SCILPY_HOME, 'tractometry', 'metric_label.json') - ret = script_runner.run('scil_plot_stats_per_point.py', in_json, - 'out/', '--stats_over_population') + ret = script_runner.run(['scil_plot_stats_per_point', in_json, + 'out/', '--stats_over_population']) assert ret.success diff --git a/scripts/tests/test_qball_metrics.py b/src/scilpy/cli/tests/test_qball_metrics.py similarity index 79% rename from scripts/tests/test_qball_metrics.py rename to src/scilpy/cli/tests/test_qball_metrics.py index 0a44b4659..4fcc07da2 100644 --- a/scripts/tests/test_qball_metrics.py +++ b/src/scilpy/cli/tests/test_qball_metrics.py @@ -12,7 +12,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_qball_metrics.py', '--help') + ret = script_runner.run(['scil_qball_metrics', '--help']) assert ret.success @@ -24,8 +24,8 @@ def test_execution_processing(script_runner, monkeypatch): '1000.bval') in_bvec = os.path.join(SCILPY_HOME, 'processing', '1000.bvec') - ret = script_runner.run('scil_qball_metrics.py', in_dwi, - in_bval, in_bvec) + ret = script_runner.run(['scil_qball_metrics', in_dwi, + in_bval, in_bvec]) assert ret.success @@ -37,12 +37,12 @@ def test_execution_not_all(script_runner, monkeypatch): '1000.bval') in_bvec = os.path.join(SCILPY_HOME, 'processing', '1000.bvec') - ret = script_runner.run('scil_qball_metrics.py', in_dwi, - in_bval, in_bvec, "--not_all", "--sh", "2.nii.gz") + ret = script_runner.run(['scil_qball_metrics', in_dwi, + in_bval, in_bvec, "--not_all", "--sh", "2.nii.gz"]) assert ret.success # Test wrong b0. Current minimal b-val is 5. - ret = script_runner.run('scil_qball_metrics.py', in_dwi, + ret = script_runner.run(['scil_qball_metrics', in_dwi, in_bval, in_bvec, "--not_all", "--sh", "2.nii.gz", - '--b0_threshold', '1', '-f') + '--b0_threshold', '1', '-f']) assert not ret.success diff --git a/scripts/tests/test_rgb_convert.py b/src/scilpy/cli/tests/test_rgb_convert.py similarity index 79% rename from scripts/tests/test_rgb_convert.py rename to src/scilpy/cli/tests/test_rgb_convert.py index 0936de0f0..a56afbe2d 100644 --- a/scripts/tests/test_rgb_convert.py +++ b/src/scilpy/cli/tests/test_rgb_convert.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_rgb_convert.py', '--help') + ret = script_runner.run(['scil_rgb_convert', '--help']) assert ret.success @@ -21,6 +21,6 @@ def test_execution_others(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_img = os.path.join(SCILPY_HOME, 'others', 'rgb.nii.gz') - ret = script_runner.run('scil_rgb_convert.py', - in_img, 'rgb_4D.nii.gz') + ret = script_runner.run(['scil_rgb_convert', + in_img, 'rgb_4D.nii.gz']) assert ret.success diff --git a/scripts/tests/test_search_keywords.py b/src/scilpy/cli/tests/test_search_keywords.py similarity index 56% rename from scripts/tests/test_search_keywords.py rename to src/scilpy/cli/tests/test_search_keywords.py index 44dd6c907..95ee786f8 100644 --- a/scripts/tests/test_search_keywords.py +++ b/src/scilpy/cli/tests/test_search_keywords.py @@ -3,21 +3,22 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_search_keywords.py', '--help') + ret = script_runner.run(['scil_search_keywords', '--help']) assert ret.success def test_search_category(script_runner): - ret = script_runner.run('scil_search_keywords.py', '--search_category', 'sh') + ret = script_runner.run(['scil_search_keywords', + '--search_category', 'sh']) assert 'Available objects:' in ret.stdout def test_no_synonyms(script_runner): - ret = script_runner.run('scil_search_keywords.py', 'sh', '--no_synonyms') + ret = script_runner.run(['scil_search_keywords', 'sh', '--no_synonyms']) assert ret.success def test_not_found(script_runner): - ret = script_runner.run('scil_search_keywords.py', 'toto') + ret = script_runner.run(['scil_search_keywords', 'toto']) assert ret.success assert 'No results found!' in ret.stdout or 'No results found!' in ret.stderr diff --git a/scripts/tests/test_sh_convert.py b/src/scilpy/cli/tests/test_sh_convert.py similarity index 71% rename from scripts/tests/test_sh_convert.py rename to src/scilpy/cli/tests/test_sh_convert.py index ca8549893..8d2ed3eac 100644 --- a/scripts/tests/test_sh_convert.py +++ b/src/scilpy/cli/tests/test_sh_convert.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_sh_convert.py', '--help') + ret = script_runner.run(['scil_sh_convert', '--help']) assert ret.success @@ -21,7 +21,7 @@ def test_execution_processing(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_fodf = os.path.join(SCILPY_HOME, 'processing', 'fodf.nii.gz') - ret = script_runner.run('scil_sh_convert.py', in_fodf, - 'fodf_descoteaux07.nii.gz', 'tournier07', - 'descoteaux07_legacy', '--processes', '1') + ret = script_runner.run(['scil_sh_convert', in_fodf, + 'fodf_descoteaux07.nii.gz', 'tournier07', + 'descoteaux07_legacy', '--processes', '1']) assert ret.success diff --git a/scripts/tests/test_sh_fusion.py b/src/scilpy/cli/tests/test_sh_fusion.py similarity index 84% rename from scripts/tests/test_sh_fusion.py rename to src/scilpy/cli/tests/test_sh_fusion.py index dc6b07a6e..b1f157245 100644 --- a/scripts/tests/test_sh_fusion.py +++ b/src/scilpy/cli/tests/test_sh_fusion.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_sh_fusion.py', '--help') + ret = script_runner.run(['scil_sh_fusion', '--help']) assert ret.success @@ -23,5 +23,5 @@ def test_execution_processing(script_runner, monkeypatch): 'sh_1000.nii.gz') in_sh_2 = os.path.join(SCILPY_HOME, 'processing', 'sh_3000.nii.gz') - ret = script_runner.run('scil_sh_fusion.py', in_sh_1, in_sh_2, 'sh.nii.gz') + ret = script_runner.run(['scil_sh_fusion', in_sh_1, in_sh_2, 'sh.nii.gz']) assert ret.success diff --git a/scripts/tests/test_sh_to_aodf.py b/src/scilpy/cli/tests/test_sh_to_aodf.py similarity index 55% rename from scripts/tests/test_sh_to_aodf.py rename to src/scilpy/cli/tests/test_sh_to_aodf.py index 17a9c819d..6d0c198e7 100644 --- a/scripts/tests/test_sh_to_aodf.py +++ b/src/scilpy/cli/tests/test_sh_to_aodf.py @@ -17,7 +17,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_sh_to_aodf.py', '--help') + ret = script_runner.run(['scil_sh_to_aodf', '--help']) assert ret.success @@ -25,21 +25,21 @@ def test_help_option(script_runner): [os.path.join(test_data_root, "fodf_descoteaux07_sub.nii.gz"), os.path.join(test_data_root, "fodf_descoteaux07_sub_unified_asym.nii.gz")]]) -def test_asym_basis_output_gpu(script_runner, in_fodf, expected_fodf, monkeypatch): +def test_asym_basis_output_gpu(script_runner, in_fodf, + expected_fodf, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_sh_to_aodf.py', - in_fodf, 'out_fodf1.nii.gz', - '--sphere', 'repulsion100', - '--sigma_align', '0.8', - '--sigma_spatial', '1.0', - '--sigma_range', '0.2', - '--sigma_angle', '0.06', - '--use_opencl', - '--device', 'gpu', - '--sh_basis', 'descoteaux07_legacy', '-f', - '--include_center', - print_result=True, shell=True) + ret = script_runner.run(['scil_sh_to_aodf', + in_fodf, 'out_fodf1.nii.gz', + '--sphere', 'repulsion100', + '--sigma_align', '0.8', + '--sigma_spatial', '1.0', + '--sigma_range', '0.2', + '--sigma_angle', '0.06', + '--use_opencl', + '--device', 'gpu', + '--sh_basis', 'descoteaux07_legacy', '-f', + '--include_center']) if have_opencl: # if we have opencl the script should not raise an error @@ -64,17 +64,16 @@ def test_asym_basis_output_gpu(script_runner, in_fodf, expected_fodf, monkeypatc def test_asym_basis_output(script_runner, in_fodf, expected_fodf, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_sh_to_aodf.py', - in_fodf, 'out_fodf1.nii.gz', - '--sphere', 'repulsion100', - '--sigma_align', '0.8', - '--sigma_spatial', '1.0', - '--sigma_range', '0.2', - '--sigma_angle', '0.06', - '--device', 'cpu', - '--sh_basis', 'descoteaux07_legacy', '-f', - '--include_center', - print_result=True, shell=True) + ret = script_runner.run(['scil_sh_to_aodf', + in_fodf, 'out_fodf1.nii.gz', + '--sphere', 'repulsion100', + '--sigma_align', '0.8', + '--sigma_spatial', '1.0', + '--sigma_range', '0.2', + '--sigma_angle', '0.06', + '--device', 'cpu', + '--sh_basis', 'descoteaux07_legacy', '-f', + '--include_center']) assert ret.success @@ -91,17 +90,16 @@ def test_asym_basis_output(script_runner, in_fodf, expected_fodf, monkeypatch): def test_asym_input(script_runner, in_fodf, expected_fodf, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_sh_to_aodf.py', - in_fodf, 'out_fodf1.nii.gz', - '--sphere', 'repulsion100', - '--sigma_align', '0.8', - '--sigma_spatial', '1.0', - '--sigma_range', '0.2', - '--sigma_angle', '0.06', - '--device', 'cpu', - '--sh_basis', 'descoteaux07_legacy', '-f', - '--include_center', - print_result=True, shell=True) + ret = script_runner.run(['scil_sh_to_aodf', + in_fodf, 'out_fodf1.nii.gz', + '--sphere', 'repulsion100', + '--sigma_align', '0.8', + '--sigma_spatial', '1.0', + '--sigma_range', '0.2', + '--sigma_angle', '0.06', + '--device', 'cpu', + '--sh_basis', 'descoteaux07_legacy', '-f', + '--include_center']) assert ret.success @@ -117,12 +115,11 @@ def test_asym_input(script_runner, in_fodf, expected_fodf, monkeypatch): def test_cosine_method(script_runner, in_fodf, out_fodf, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_sh_to_aodf.py', - in_fodf, 'out_fodf1.nii.gz', - '--sphere', 'repulsion100', - '--method', 'cosine', '-f', - '--sh_basis', 'descoteaux07_legacy', - print_result=True, shell=True) + ret = script_runner.run(['scil_sh_to_aodf', + in_fodf, 'out_fodf1.nii.gz', + '--sphere', 'repulsion100', + '--method', 'cosine', '-f', + '--sh_basis', 'descoteaux07_legacy']) assert ret.success diff --git a/scripts/tests/test_sh_to_rish.py b/src/scilpy/cli/tests/test_sh_to_rish.py similarity index 77% rename from scripts/tests/test_sh_to_rish.py rename to src/scilpy/cli/tests/test_sh_to_rish.py index 6568c29b9..d84e63536 100644 --- a/scripts/tests/test_sh_to_rish.py +++ b/src/scilpy/cli/tests/test_sh_to_rish.py @@ -13,13 +13,13 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_sh_to_rish.py', '--help') + ret = script_runner.run(['scil_sh_to_rish', '--help']) assert ret.success def test_execution_processing(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_sh = os.path.join(SCILPY_HOME, 'processing', - 'sh.nii.gz') - ret = script_runner.run('scil_sh_to_rish.py', in_sh, 'rish.nii.gz') + 'sh.nii.gz') + ret = script_runner.run(['scil_sh_to_rish', in_sh, 'rish.nii.gz']) assert ret.success diff --git a/scripts/tests/test_sh_to_sf.py b/src/scilpy/cli/tests/test_sh_to_sf.py similarity index 52% rename from scripts/tests/test_sh_to_sf.py rename to src/scilpy/cli/tests/test_sh_to_sf.py index 8703876c3..41156a8d9 100644 --- a/scripts/tests/test_sh_to_sf.py +++ b/src/scilpy/cli/tests/test_sh_to_sf.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_sh_to_sf.py', '--help') + ret = script_runner.run(['scil_sh_to_sf', '--help']) assert ret.success @@ -24,12 +24,12 @@ def test_execution_in_sphere(script_runner, monkeypatch): in_bval = os.path.join(SCILPY_HOME, 'processing', '1000.bval') # Required: either --sphere or --in_bvec. Here, --sphere - ret = script_runner.run('scil_sh_to_sf.py', in_sh, - 'sf_724.nii.gz', '--in_bval', - in_bval, '--in_b0', in_b0, '--out_bval', - 'sf_724.bval', '--out_bvec', 'sf_724.bvec', - '--sphere', 'symmetric724', '--dtype', 'float32', - '--processes', '1') + ret = script_runner.run(['scil_sh_to_sf', in_sh, + 'sf_724.nii.gz', '--in_bval', + in_bval, '--in_b0', in_b0, '--out_bval', + 'sf_724.bval', '--out_bvec', 'sf_724.bvec', + '--sphere', 'symmetric724', '--dtype', 'float32', + '--processes', '1']) assert ret.success @@ -40,20 +40,20 @@ def test_execution_in_bvec(script_runner, monkeypatch): in_bvec = os.path.join(SCILPY_HOME, 'processing', '1000.bvec') # --in_bvec: in_bval is required. - ret = script_runner.run('scil_sh_to_sf.py', in_sh, - 'sf_724.nii.gz', '--in_bval', in_bval, - '--out_bval', 'sf_724.bval', - '--out_bvec', 'sf_724.bvec', - '--in_bvec', in_bvec, '--dtype', 'float32', '-f', - '--processes', '1') + ret = script_runner.run(['scil_sh_to_sf', in_sh, + 'sf_724.nii.gz', '--in_bval', in_bval, + '--out_bval', 'sf_724.bval', + '--out_bvec', 'sf_724.bvec', + '--in_bvec', in_bvec, '--dtype', 'float32', '-f', + '--processes', '1']) assert ret.success # Test that fails if no bvals is given. - ret = script_runner.run('scil_sh_to_sf.py', in_sh, - 'sf_724.nii.gz', - '--out_bvec', 'sf_724.bvec', - '--in_bvec', in_bvec, '--dtype', 'float32', '-f', - '--processes', '1') + ret = script_runner.run(['scil_sh_to_sf', in_sh, + 'sf_724.nii.gz', + '--out_bvec', 'sf_724.bvec', + '--in_bvec', in_bvec, '--dtype', 'float32', '-f', + '--processes', '1']) assert not ret.success @@ -64,9 +64,9 @@ def test_execution_no_bval(script_runner, monkeypatch): # --sphere but no --bval # Testing multiprocessing option - ret = script_runner.run('scil_sh_to_sf.py', in_sh, - 'sf_724.nii.gz', '--in_b0', in_b0, - '--out_bvec', 'sf_724.bvec', '--b0_scaling', - '--sphere', 'symmetric724', '--dtype', 'float32', - '-f', '--processes', '4') + ret = script_runner.run(['scil_sh_to_sf', in_sh, + 'sf_724.nii.gz', '--in_b0', in_b0, + '--out_bvec', 'sf_724.bvec', '--b0_scaling', + '--sphere', 'symmetric724', '--dtype', 'float32', + '-f', '--processes', '4']) assert ret.success diff --git a/scripts/tests/test_stats_group_comparison.py b/src/scilpy/cli/tests/test_stats_group_comparison.py similarity index 65% rename from scripts/tests/test_stats_group_comparison.py rename to src/scilpy/cli/tests/test_stats_group_comparison.py index 70b7a9364..cf2ca8929 100644 --- a/scripts/tests/test_stats_group_comparison.py +++ b/src/scilpy/cli/tests/test_stats_group_comparison.py @@ -13,9 +13,9 @@ def test_help_option(script_runner): - ret = script_runner.run( - 'scil_stats_group_comparison.py', - '--help') + ret = script_runner.run([ + 'scil_stats_group_comparison', + '--help']) assert ret.success @@ -25,11 +25,11 @@ def test_execution_bundles(script_runner, monkeypatch): in_participants = os.path.join(SCILPY_HOME, 'stats/group', 'meanstd_all.json') - ret = script_runner.run('scil_stats_group_comparison.py', - in_participants, in_json, 'Group', - '-b', 'AF_L', - '-m', 'FIT_FW', - '--va', 'mean', - '--gg') + ret = script_runner.run(['scil_stats_group_comparison', + in_participants, in_json, 'Group', + '-b', 'AF_L', + '-m', 'FIT_FW', + '--va', 'mean', + '--gg']) assert ret.success diff --git a/scripts/tests/test_surface_apply_transform.py b/src/scilpy/cli/tests/test_surface_apply_transform.py similarity index 77% rename from scripts/tests/test_surface_apply_transform.py rename to src/scilpy/cli/tests/test_surface_apply_transform.py index 80a0e6767..0bb0694ba 100644 --- a/scripts/tests/test_surface_apply_transform.py +++ b/src/scilpy/cli/tests/test_surface_apply_transform.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_surface_apply_transform.py', '--help') + ret = script_runner.run(['scil_surface_apply_transform', '--help']) assert ret.success @@ -23,6 +23,6 @@ def test_execution_surface_vtk_fib(script_runner, monkeypatch): 'lhpialt.vtk') in_aff = os.path.join(SCILPY_HOME, 'surface_vtk_fib', 'affine.txt') - ret = script_runner.run('scil_surface_apply_transform.py', in_surf, - in_aff, 'lhpialt_lin.vtk', '--inverse') + ret = script_runner.run(['scil_surface_apply_transform', in_surf, + in_aff, 'lhpialt_lin.vtk', '--inverse']) assert ret.success diff --git a/scripts/tests/test_surface_convert.py b/src/scilpy/cli/tests/test_surface_convert.py similarity index 72% rename from scripts/tests/test_surface_convert.py rename to src/scilpy/cli/tests/test_surface_convert.py index d14cfc851..202ce5e25 100644 --- a/scripts/tests/test_surface_convert.py +++ b/src/scilpy/cli/tests/test_surface_convert.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_surface_convert.py', '--help') + ret = script_runner.run(['scil_surface_convert', '--help']) assert ret.success @@ -21,8 +21,8 @@ def test_execution_surface_vtk_fib(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_surf = os.path.join(SCILPY_HOME, 'surface_vtk_fib', 'lhpialt.vtk') - ret = script_runner.run('scil_surface_convert.py', in_surf, - 'rhpialt.ply') + ret = script_runner.run(['scil_surface_convert', in_surf, + 'rhpialt.ply']) assert ret.success @@ -31,7 +31,7 @@ def test_execution_surface_vtk_xfrom(script_runner, monkeypatch): in_surf = os.path.join(SCILPY_HOME, 'surface_vtk_fib', 'lh.pialt_xform') ref = os.path.join(SCILPY_HOME, 'surface_vtk_fib', 'fa.nii.gz') - ret = script_runner.run('scil_surface_convert.py', in_surf, - 'lh.pialt_xform.vtk', '--reference', ref, - '--flip_axes', '-1', '-1', '1') + ret = script_runner.run(['scil_surface_convert', in_surf, + 'lh.pialt_xform.vtk', '--reference', ref, + '--flip_axes', '-1', '-1', '1']) assert ret.success diff --git a/src/scilpy/cli/tests/test_surface_create.py b/src/scilpy/cli/tests/test_surface_create.py new file mode 100644 index 000000000..9430a93f8 --- /dev/null +++ b/src/scilpy/cli/tests/test_surface_create.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import os +import tempfile + +from scilpy import SCILPY_HOME +from scilpy.io.fetcher import fetch_data, get_testing_files_dict + +# If they already exist, this only takes 5 seconds (check md5sum) +fetch_data(get_testing_files_dict(), keys=['atlas.zip']) +fetch_data(get_testing_files_dict(), keys=['others.zip']) +tmp_dir = tempfile.TemporaryDirectory() + + +def test_help_option(script_runner): + ret = script_runner.run(['scil_surface_create', '--help']) + assert ret.success + + +def test_execution_atlas(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + in_atlas = os.path.join(SCILPY_HOME, 'atlas', + 'atlas_freesurfer_v2.nii.gz') + ret = script_runner.run(['scil_surface_create', + '--in_labels', in_atlas, + 'surface.vtk', + '--list_indices', '2024:2035 1024', + '--fill', + '--smooth', '1', + '--erosion', '1', + '--dilation', '1', + '--opening', '1', + '--closing', '1', '-f']) + assert ret.success + + +def test_execution_atlas_each_index(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + in_atlas = os.path.join(SCILPY_HOME, 'atlas', + 'atlas_freesurfer_v2.nii.gz') + ret = script_runner.run(['scil_surface_create', + '--in_labels', in_atlas, + 'surface.vtk', + '--each_index', + '--fill', + '--smooth', '1', + '--erosion', '1', + '--dilation', '1', + '--opening', '1', + '--closing', '1', + '--vtk2vox', '-f']) + assert ret.success + + +def test_execution_atlas_no_index(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + in_atlas = os.path.join(SCILPY_HOME, 'atlas', + 'atlas_freesurfer_v2.nii.gz') + ret = script_runner.run(['scil_surface_create', + '--in_labels', in_atlas, + 'surface.vtk', + '--fill', + '--smooth', '1', + '--erosion', '1', + '--dilation', '1', + '--opening', '1', + '--closing', '1', '-f']) + assert ret.success + + +def test_execution_mask(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + in_mask = os.path.join(SCILPY_HOME, 'atlas', + 'brainstem_bin.nii.gz') + ret = script_runner.run(['scil_surface_create', + '--in_mask', in_mask, + 'surface.vtk', '-f']) + assert ret.success + + +def test_execution_volume(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + in_t1 = os.path.join(SCILPY_HOME, 'others', + 't1.nii.gz') + ret = script_runner.run(['scil_surface_create', + '--in_volume', in_t1, + '--value', '0.2', + 'surface.vtk', '-f']) + assert ret.success diff --git a/scripts/tests/test_surface_flip.py b/src/scilpy/cli/tests/test_surface_flip.py similarity index 81% rename from scripts/tests/test_surface_flip.py rename to src/scilpy/cli/tests/test_surface_flip.py index 6ebf77018..006fb0964 100644 --- a/scripts/tests/test_surface_flip.py +++ b/src/scilpy/cli/tests/test_surface_flip.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_surface_flip.py', '--help') + ret = script_runner.run(['scil_surface_flip', '--help']) assert ret.success @@ -23,6 +23,6 @@ def test_execution_surface_vtk_fib(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_surf = os.path.join(SCILPY_HOME, 'surface_vtk_fib', 'lhpialt.vtk') - ret = script_runner.run('scil_surface_flip.py', in_surf, 'rhpialt.vtk', - 'x') + ret = script_runner.run(['scil_surface_flip', in_surf, 'rhpialt.vtk', + 'x']) assert ret.success diff --git a/scripts/tests/test_surface_smooth.py b/src/scilpy/cli/tests/test_surface_smooth.py similarity index 76% rename from scripts/tests/test_surface_smooth.py rename to src/scilpy/cli/tests/test_surface_smooth.py index 11d0b8e58..7e20b3efc 100644 --- a/scripts/tests/test_surface_smooth.py +++ b/src/scilpy/cli/tests/test_surface_smooth.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_surface_smooth.py', '--help') + ret = script_runner.run(['scil_surface_smooth', '--help']) assert ret.success @@ -21,6 +21,6 @@ def test_execution_surface_vtk_fib(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_surf = os.path.join(SCILPY_HOME, 'surface_vtk_fib', 'lhpialt.vtk') - ret = script_runner.run('scil_surface_smooth.py', in_surf, - 'lhpialt_smooth.vtk', '-n', '5', '-s', '1') + ret = script_runner.run(['scil_surface_smooth', in_surf, + 'lhpialt_smooth.vtk', '-n', '5', '-s', '1']) assert ret.success diff --git a/scripts/tests/test_tracking_local.py b/src/scilpy/cli/tests/test_tracking_local.py similarity index 53% rename from scripts/tests/test_tracking_local.py rename to src/scilpy/cli/tests/test_tracking_local.py index 38f89a3e9..2a06a9294 100644 --- a/scripts/tests/test_tracking_local.py +++ b/src/scilpy/cli/tests/test_tracking_local.py @@ -14,7 +14,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tracking_local.py', '--help') + ret = script_runner.run(['scil_tracking_local', '--help']) assert ret.success @@ -26,10 +26,10 @@ def test_execution_tracking_fodf_prob(script_runner, monkeypatch): in_fodf = os.path.join(SCILPY_HOME, 'tracking', 'fodf.nii.gz') in_mask = os.path.join(SCILPY_HOME, 'tracking', 'seeding_mask.nii.gz') - ret = script_runner.run('scil_tracking_local.py', in_fodf, - in_mask, in_mask, 'local_prob.trk', '--nt', '100', - '--compress', '0.1', '--sh_basis', 'descoteaux07', - '--min_length', '20', '--max_length', '200') + ret = script_runner.run(['scil_tracking_local', in_fodf, + in_mask, in_mask, 'local_prob.trk', '--nt', '100', + '--compress', '0.1', '--sh_basis', 'descoteaux07', + '--min_length', '20', '--max_length', '200']) assert ret.success @@ -38,11 +38,11 @@ def test_execution_tracking_fodf_det(script_runner, monkeypatch): in_fodf = os.path.join(SCILPY_HOME, 'tracking', 'fodf.nii.gz') in_mask = os.path.join(SCILPY_HOME, 'tracking', 'seeding_mask.nii.gz') - ret = script_runner.run('scil_tracking_local.py', in_fodf, - in_mask, in_mask, 'local_det.trk', '--nt', '100', - '--compress', '0.1', '--sh_basis', 'descoteaux07', - '--min_length', '20', '--max_length', '200', - '--algo', 'det') + ret = script_runner.run(['scil_tracking_local', in_fodf, + in_mask, in_mask, 'local_det.trk', '--nt', '100', + '--compress', '0.1', '--sh_basis', 'descoteaux07', + '--min_length', '20', '--max_length', '200', + '--algo', 'det']) assert ret.success @@ -51,11 +51,11 @@ def test_execution_tracking_ptt(script_runner, monkeypatch): in_fodf = os.path.join(SCILPY_HOME, 'tracking', 'fodf.nii.gz') in_mask = os.path.join(SCILPY_HOME, 'tracking', 'seeding_mask.nii.gz') - ret = script_runner.run('scil_tracking_local.py', in_fodf, - in_mask, in_mask, 'local_ptt.trk', '--nt', '100', - '--compress', '0.1', '--sh_basis', 'descoteaux07', - '--min_length', '20', '--max_length', '200', - '--algo', 'ptt', '-f') + ret = script_runner.run(['scil_tracking_local', in_fodf, + in_mask, in_mask, 'local_ptt.trk', '--nt', '100', + '--compress', '0.1', '--sh_basis', 'descoteaux07', + '--min_length', '20', '--max_length', '200', + '--algo', 'ptt', '-f']) assert ret.success @@ -64,12 +64,12 @@ def test_execution_sphere_subdivide(script_runner, monkeypatch): in_fodf = os.path.join(SCILPY_HOME, 'tracking', 'fodf.nii.gz') in_mask = os.path.join(SCILPY_HOME, 'tracking', 'seeding_mask.nii.gz') - ret = script_runner.run('scil_tracking_local.py', in_fodf, - in_mask, in_mask, 'local_sphere.trk', - '--nt', '100', - '--compress', '0.1', '--sh_basis', 'descoteaux07', - '--min_length', '20', '--max_length', '200', - '--sub_sphere', '2') + ret = script_runner.run(['scil_tracking_local', in_fodf, + in_mask, in_mask, 'local_sphere.trk', + '--nt', '100', + '--compress', '0.1', '--sh_basis', 'descoteaux07', + '--min_length', '20', '--max_length', '200', + '--sub_sphere', '2']) assert ret.success @@ -78,10 +78,10 @@ def test_execution_sphere_gpu(script_runner, monkeypatch): in_fodf = os.path.join(SCILPY_HOME, 'tracking', 'fodf.nii.gz') in_mask = os.path.join(SCILPY_HOME, 'tracking', 'seeding_mask.nii.gz') - ret = script_runner.run('scil_tracking_local.py', in_fodf, - in_mask, in_mask, 'sphere_gpu.trk', - '--use_gpu', '--sphere', 'symmetric362', - '--npv', '1') + ret = script_runner.run(['scil_tracking_local', in_fodf, + in_mask, in_mask, 'sphere_gpu.trk', + '--use_gpu', '--sphere', 'symmetric362', + '--npv', '1']) assert not ret.success @@ -91,9 +91,9 @@ def test_sh_interp_without_gpu(script_runner, monkeypatch): in_fodf = os.path.join(SCILPY_HOME, 'tracking', 'fodf.nii.gz') in_mask = os.path.join(SCILPY_HOME, 'tracking', 'seeding_mask.nii.gz') - ret = script_runner.run('scil_tracking_local.py', in_fodf, - in_mask, in_mask, 'nearest_interp.trk', - '--sh_interp', 'nearest', '--nt', '100') + ret = script_runner.run(['scil_tracking_local', in_fodf, + in_mask, in_mask, 'nearest_interp.trk', + '--sh_interp', 'nearest', '--nt', '100']) assert not ret.success @@ -103,9 +103,9 @@ def test_forward_without_gpu(script_runner, monkeypatch): in_fodf = os.path.join(SCILPY_HOME, 'tracking', 'fodf.nii.gz') in_mask = os.path.join(SCILPY_HOME, 'tracking', 'seeding_mask.nii.gz') - ret = script_runner.run('scil_tracking_local.py', in_fodf, - in_mask, in_mask, 'fwd_only.trk', - '--forward_only', '--nt', '100') + ret = script_runner.run(['scil_tracking_local', in_fodf, + in_mask, in_mask, 'fwd_only.trk', + '--forward_only', '--nt', '100']) assert not ret.success @@ -115,9 +115,9 @@ def test_batch_size_without_gpu(script_runner, monkeypatch): in_fodf = os.path.join(SCILPY_HOME, 'tracking', 'fodf.nii.gz') in_mask = os.path.join(SCILPY_HOME, 'tracking', 'seeding_mask.nii.gz') - ret = script_runner.run('scil_tracking_local.py', in_fodf, - in_mask, in_mask, 'batch.trk', - '--batch_size', 100) + ret = script_runner.run(['scil_tracking_local', in_fodf, + in_mask, in_mask, 'batch.trk', + '--batch_size', 100]) assert not ret.success @@ -127,9 +127,9 @@ def test_algo_with_gpu(script_runner, monkeypatch): in_fodf = os.path.join(SCILPY_HOME, 'tracking', 'fodf.nii.gz') in_mask = os.path.join(SCILPY_HOME, 'tracking', 'seeding_mask.nii.gz') - ret = script_runner.run('scil_tracking_local.py', in_fodf, - in_mask, in_mask, 'gpu_det.trk', '--algo', - 'det', '--use_gpu', '--nt', '100') + ret = script_runner.run(['scil_tracking_local', in_fodf, + in_mask, in_mask, 'gpu_det.trk', '--algo', + 'det', '--use_gpu', '--nt', '100']) assert not ret.success @@ -139,10 +139,10 @@ def test_execution_tracking_fodf_no_compression(script_runner, monkeypatch): in_fodf = os.path.join(SCILPY_HOME, 'tracking', 'fodf.nii.gz') in_mask = os.path.join(SCILPY_HOME, 'tracking', 'seeding_mask.nii.gz') - ret = script_runner.run('scil_tracking_local.py', in_fodf, - in_mask, in_mask, 'local_prob2.trk', - '--nt', '100', '--sh_basis', 'descoteaux07', - '--max_length', '200') + ret = script_runner.run(['scil_tracking_local', in_fodf, + in_mask, in_mask, 'local_prob2.trk', + '--nt', '100', '--sh_basis', 'descoteaux07', + '--max_length', '200']) assert ret.success @@ -151,11 +151,11 @@ def test_execution_tracking_peaks(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_peaks = os.path.join(SCILPY_HOME, 'tracking', 'peaks.nii.gz') in_mask = os.path.join(SCILPY_HOME, 'tracking', 'seeding_mask.nii.gz') - ret = script_runner.run('scil_tracking_local.py', in_peaks, - in_mask, in_mask, 'local_eudx.trk', '--nt', '100', - '--compress', '0.1', '--sh_basis', 'descoteaux07', - '--min_length', '20', '--max_length', '200', - '--algo', 'eudx') + ret = script_runner.run(['scil_tracking_local', in_peaks, + in_mask, in_mask, 'local_eudx.trk', '--nt', '100', + '--compress', '0.1', '--sh_basis', 'descoteaux07', + '--min_length', '20', '--max_length', '200', + '--algo', 'eudx']) assert ret.success @@ -164,11 +164,12 @@ def test_execution_tracking_fodf_prob_pmf_mapping(script_runner, monkeypatch): in_fodf = os.path.join(SCILPY_HOME, 'tracking', 'fodf.nii.gz') in_mask = os.path.join(SCILPY_HOME, 'tracking', 'seeding_mask.nii.gz') - ret = script_runner.run('scil_tracking_local.py', in_fodf, - in_mask, in_mask, 'local_prob3.trk', '--nt', '100', - '--compress', '0.1', '--sh_basis', 'descoteaux07', - '--min_length', '20', '--max_length', '200', - '--sh_to_pmf', '-v') + ret = script_runner.run(['scil_tracking_local', in_fodf, + in_mask, in_mask, 'local_prob3.trk', + '--nt', '100', + '--compress', '0.1', '--sh_basis', 'descoteaux07', + '--min_length', '20', '--max_length', '200', + '--sh_to_pmf', '-v']) assert ret.success @@ -177,12 +178,12 @@ def test_execution_tracking_ptt_with_probe(script_runner, monkeypatch): in_fodf = os.path.join(SCILPY_HOME, 'tracking', 'fodf.nii.gz') in_mask = os.path.join(SCILPY_HOME, 'tracking', 'seeding_mask.nii.gz') - ret = script_runner.run('scil_tracking_local.py', in_fodf, - in_mask, in_mask, 'local_ptt.trk', '--nt', '100', - '--compress', '0.1', '--sh_basis', 'descoteaux07', - '--min_length', '20', '--max_length', '200', - '--sh_to_pmf', '-v', '--probe_length', '2', - '--probe_quality', '5', '--algo', 'ptt', '-f') + ret = script_runner.run(['scil_tracking_local', in_fodf, + in_mask, in_mask, 'local_ptt.trk', '--nt', '100', + '--compress', '0.1', '--sh_basis', 'descoteaux07', + '--min_length', '20', '--max_length', '200', + '--sh_to_pmf', '-v', '--probe_length', '2', + '--probe_quality', '5', '--algo', 'ptt', '-f']) assert ret.success @@ -195,9 +196,9 @@ def test_execution_tracking_fodf_custom_seeds(script_runner, monkeypatch): custom_seeds = [[1., 1., 1.], [2., 2., 2.], [3., 3., 3.]] np.save(in_custom_seeds, custom_seeds) - ret = script_runner.run('scil_tracking_local.py', in_fodf, - in_mask, in_mask, 'local_prob4.trk', - '--in_custom_seeds', in_custom_seeds, - '--compress', '0.1', '--sh_basis', 'descoteaux07', - '--min_length', '20', '--max_length', '200') + ret = script_runner.run(['scil_tracking_local', in_fodf, + in_mask, in_mask, 'local_prob4.trk', + '--in_custom_seeds', in_custom_seeds, + '--compress', '0.1', '--sh_basis', 'descoteaux07', + '--min_length', '20', '--max_length', '200']) assert ret.success diff --git a/scripts/tests/test_tracking_local_dev.py b/src/scilpy/cli/tests/test_tracking_local_dev.py similarity index 50% rename from scripts/tests/test_tracking_local_dev.py rename to src/scilpy/cli/tests/test_tracking_local_dev.py index 38d79d01b..b7d95bdee 100644 --- a/scripts/tests/test_tracking_local_dev.py +++ b/src/scilpy/cli/tests/test_tracking_local_dev.py @@ -14,8 +14,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tracking_local_dev.py', - '--help') + ret = script_runner.run(['scil_tracking_local_dev', + '--help']) assert ret.success @@ -25,13 +25,13 @@ def test_execution_tracking_fodf(script_runner, monkeypatch): 'fodf.nii.gz') in_mask = os.path.join(SCILPY_HOME, 'tracking', 'seeding_mask.nii.gz') - ret = script_runner.run('scil_tracking_local_dev.py', in_fodf, - in_mask, in_mask, 'local_prob.trk', '--nt', '10', - '--compress', '0.1', '--sh_basis', 'descoteaux07', - '--min_length', '20', '--max_length', '200', - '--save_seeds', '--rng_seed', '0', - '--sub_sphere', '2', - '--rk_order', '4') + ret = script_runner.run(['scil_tracking_local_dev', in_fodf, + in_mask, in_mask, 'local_prob.trk', '--nt', '10', + '--compress', '0.1', '--sh_basis', 'descoteaux07', + '--min_length', '20', '--max_length', '200', + '--save_seeds', '--rng_seed', '0', + '--sub_sphere', '2', + '--rk_order', '4']) assert ret.success @@ -44,15 +44,16 @@ def test_execution_tracking_rap(script_runner, monkeypatch): in_rap_mask = os.path.join(SCILPY_HOME, 'tracking', 'seeding_mask.nii.gz') - ret = script_runner.run('scil_tracking_local_dev.py', in_fodf, - in_mask, in_mask, 'local_prob_rap.trk', '--nt', '10', - '--compress', '0.1', '--sh_basis', 'descoteaux07', - '--min_length', '20', '--max_length', '200', - '--save_seeds', '--rng_seed', '0', - '--sub_sphere', '2', - '--rk_order', '1', - '--rap_mask', in_rap_mask, - '--rap_method', "continue") + ret = script_runner.run(['scil_tracking_local_dev', in_fodf, + in_mask, in_mask, 'local_prob_rap.trk', + '--nt', '10', + '--compress', '0.1', '--sh_basis', 'descoteaux07', + '--min_length', '20', '--max_length', '200', + '--save_seeds', '--rng_seed', '0', + '--sub_sphere', '2', + '--rk_order', '1', + '--rap_mask', in_rap_mask, + '--rap_method', "continue"]) assert ret.success @@ -67,12 +68,12 @@ def test_execution_tracking_fodf_custom_seeds(script_runner, monkeypatch): custom_seeds = [[1., 1., 1.], [2., 2., 2.], [3., 3., 3.]] np.save(in_custom_seeds, custom_seeds) - ret = script_runner.run('scil_tracking_local_dev.py', in_fodf, - in_mask, in_mask, 'local_prob2.trk', - '--in_custom_seeds', in_custom_seeds, - '--compress', '0.1', '--sh_basis', 'descoteaux07', - '--min_length', '20', '--max_length', '200', - '--save_seeds', '--rng_seed', '0', - '--sub_sphere', '2', - '--rk_order', '4') + ret = script_runner.run(['scil_tracking_local_dev', in_fodf, + in_mask, in_mask, 'local_prob2.trk', + '--in_custom_seeds', in_custom_seeds, + '--compress', '0.1', '--sh_basis', 'descoteaux07', + '--min_length', '20', '--max_length', '200', + '--save_seeds', '--rng_seed', '0', + '--sub_sphere', '2', + '--rk_order', '4']) assert ret.success diff --git a/scripts/tests/test_tracking_pft.py b/src/scilpy/cli/tests/test_tracking_pft.py similarity index 67% rename from scripts/tests/test_tracking_pft.py rename to src/scilpy/cli/tests/test_tracking_pft.py index 08529e281..f7af92d18 100644 --- a/scripts/tests/test_tracking_pft.py +++ b/src/scilpy/cli/tests/test_tracking_pft.py @@ -13,8 +13,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tracking_pft.py', - '--help') + ret = script_runner.run(['scil_tracking_pft', + '--help']) assert ret.success @@ -28,9 +28,10 @@ def test_execution_tracking(script_runner, monkeypatch): 'map_include.nii.gz') in_exclude = os.path.join(SCILPY_HOME, 'tracking', 'map_exclude.nii.gz') - ret = script_runner.run('scil_tracking_pft.py', in_fodf, - in_interface, in_include, in_exclude, - 'pft.trk', '--nt', '1000', '--compress', '0.1', - '--sh_basis', 'descoteaux07', '--min_length', '20', - '--max_length', '200') + ret = script_runner.run(['scil_tracking_pft', in_fodf, + in_interface, in_include, in_exclude, + 'pft.trk', '--nt', '1000', '--compress', '0.1', + '--sh_basis', 'descoteaux07', + '--min_length', '20', + '--max_length', '200']) assert ret.success diff --git a/scripts/tests/test_tracking_pft_maps.py b/src/scilpy/cli/tests/test_tracking_pft_maps.py similarity index 80% rename from scripts/tests/test_tracking_pft_maps.py rename to src/scilpy/cli/tests/test_tracking_pft_maps.py index a21ad0d5d..2acd74a53 100644 --- a/scripts/tests/test_tracking_pft_maps.py +++ b/src/scilpy/cli/tests/test_tracking_pft_maps.py @@ -13,8 +13,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tracking_pft_maps.py', - '--help') + ret = script_runner.run(['scil_tracking_pft_maps', + '--help']) assert ret.success @@ -26,6 +26,6 @@ def test_execution_tracking(script_runner, monkeypatch): 'map_gm.nii.gz') in_csf = os.path.join(SCILPY_HOME, 'tracking', 'map_csf.nii.gz') - ret = script_runner.run('scil_tracking_pft_maps.py', - in_wm, in_gm, in_csf) + ret = script_runner.run(['scil_tracking_pft_maps', + in_wm, in_gm, in_csf]) assert ret.success diff --git a/scripts/tests/test_tracking_pft_maps_edit.py b/src/scilpy/cli/tests/test_tracking_pft_maps_edit.py similarity index 73% rename from scripts/tests/test_tracking_pft_maps_edit.py rename to src/scilpy/cli/tests/test_tracking_pft_maps_edit.py index b08fe6bac..eebb0f681 100644 --- a/scripts/tests/test_tracking_pft_maps_edit.py +++ b/src/scilpy/cli/tests/test_tracking_pft_maps_edit.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tracking_pft_maps_edit.py', '--help') + ret = script_runner.run(['scil_tracking_pft_maps_edit', '--help']) assert ret.success @@ -25,8 +25,8 @@ def test_execution_tracking(script_runner, monkeypatch): 'map_exclude.nii.gz') in_mask = os.path.join(SCILPY_HOME, 'tracking', 'seeding_mask.nii.gz') - ret = script_runner.run('scil_tracking_pft_maps_edit.py', - in_include, in_exclude, in_mask, - 'map_include_corr.nii.gz', - 'map_exclude_corr.nii.gz') + ret = script_runner.run(['scil_tracking_pft_maps_edit', + in_include, in_exclude, in_mask, + 'map_include_corr.nii.gz', + 'map_exclude_corr.nii.gz']) assert ret.success diff --git a/scripts/tests/test_tractogram_apply_transform.py b/src/scilpy/cli/tests/test_tractogram_apply_transform.py similarity index 71% rename from scripts/tests/test_tractogram_apply_transform.py rename to src/scilpy/cli/tests/test_tractogram_apply_transform.py index 475db0441..03850c8f7 100644 --- a/scripts/tests/test_tractogram_apply_transform.py +++ b/src/scilpy/cli/tests/test_tractogram_apply_transform.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_apply_transform.py', '--help') + ret = script_runner.run(['scil_tractogram_apply_transform', '--help']) assert ret.success @@ -24,8 +24,8 @@ def test_execution_inverse(script_runner, monkeypatch): in_aff = os.path.join(SCILPY_HOME, 'bst', 'output0GenericAffine.mat') in_warp = os.path.join(SCILPY_HOME, 'bst', 'output1InverseWarp.nii.gz') - ret = script_runner.run('scil_tractogram_apply_transform.py', - in_model, in_fa, in_aff, 'rpt_m_warp.trk', - '--inverse', '--in_deformation', in_warp, - '--cut') + ret = script_runner.run(['scil_tractogram_apply_transform', + in_model, in_fa, in_aff, 'rpt_m_warp.trk', + '--inverse', '--in_deformation', in_warp, + '--cut']) assert ret.success diff --git a/scripts/tests/test_tractogram_apply_transform_to_hdf5.py b/src/scilpy/cli/tests/test_tractogram_apply_transform_to_hdf5.py similarity index 78% rename from scripts/tests/test_tractogram_apply_transform_to_hdf5.py rename to src/scilpy/cli/tests/test_tractogram_apply_transform_to_hdf5.py index a51d7fc1c..a03cf8305 100644 --- a/scripts/tests/test_tractogram_apply_transform_to_hdf5.py +++ b/src/scilpy/cli/tests/test_tractogram_apply_transform_to_hdf5.py @@ -13,8 +13,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_apply_transform_to_hdf5.py', - '--help') + ret = script_runner.run(['scil_tractogram_apply_transform_to_hdf5', + '--help']) assert ret.success @@ -28,6 +28,6 @@ def test_execution_connectivity(script_runner, monkeypatch): # toDo. Add a --in_deformation file in our test data, fitting with hdf5. # (See test_tractogram_apply_transform) # toDo. Add some dps in the hdf5's data for more line coverage. - ret = script_runner.run('scil_tractogram_apply_transform_to_hdf5.py', - in_h5, in_target, in_transfo, 'decompose_lin.h5') + ret = script_runner.run(['scil_tractogram_apply_transform_to_hdf5', + in_h5, in_target, in_transfo, 'decompose_lin.h5']) assert ret.success diff --git a/scripts/tests/test_tractogram_assign_custom_color.py b/src/scilpy/cli/tests/test_tractogram_assign_custom_color.py similarity index 54% rename from scripts/tests/test_tractogram_assign_custom_color.py rename to src/scilpy/cli/tests/test_tractogram_assign_custom_color.py index 10c5887fe..66cdb82f4 100644 --- a/scripts/tests/test_tractogram_assign_custom_color.py +++ b/src/scilpy/cli/tests/test_tractogram_assign_custom_color.py @@ -18,8 +18,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_assign_custom_color.py', - '--help') + ret = script_runner.run(['scil_tractogram_assign_custom_color', + '--help']) assert ret.success @@ -28,23 +28,32 @@ def test_execution_from_anat(script_runner, monkeypatch): in_anat = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM_labels_map.nii.gz') - ret = script_runner.run('scil_tractogram_assign_custom_color.py', - in_bundle, 'colored.trk', '--from_anatomy', - in_anat, '--out_colorbar', 'test_colorbar.png') + ret = script_runner.run(['scil_tractogram_assign_custom_color', + in_bundle, 'colored.trk', '--from_anatomy', + in_anat, '--out_colorbar', 'test_colorbar.png']) assert ret.success def test_execution_along_profile(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_tractogram_assign_custom_color.py', - in_bundle, 'colored2.trk', '--along_profile') + ret = script_runner.run(['scil_tractogram_assign_custom_color', + in_bundle, 'colored2.trk', '--along_profile']) assert ret.success def test_execution_from_angle(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_tractogram_assign_custom_color.py', - in_bundle, 'colored3.trk', '--local_angle') + ret = script_runner.run(['scil_tractogram_assign_custom_color', + in_bundle, 'colored3.trk', '--local_angle']) + assert ret.success + + +def test_execution_ambiant_occlusion(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + ret = script_runner.run(['scil_tractogram_assign_custom_color', + in_bundle, 'colored4.trk', '--local_orientation', + '--ambiant_occlusion']) assert ret.success diff --git a/scripts/tests/test_tractogram_assign_uniform_color.py b/src/scilpy/cli/tests/test_tractogram_assign_uniform_color.py similarity index 64% rename from scripts/tests/test_tractogram_assign_uniform_color.py rename to src/scilpy/cli/tests/test_tractogram_assign_uniform_color.py index d22d951cd..7ffb2dcc5 100644 --- a/scripts/tests/test_tractogram_assign_uniform_color.py +++ b/src/scilpy/cli/tests/test_tractogram_assign_uniform_color.py @@ -16,17 +16,17 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_assign_uniform_color.py', - '--help') + ret = script_runner.run(['scil_tractogram_assign_uniform_color', + '--help']) assert ret.success def test_execution_fill(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_tractogram_assign_uniform_color.py', - in_bundle, '--fill_color', '0x000000', - '--out_tractogram', 'colored.trk', '-f') + ret = script_runner.run(['scil_tractogram_assign_uniform_color', + in_bundle, '--fill_color', '0x000000', + '--out_tractogram', 'colored.trk', '-f']) assert ret.success @@ -39,11 +39,12 @@ def test_execution_dict(script_runner, monkeypatch): with open(json_file, "w+") as f: json.dump(my_dict, f) - ret = script_runner.run('scil_tractogram_assign_uniform_color.py', - in_bundle, '--dict_colors', json_file, - '--out_suffix', 'colored', '-f') + ret = script_runner.run(['scil_tractogram_assign_uniform_color', + in_bundle, '--dict_colors', json_file, + '--out_suffix', 'colored', '-f']) assert ret.success + def test_execution_dict_new_color(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) @@ -54,8 +55,8 @@ def test_execution_dict_new_color(script_runner, monkeypatch): json.dump(my_dict, f) shutil.copy2(in_bundle, 'dummy.trk') - ret = script_runner.run('scil_tractogram_assign_uniform_color.py', - in_bundle, "dummy.trk", - '--dict_colors', json_file, - '--out_suffix', 'colored', '-f') + ret = script_runner.run(['scil_tractogram_assign_uniform_color', + in_bundle, "dummy.trk", + '--dict_colors', json_file, + '--out_suffix', 'colored', '-f']) assert ret.success diff --git a/scripts/tests/test_tractogram_commit.py b/src/scilpy/cli/tests/test_tractogram_commit.py similarity index 82% rename from scripts/tests/test_tractogram_commit.py rename to src/scilpy/cli/tests/test_tractogram_commit.py index ca67913e9..6cd2e626b 100644 --- a/scripts/tests/test_tractogram_commit.py +++ b/src/scilpy/cli/tests/test_tractogram_commit.py @@ -20,7 +20,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_commit.py', '--help') + ret = script_runner.run(['scil_tractogram_commit', '--help']) assert ret.success @@ -28,14 +28,14 @@ def test_execution_commit_amico(script_runner, monkeypatch): tmp_dir = tempfile.TemporaryDirectory() monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run( - 'scil_tractogram_commit.py', in_tracking, in_dwi, in_bval, in_bvec, + ret = script_runner.run([ + 'scil_tractogram_commit', in_tracking, in_dwi, in_bval, in_bvec, 'results_bzs/', '--tol', '30', '--nbr_dir', '500', '--nbr_iter', '500', '--in_peaks', in_peaks, '--in_tracking_mask', in_mask, '--perp_diff', '1.19E-3', '0.85E-3', '0.51E-3', '0.17E-3', '--iso_diff', '1.7E-3', '3.0E-3', - '--processes', '1', '--keep_whole_tractogram') + '--processes', '1', '--keep_whole_tractogram']) assert ret.success @@ -44,12 +44,12 @@ def test_execution_commit2(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) # TODO Add a HDF5 in our test data that could be used here. - ret = script_runner.run( - 'scil_tractogram_commit.py', in_tracking, in_dwi, in_bval, in_bvec, + ret = script_runner.run([ + 'scil_tractogram_commit', in_tracking, in_dwi, in_bval, in_bvec, 'results_bzs/', '--tol', '30', '--nbr_dir', '500', '--nbr_iter', '500', '--in_peaks', in_peaks, '--in_tracking_mask', in_mask, '--perp_diff', '1.19E-3', '0.85E-3', '0.51E-3', '0.17E-3', '--iso_diff', '1.7E-3', '3.0E-3', - '--processes', '1', '--commit2') + '--processes', '1', '--commit2']) assert not ret.success diff --git a/scripts/tests/test_tractogram_compress.py b/src/scilpy/cli/tests/test_tractogram_compress.py similarity index 76% rename from scripts/tests/test_tractogram_compress.py rename to src/scilpy/cli/tests/test_tractogram_compress.py index 67d935a90..7e9762f83 100644 --- a/scripts/tests/test_tractogram_compress.py +++ b/src/scilpy/cli/tests/test_tractogram_compress.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_compress.py', '--help') + ret = script_runner.run(['scil_tractogram_compress', '--help']) assert ret.success @@ -21,6 +21,6 @@ def test_execution_surface_vtk_fib(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_fib = os.path.join(SCILPY_HOME, 'surface_vtk_fib', 'gyri_fanning.trk') - ret = script_runner.run('scil_tractogram_compress.py', in_fib, - 'gyri_fanning_c.trk', '-e', '0.1') + ret = script_runner.run(['scil_tractogram_compress', in_fib, + 'gyri_fanning_c.trk', '-e', '0.1']) assert ret.success diff --git a/scripts/tests/test_tractogram_compute_TODI.py b/src/scilpy/cli/tests/test_tractogram_compute_TODI.py similarity index 51% rename from scripts/tests/test_tractogram_compute_TODI.py rename to src/scilpy/cli/tests/test_tractogram_compute_TODI.py index f95ed1e92..6d29f1569 100644 --- a/scripts/tests/test_tractogram_compute_TODI.py +++ b/src/scilpy/cli/tests/test_tractogram_compute_TODI.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_compute_TODI.py', '--help') + ret = script_runner.run(['scil_tractogram_compute_TODI', '--help']) assert ret.success @@ -22,23 +22,22 @@ def test_execution_bst(script_runner, monkeypatch): in_bundle = os.path.join(SCILPY_HOME, 'bst', 'rpt_m_warp.trk') in_mask = os.path.join(SCILPY_HOME, 'bst', 'mask.nii.gz') - ret = script_runner.run('scil_tractogram_compute_TODI.py', in_bundle, - '--mask', in_mask, - '--out_mask', 'todi_mask.nii.gz', - '--out_tdi', 'tdi.nii.gz', - '--out_todi_sh', 'todi_sh.nii.gz', - '--out_todi_sf', 'todi_sf.nii.gz', - '--sh_order', '6', - '--normalize_per_voxel', '--smooth_todi', - '--sh_basis', 'descoteaux07') + ret = script_runner.run(['scil_tractogram_compute_TODI', in_bundle, + '--mask', in_mask, + '--out_mask', 'todi_mask.nii.gz', + '--out_tdi', 'tdi.nii.gz', + '--out_todi_sh', 'todi_sh.nii.gz', + '--out_todi_sf', 'todi_sf.nii.gz', + '--sh_order', '6', + '--normalize_per_voxel', '--smooth_todi', + '--sh_basis', 'descoteaux07']) assert ret.success def test_execution_asym(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'bst', 'rpt_m_warp.trk') - ret = script_runner.run('scil_tractogram_compute_TODI.py', in_bundle, - '--out_todi_sh', 'atodi_sh_8.nii.gz', - '--asymmetric', '--n_steps', '2') - + ret = script_runner.run(['scil_tractogram_compute_TODI', in_bundle, + '--out_todi_sh', 'atodi_sh_8.nii.gz', + '--asymmetric', '--n_steps', '2']) assert ret.success diff --git a/scripts/tests/test_tractogram_compute_density_map.py b/src/scilpy/cli/tests/test_tractogram_compute_density_map.py similarity index 67% rename from scripts/tests/test_tractogram_compute_density_map.py rename to src/scilpy/cli/tests/test_tractogram_compute_density_map.py index 81cd495fe..91cf5c57c 100644 --- a/scripts/tests/test_tractogram_compute_density_map.py +++ b/src/scilpy/cli/tests/test_tractogram_compute_density_map.py @@ -13,22 +13,22 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_compute_density_map.py', - '--help') + ret = script_runner.run(['scil_tractogram_compute_density_map', + '--help']) assert ret.success def test_execution_others(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'others', 'IFGWM.trk') - ret = script_runner.run('scil_tractogram_compute_density_map.py', - in_bundle, 'binary.nii.gz', '--endpoints_only') + ret = script_runner.run(['scil_tractogram_compute_density_map', + in_bundle, 'binary.nii.gz', '--endpoints_only']) assert ret.success def test_execution_tractometry(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM.trk') - ret = script_runner.run('scil_tractogram_compute_density_map.py', - in_bundle, 'IFGWM.nii.gz', '--binary') + ret = script_runner.run(['scil_tractogram_compute_density_map', + in_bundle, 'IFGWM.nii.gz', '--binary']) assert ret.success diff --git a/scripts/tests/test_tractogram_convert.py b/src/scilpy/cli/tests/test_tractogram_convert.py similarity index 85% rename from scripts/tests/test_tractogram_convert.py rename to src/scilpy/cli/tests/test_tractogram_convert.py index 6354f15fc..6805bc535 100644 --- a/scripts/tests/test_tractogram_convert.py +++ b/src/scilpy/cli/tests/test_tractogram_convert.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_convert.py', '--help') + ret = script_runner.run(['scil_tractogram_convert', '--help']) assert ret.success @@ -23,6 +23,6 @@ def test_execution_surface_vtk_fib(script_runner, monkeypatch): 'gyri_fanning.fib') in_fa = os.path.join(SCILPY_HOME, 'surface_vtk_fib', 'fa.nii.gz') - ret = script_runner.run('scil_tractogram_convert.py', in_fib, - 'gyri_fanning.trk', '--reference', in_fa) + ret = script_runner.run(['scil_tractogram_convert', in_fib, + 'gyri_fanning.trk', '--reference', in_fa]) assert ret.success diff --git a/scripts/tests/test_tractogram_convert_hdf5_to_trk.py b/src/scilpy/cli/tests/test_tractogram_convert_hdf5_to_trk.py similarity index 68% rename from scripts/tests/test_tractogram_convert_hdf5_to_trk.py rename to src/scilpy/cli/tests/test_tractogram_convert_hdf5_to_trk.py index 720eaad1e..5bff8b8fd 100644 --- a/scripts/tests/test_tractogram_convert_hdf5_to_trk.py +++ b/src/scilpy/cli/tests/test_tractogram_convert_hdf5_to_trk.py @@ -14,14 +14,14 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_convert_hdf5_to_trk.py', '--help') + ret = script_runner.run(['scil_tractogram_convert_hdf5_to_trk', '--help']) assert ret.success def test_execution_all_keys(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_tractogram_convert_hdf5_to_trk.py', - in_h5, 'save_trk/') + ret = script_runner.run(['scil_tractogram_convert_hdf5_to_trk', + in_h5, 'save_trk/']) assert ret.success # With current test data, out directory should have 7 files @@ -31,8 +31,9 @@ def test_execution_all_keys(script_runner, monkeypatch): def test_execution_edge_keys(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_tractogram_convert_hdf5_to_trk.py', - in_h5, 'save_trk2/', '--edge_keys', '1_10', '1_7') + ret = script_runner.run(['scil_tractogram_convert_hdf5_to_trk', + in_h5, 'save_trk2/', + '--edge_keys', '1_10', '1_7']) assert ret.success # Out directory should have 2 files @@ -42,8 +43,8 @@ def test_execution_edge_keys(script_runner, monkeypatch): def test_execution_node_keys(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_tractogram_convert_hdf5_to_trk.py', - in_h5, 'save_trk3/', '--node_keys', '7') + ret = script_runner.run(['scil_tractogram_convert_hdf5_to_trk', + in_h5, 'save_trk3/', '--node_keys', '7']) assert ret.success # With current test data, out directory should have 3 files @@ -58,11 +59,11 @@ def test_execution_save_empty(script_runner, monkeypatch): # connections. with open('labels_list.txt', 'w') as f: f.write('1\n10\n100') - ret = script_runner.run('scil_tractogram_convert_hdf5_to_trk.py', - in_h5, 'save_trk4/', - '--save_empty', 'labels_list.txt', - '--edge_keys', '1_10', '1_100', - '-v', 'DEBUG') + ret = script_runner.run(['scil_tractogram_convert_hdf5_to_trk', + in_h5, 'save_trk4/', + '--save_empty', 'labels_list.txt', + '--edge_keys', '1_10', '1_100', + '-v', 'DEBUG']) assert ret.success # Out directory should have 2 files diff --git a/scripts/tests/test_tractogram_convert_trk_to_hdf5.py b/src/scilpy/cli/tests/test_tractogram_convert_trk_to_hdf5.py similarity index 72% rename from scripts/tests/test_tractogram_convert_trk_to_hdf5.py rename to src/scilpy/cli/tests/test_tractogram_convert_trk_to_hdf5.py index fd564f939..f0ecaa9d6 100644 --- a/scripts/tests/test_tractogram_convert_trk_to_hdf5.py +++ b/src/scilpy/cli/tests/test_tractogram_convert_trk_to_hdf5.py @@ -18,25 +18,25 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_convert_trk_to_hdf5.py', '--help') + ret = script_runner.run(['scil_tractogram_convert_trk_to_hdf5', '--help']) assert ret.success def test_execution_edge_keys(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_tractogram_convert_hdf5_to_trk.py', - in_h5, 'save_trk/', '--edge_keys', '1_10', '1_7') + ret = script_runner.run(['scil_tractogram_convert_hdf5_to_trk', + in_h5, 'save_trk/', '--edge_keys', '1_10', '1_7']) assert ret.success # Out directory should have 2 files out_files = glob.glob('save_trk/*') assert len(out_files) == 2 - ret = script_runner.run('scil_tractogram_convert_trk_to_hdf5.py', - 'save_trk/1_10.trk', 'save_trk/1_7.trk', - 'two_edges.h5', - '--stored_space', 'voxmm', - '--stored_origin', 'nifti') + ret = script_runner.run(['scil_tractogram_convert_trk_to_hdf5', + 'save_trk/1_10.trk', 'save_trk/1_7.trk', + 'two_edges.h5', + '--stored_space', 'voxmm', + '--stored_origin', 'nifti']) assert ret.success with h5py.File('two_edges.h5', 'r') as hdf5_file: diff --git a/scripts/tests/test_tractogram_count_streamlines.py b/src/scilpy/cli/tests/test_tractogram_count_streamlines.py similarity index 80% rename from scripts/tests/test_tractogram_count_streamlines.py rename to src/scilpy/cli/tests/test_tractogram_count_streamlines.py index 7b2e4aa47..65e34c204 100644 --- a/scripts/tests/test_tractogram_count_streamlines.py +++ b/src/scilpy/cli/tests/test_tractogram_count_streamlines.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_count_streamlines.py', '--help') + ret = script_runner.run(['scil_tractogram_count_streamlines', '--help']) assert ret.success @@ -21,5 +21,5 @@ def test_execution_others(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'others', 'IFGWM_sub.trk') - ret = script_runner.run('scil_tractogram_count_streamlines.py', in_bundle) + ret = script_runner.run(['scil_tractogram_count_streamlines', in_bundle]) assert ret.success diff --git a/scripts/tests/test_tractogram_cut_streamlines.py b/src/scilpy/cli/tests/test_tractogram_cut_streamlines.py similarity index 56% rename from scripts/tests/test_tractogram_cut_streamlines.py rename to src/scilpy/cli/tests/test_tractogram_cut_streamlines.py index 91267c8ef..9e447053b 100644 --- a/scripts/tests/test_tractogram_cut_streamlines.py +++ b/src/scilpy/cli/tests/test_tractogram_cut_streamlines.py @@ -14,8 +14,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_cut_streamlines.py', - '--help') + ret = script_runner.run(['scil_tractogram_cut_streamlines', + '--help']) assert ret.success @@ -24,11 +24,11 @@ def test_execution(script_runner, monkeypatch): in_tractogram = os.path.join(SCILPY_HOME, 'filtering', 'bundle_all_1mm.trk') in_mask = os.path.join(SCILPY_HOME, 'filtering', 'mask.nii.gz') - ret = script_runner.run('scil_tractogram_cut_streamlines.py', - in_tractogram, 'out_tractogram_cut.trk', - '--mask', in_mask, '--min_length', '0', '-f', - '--reference', in_mask, - '--resample', '0.2', '--compress', '0.1') + ret = script_runner.run(['scil_tractogram_cut_streamlines', + in_tractogram, 'out_tractogram_cut.trk', + '--mask', in_mask, '--min_length', '0', '-f', + '--reference', in_mask, + '--resample', '0.2', '--compress', '0.1']) assert ret.success @@ -40,12 +40,12 @@ def test_execution_two_rois(script_runner, monkeypatch): in_mask = os.path.join(SCILPY_HOME, 'tractograms', 'streamline_and_mask_operations', 'bundle_4_head_tail_offset.nii.gz') - ret = script_runner.run('scil_tractogram_cut_streamlines.py', - in_tractogram, '--mask', in_mask, - 'out_tractogram_cut.trk', '-f', - '--mask', in_mask, '--min_length', '0', - '--reference', in_mask, - '--resample', '0.2', '--compress', '0.1') + ret = script_runner.run(['scil_tractogram_cut_streamlines', + in_tractogram, '--mask', in_mask, + 'out_tractogram_cut.trk', '-f', + '--mask', in_mask, '--min_length', '0', + '--reference', in_mask, + '--resample', '0.2', '--compress', '0.1']) assert ret.success @@ -57,13 +57,13 @@ def test_execution_keep_longest(script_runner, monkeypatch): in_mask = os.path.join(SCILPY_HOME, 'tractograms', 'streamline_and_mask_operations', 'bundle_4_head_tail_offset.nii.gz') - ret = script_runner.run('scil_tractogram_cut_streamlines.py', - in_tractogram, '--mask', in_mask, - 'out_tractogram_cut.trk', '-f', - '--keep_longest', '--mask', in_mask, - '--min_length', '0', '--resample', '0.2', - '--reference', in_mask, - '--compress', '0.1') + ret = script_runner.run(['scil_tractogram_cut_streamlines', + in_tractogram, '--mask', in_mask, + 'out_tractogram_cut.trk', '-f', + '--keep_longest', '--mask', in_mask, + '--min_length', '0', '--resample', '0.2', + '--reference', in_mask, + '--compress', '0.1']) assert ret.success @@ -75,13 +75,13 @@ def test_execution_trim_endpoints(script_runner, monkeypatch): in_mask = os.path.join(SCILPY_HOME, 'tractograms', 'streamline_and_mask_operations', 'bundle_4_head_tail_offset.nii.gz') - ret = script_runner.run('scil_tractogram_cut_streamlines.py', - in_tractogram, '--mask', in_mask, - 'out_tractogram_cut.trk', '-f', - '--trim_endpoints', '--mask', in_mask, - '--min_length', '0', '--resample', '0.2', - '--reference', in_mask, - '--compress', '0.1') + ret = script_runner.run(['scil_tractogram_cut_streamlines', + in_tractogram, '--mask', in_mask, + 'out_tractogram_cut.trk', '-f', + '--trim_endpoints', '--mask', in_mask, + '--min_length', '0', '--resample', '0.2', + '--reference', in_mask, + '--compress', '0.1']) assert ret.success @@ -91,11 +91,11 @@ def test_execution_labels(script_runner, monkeypatch): 'bundle_all_1mm.trk') in_labels = os.path.join(SCILPY_HOME, 'connectivity', 'endpoints_atlas.nii.gz') - ret = script_runner.run('scil_tractogram_cut_streamlines.py', - in_tractogram, '--labels', in_labels, - 'out_tractogram_cut.trk', '-f', - '--label_ids', '1', '10', - '--resample', '0.2', '--compress', '0.1') + ret = script_runner.run(['scil_tractogram_cut_streamlines', + in_tractogram, '--labels', in_labels, + 'out_tractogram_cut.trk', '-f', + '--label_ids', '1', '10', + '--resample', '0.2', '--compress', '0.1']) assert ret.success @@ -105,12 +105,12 @@ def test_execution_labels_error_trim(script_runner, monkeypatch): 'bundle_all_1mm.trk') in_labels = os.path.join(SCILPY_HOME, 'connectivity', 'endpoints_atlas.nii.gz') - ret = script_runner.run('scil_tractogram_cut_streamlines.py', - in_tractogram, '--labels', in_labels, - 'out_tractogram_cut2.trk', '-f', - '--label_ids', '1', '10', - '--resample', '0.2', '--compress', '0.1' - '--trim_endpoints') + ret = script_runner.run(['scil_tractogram_cut_streamlines', + in_tractogram, '--labels', in_labels, + 'out_tractogram_cut2.trk', '-f', + '--label_ids', '1', '10', + '--resample', '0.2', '--compress', '0.1' + '--trim_endpoints']) assert not ret.success @@ -120,10 +120,10 @@ def test_execution_labels_no_point(script_runner, monkeypatch): 'bundle_all_1mm.trk') in_labels = os.path.join(SCILPY_HOME, 'connectivity', 'endpoints_atlas.nii.gz') - ret = script_runner.run('scil_tractogram_cut_streamlines.py', - in_tractogram, '--labels', in_labels, - 'out_tractogram_cut.trk', '-f', - '--no_point_in_roi', '--label_ids', '1', '10') + ret = script_runner.run(['scil_tractogram_cut_streamlines', + in_tractogram, '--labels', in_labels, + 'out_tractogram_cut.trk', '-f', + '--no_point_in_roi', '--label_ids', '1', '10']) assert ret.success @@ -133,8 +133,8 @@ def test_execution_labels_one_point(script_runner, monkeypatch): 'bundle_all_1mm.trk') in_labels = os.path.join(SCILPY_HOME, 'connectivity', 'endpoints_atlas.nii.gz') - ret = script_runner.run('scil_tractogram_cut_streamlines.py', - in_tractogram, '--labels', in_labels, - 'out_tractogram_cut.trk', '-f', - '--one_point_in_roi', '--label_ids', '1', '10') + ret = script_runner.run(['scil_tractogram_cut_streamlines', + in_tractogram, '--labels', in_labels, + 'out_tractogram_cut.trk', '-f', + '--one_point_in_roi', '--label_ids', '1', '10']) assert ret.success diff --git a/scripts/tests/test_tractogram_detect_loops.py b/src/scilpy/cli/tests/test_tractogram_detect_loops.py similarity index 59% rename from scripts/tests/test_tractogram_detect_loops.py rename to src/scilpy/cli/tests/test_tractogram_detect_loops.py index 73bc88209..b4941ba9e 100644 --- a/scripts/tests/test_tractogram_detect_loops.py +++ b/src/scilpy/cli/tests/test_tractogram_detect_loops.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_detect_loops.py', '--help') + ret = script_runner.run(['scil_tractogram_detect_loops', '--help']) assert ret.success @@ -21,10 +21,10 @@ def test_execution_filtering(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'filtering', 'bundle_4_filtered.trk') - ret = script_runner.run('scil_tractogram_detect_loops.py', - in_bundle, 'bundle_4_filtered_no_loops.trk', - '--looping_tractogram', - 'bundle_4_filtered_loops.trk', - '--angle', '270', '--qb', '4', - '--processes', '1', '--display_counts') + ret = script_runner.run(['scil_tractogram_detect_loops', + in_bundle, 'bundle_4_filtered_no_loops.trk', + '--looping_tractogram', + 'bundle_4_filtered_loops.trk', + '--angle', '270', '--qb', '4', + '--processes', '1', '--display_counts']) assert ret.success diff --git a/scripts/tests/test_tractogram_dpp_math.py b/src/scilpy/cli/tests/test_tractogram_dpp_math.py similarity index 52% rename from scripts/tests/test_tractogram_dpp_math.py rename to src/scilpy/cli/tests/test_tractogram_dpp_math.py index 0471961ed..8f0a98000 100644 --- a/scripts/tests/test_tractogram_dpp_math.py +++ b/src/scilpy/cli/tests/test_tractogram_dpp_math.py @@ -14,7 +14,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_dpp_math.py', '--help') + ret = script_runner.run(['scil_tractogram_dpp_math', '--help']) assert ret.success @@ -26,25 +26,24 @@ def test_execution_tractogram_point_math_mean_3D_defaults(script_runner, t1_on_bundle = 't1_on_streamlines.trk' # Create some dpp. Could have test data with dpp instead. - script_runner.run('scil_tractogram_project_map_to_streamlines.py', + script_runner.run(['scil_tractogram_project_map_to_streamlines', in_bundle, t1_on_bundle, '--in_maps', in_t1, - '--out_dpp_name', 't1') + '--out_dpp_name', 't1']) # Test dps mode - ret = script_runner.run('scil_tractogram_dpp_math.py', - 'mean', t1_on_bundle, 't1_mean_on_streamlines.trk', - '--mode', 'dps', '--in_dpp_name', 't1', - '--out_keys', 't1_mean') - + ret = script_runner.run(['scil_tractogram_dpp_math', + 'mean', t1_on_bundle, + 't1_mean_on_streamlines.trk', + '--mode', 'dps', '--in_dpp_name', 't1', + '--out_keys', 't1_mean']) assert ret.success # Test dpp mode - ret = script_runner.run('scil_tractogram_dpp_math.py', - 'mean', t1_on_bundle, - 't1_mean_on_streamlines2.trk', - '--mode', 'dpp', '--in_dpp_name', 't1', - '--out_keys', 't1_mean') - + ret = script_runner.run(['scil_tractogram_dpp_math', + 'mean', t1_on_bundle, + 't1_mean_on_streamlines2.trk', + '--mode', 'dpp', '--in_dpp_name', 't1', + '--out_keys', 't1_mean']) assert ret.success @@ -55,16 +54,15 @@ def test_execution_tractogram_point_math_mean_4D_correlation(script_runner, in_fodf = os.path.join(SCILPY_HOME, 'tracking', 'fodf.nii.gz') fodf_on_bundle = 'fodf_on_streamlines.trk' - script_runner.run('scil_tractogram_project_map_to_streamlines.py', - in_bundle, fodf_on_bundle, - '--in_maps', in_fodf, in_fodf, - '--out_dpp_name', 'fodf', 'fodf2') - - ret = script_runner.run('scil_tractogram_dpp_math.py', - 'correlation', fodf_on_bundle, - 'fodf_correlation_on_streamlines.trk', - '--mode', 'dps', '--endpoints_only', - '--in_dpp_name', 'fodf', - '--out_keys', 'fodf_correlation') - + script_runner.run(['scil_tractogram_project_map_to_streamlines', + in_bundle, fodf_on_bundle, + '--in_maps', in_fodf, in_fodf, + '--out_dpp_name', 'fodf', 'fodf2']) + + ret = script_runner.run(['scil_tractogram_dpp_math', + 'correlation', fodf_on_bundle, + 'fodf_correlation_on_streamlines.trk', + '--mode', 'dps', '--endpoints_only', + '--in_dpp_name', 'fodf', + '--out_keys', 'fodf_correlation']) assert ret.success diff --git a/scripts/tests/test_tractogram_dps_math.py b/src/scilpy/cli/tests/test_tractogram_dps_math.py similarity index 60% rename from scripts/tests/test_tractogram_dps_math.py rename to src/scilpy/cli/tests/test_tractogram_dps_math.py index 8a133633e..397ef6417 100644 --- a/scripts/tests/test_tractogram_dps_math.py +++ b/src/scilpy/cli/tests/test_tractogram_dps_math.py @@ -16,8 +16,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_dps_math.py', - '--help') + ret = script_runner.run(['scil_tractogram_dps_math', + '--help']) assert ret.success @@ -29,11 +29,11 @@ def test_execution_dps_math_import(script_runner, monkeypatch): filename = 'vals.npy' outname = 'out.trk' np.save(filename, np.arange(len(sft))) - ret = script_runner.run('scil_tractogram_dps_math.py', - in_bundle, 'import', 'key', - '--in_dps_file', filename, - '--out_tractogram', outname, - '-f') + ret = script_runner.run(['scil_tractogram_dps_math', + in_bundle, 'import', 'key', + '--in_dps_file', filename, + '--out_tractogram', outname, + '-f']) assert ret.success @@ -43,11 +43,11 @@ def test_execution_dps_math_import_single_value(script_runner, in_bundle = os.path.join(SCILPY_HOME, 'filtering', 'bundle_4.trk') outname = 'out.trk' - ret = script_runner.run('scil_tractogram_dps_math.py', - in_bundle, 'import', 'key', - '--in_dps_single_value', '42', - '--out_tractogram', outname, - '-f') + ret = script_runner.run(['scil_tractogram_dps_math', + in_bundle, 'import', 'key', + '--in_dps_single_value', '42', + '--out_tractogram', outname, + '-f']) assert ret.success @@ -57,11 +57,11 @@ def test_execution_dps_math_import_single_value_array(script_runner, in_bundle = os.path.join(SCILPY_HOME, 'filtering', 'bundle_4.trk') outname = 'out.trk' - ret = script_runner.run('scil_tractogram_dps_math.py', - in_bundle, 'import', 'key', - '--in_dps_single_value', '1', '1.1', '1.2', - '--out_tractogram', outname, - '-f') + ret = script_runner.run(['scil_tractogram_dps_math', + in_bundle, 'import', 'key', + '--in_dps_single_value', '1', '1.1', '1.2', + '--out_tractogram', outname, + '-f']) assert ret.success @@ -74,11 +74,11 @@ def test_execution_dps_math_import_with_missing_vals(script_runner, filename = 'vals.npy' outname = 'out.trk' np.save(filename, np.arange(len(sft) - 10)) - ret = script_runner.run('scil_tractogram_dps_math.py', - in_bundle, 'import', 'key', - '--in_dps_file', filename, - '--out_tractogram', outname, - '-f') + ret = script_runner.run(['scil_tractogram_dps_math', + in_bundle, 'import', 'key', + '--in_dps_file', filename, + '--out_tractogram', outname, + '-f']) assert ret.stderr @@ -92,16 +92,16 @@ def test_execution_dps_math_import_with_existing_key(script_runner, outname = 'out.trk' outname2 = 'out_2.trk' np.save(filename, np.arange(len(sft))) - ret = script_runner.run('scil_tractogram_dps_math.py', - in_bundle, 'import', 'key', - '--in_dps_file', filename, - '--out_tractogram', outname, - '-f') + ret = script_runner.run(['scil_tractogram_dps_math', + in_bundle, 'import', 'key', + '--in_dps_file', filename, + '--out_tractogram', outname, + '-f']) assert ret.success - ret = script_runner.run('scil_tractogram_dps_math.py', - outname, 'import', 'key', - '--in_dps_file', filename, - '--out_tractogram', outname2,) + ret = script_runner.run(['scil_tractogram_dps_math', + outname, 'import', 'key', + '--in_dps_file', filename, + '--out_tractogram', outname2,]) assert not ret.success @@ -113,11 +113,11 @@ def test_execution_dps_math_tck_output(script_runner, monkeypatch): filename = 'vals.npy' outname = 'out.tck' np.save(filename, np.arange(len(sft))) - ret = script_runner.run('scil_tractogram_dps_math.py', - in_bundle, 'import', 'key', - '--in_dps_file', filename, - '--out_tractogram', outname, - '-f') + ret = script_runner.run(['scil_tractogram_dps_math', + in_bundle, 'import', 'key', + '--in_dps_file', filename, + '--out_tractogram', outname, + '-f']) assert not ret.success @@ -128,14 +128,14 @@ def test_execution_dps_math_delete(script_runner, monkeypatch): in_bundle = 'bundle_4.trk' sft = load_tractogram(in_bundle_no_key, 'same') sft.data_per_streamline = { - "key": [0] * len(sft) + "key": np.zeros(len(sft), dtype=np.float32) } save_tractogram(sft, in_bundle) outname = 'out.trk' - ret = script_runner.run('scil_tractogram_dps_math.py', - in_bundle, 'delete', 'key', - '--out_tractogram', outname, - '-f') + ret = script_runner.run(['scil_tractogram_dps_math', + in_bundle, 'delete', 'key', + '--out_tractogram', outname, + '-f']) assert ret.success @@ -144,10 +144,10 @@ def test_execution_dps_math_delete_no_key(script_runner, monkeypatch): in_bundle = os.path.join(SCILPY_HOME, 'filtering', 'bundle_4.trk') outname = 'out.trk' - ret = script_runner.run('scil_tractogram_dps_math.py', - in_bundle, 'delete', 'key', - '--out_tractogram', outname, - '-f') + ret = script_runner.run(['scil_tractogram_dps_math', + in_bundle, 'delete', 'key', + '--out_tractogram', outname, + '-f']) assert not ret.success @@ -158,14 +158,14 @@ def test_execution_dps_math_export(script_runner, monkeypatch): in_bundle = 'bundle_4.trk' sft = load_tractogram(in_bundle_no_key, 'same') sft.data_per_streamline = { - "key": [0] * len(sft) + "key": np.zeros(len(sft), dtype=np.float32) } save_tractogram(sft, in_bundle) filename = 'out.txt' - ret = script_runner.run('scil_tractogram_dps_math.py', - in_bundle, 'export', 'key', - '--out_dps_file', filename, - '-f') + ret = script_runner.run(['scil_tractogram_dps_math', + in_bundle, 'export', 'key', + '--out_dps_file', filename, + '-f']) assert ret.success @@ -174,8 +174,8 @@ def test_execution_dps_math_export_no_key(script_runner, monkeypatch): in_bundle = os.path.join(SCILPY_HOME, 'filtering', 'bundle_4.trk') filename = 'out.txt' - ret = script_runner.run('scil_tractogram_dps_math.py', - in_bundle, 'export', 'key', - '--out_dps_file', filename, - '-f') + ret = script_runner.run(['scil_tractogram_dps_math', + in_bundle, 'export', 'key', + '--out_dps_file', filename, + '-f']) assert not ret.success diff --git a/scripts/tests/test_tractogram_extract_ushape.py b/src/scilpy/cli/tests/test_tractogram_extract_ushape.py similarity index 61% rename from scripts/tests/test_tractogram_extract_ushape.py rename to src/scilpy/cli/tests/test_tractogram_extract_ushape.py index bbcfed761..3df91d0a3 100644 --- a/scripts/tests/test_tractogram_extract_ushape.py +++ b/src/scilpy/cli/tests/test_tractogram_extract_ushape.py @@ -13,8 +13,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_extract_ushape.py', - '--help') + ret = script_runner.run(['scil_tractogram_extract_ushape', + '--help']) assert ret.success @@ -23,10 +23,10 @@ def test_execution_processing(script_runner, monkeypatch): in_trk = os.path.join(SCILPY_HOME, 'tracking', 'union.trk') out_trk = 'ushape.trk' remaining_trk = 'remaining.trk' - ret = script_runner.run('scil_tractogram_extract_ushape.py', - in_trk, out_trk, - '--minU', '0.5', - '--maxU', '1', - '--remaining_tractogram', remaining_trk, - '--display_counts') + ret = script_runner.run(['scil_tractogram_extract_ushape', + in_trk, out_trk, + '--minU', '0.5', + '--maxU', '1', + '--remaining_tractogram', remaining_trk, + '--display_counts']) assert ret.success diff --git a/src/scilpy/cli/tests/test_tractogram_filter_by_anatomy.py b/src/scilpy/cli/tests/test_tractogram_filter_by_anatomy.py new file mode 100644 index 000000000..f603c54a1 --- /dev/null +++ b/src/scilpy/cli/tests/test_tractogram_filter_by_anatomy.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import os +import tempfile + +from scilpy import SCILPY_HOME +from scilpy.io.fetcher import fetch_data, get_testing_files_dict + +# If they already exist, this only takes 5 seconds (check md5sum) +fetch_data(get_testing_files_dict(), keys=['anatomical_filtering.zip']) +tmp_dir = tempfile.TemporaryDirectory() + + +def test_help_option(script_runner): + ret = script_runner.run(['scil_tractogram_filter_by_anatomy', + '--help']) + assert ret.success + + +def test_execution_filtering_all_options(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + in_tractogram = os.path.join(SCILPY_HOME, 'anatomical_filtering', + 'tractogram_filter_ana.trk') + in_wmparc = os.path.join(SCILPY_HOME, 'anatomical_filtering', + 'wmparc_filter_ana.nii.gz') + ret = script_runner.run(['scil_tractogram_filter_by_anatomy', + in_tractogram, in_wmparc, + os.path.expanduser(tmp_dir.name), + '--minL', '40', '--maxL', '200', '--angle', '300', + '--processes', '1', '--save_volumes', + '--dilate_ctx', '2', + '--save_intermediate_tractograms', + '--save_counts', + '--save_rejected', + '-f']) + assert ret.success + + +def test_execution_filtering_rejected(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + in_tractogram = os.path.join(SCILPY_HOME, 'anatomical_filtering', + 'tractogram_filter_ana.trk') + in_wmparc = os.path.join(SCILPY_HOME, 'anatomical_filtering', + 'wmparc_filter_ana.nii.gz') + ret = script_runner.run(['scil_tractogram_filter_by_anatomy', + in_tractogram, in_wmparc, + os.path.expanduser(tmp_dir.name), + '--minL', '40', '--maxL', '200', '--angle', '300', + '--processes', '1', '--save_volumes', + '--dilate_ctx', '2', + '--save_counts', + '--save_rejected', + '-f']) + assert ret.success + + +def test_execution_filtering_save_intermediate(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + in_tractogram = os.path.join(SCILPY_HOME, 'anatomical_filtering', + 'tractogram_filter_ana.trk') + in_wmparc = os.path.join(SCILPY_HOME, 'anatomical_filtering', + 'wmparc_filter_ana.nii.gz') + ret = script_runner.run(['scil_tractogram_filter_by_anatomy', + in_tractogram, in_wmparc, + os.path.expanduser(tmp_dir.name), + '--minL', '40', '--maxL', '200', '--angle', '300', + '--processes', '1', '--save_volumes', + '--dilate_ctx', '2', + '--save_intermediate_tractograms', + '-f']) + assert ret.success diff --git a/scripts/tests/test_tractogram_filter_by_length.py b/src/scilpy/cli/tests/test_tractogram_filter_by_length.py similarity index 70% rename from scripts/tests/test_tractogram_filter_by_length.py rename to src/scilpy/cli/tests/test_tractogram_filter_by_length.py index d5f4eda7d..5aa3eef11 100644 --- a/scripts/tests/test_tractogram_filter_by_length.py +++ b/src/scilpy/cli/tests/test_tractogram_filter_by_length.py @@ -14,8 +14,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_filter_by_length.py', - '--help') + ret = script_runner.run(['scil_tractogram_filter_by_length', + '--help']) assert ret.success @@ -26,9 +26,9 @@ def test_execution_filtering(script_runner, monkeypatch): # script execution. in_bundle = os.path.join(SCILPY_HOME, 'filtering', 'bundle_4.trk') - ret = script_runner.run('scil_tractogram_filter_by_length.py', - in_bundle, 'bundle_4_filtered.trk', - '--minL', '125', '--maxL', '130') + ret = script_runner.run(['scil_tractogram_filter_by_length', + in_bundle, 'bundle_4_filtered.trk', + '--minL', '125', '--maxL', '130']) sft = load_tractogram('bundle_4_filtered.trk', 'same') assert len(sft) == 52 @@ -40,10 +40,10 @@ def test_rejected_filtering(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'filtering', 'bundle_all_1mm.trk') - ret = script_runner.run('scil_tractogram_filter_by_length.py', - in_bundle, 'bundle_all_1mm_filtered.trk', - '--minL', '125', '--maxL', '130', - '--out_rejected', 'bundle_all_1mm_rejected.trk') + ret = script_runner.run(['scil_tractogram_filter_by_length', + in_bundle, 'bundle_all_1mm_filtered.trk', + '--minL', '125', '--maxL', '130', + '--out_rejected', 'bundle_all_1mm_rejected.trk']) assert ret.success assert os.path.exists('bundle_all_1mm_rejected.trk') assert os.path.exists('bundle_all_1mm_rejected.trk') @@ -59,10 +59,10 @@ def test_rejected_filtering_no_rejection(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'filtering', 'bundle_4.trk') - ret = script_runner.run('scil_tractogram_filter_by_length.py', - in_bundle, 'bundle_4_filtered_no_rejection.trk', - '--minL', '125', '--maxL', '130', - '--out_rejected', 'bundle_4_rejected.trk') + ret = script_runner.run(['scil_tractogram_filter_by_length', + in_bundle, 'bundle_4_filtered_no_rejection.trk', + '--minL', '125', '--maxL', '130', + '--out_rejected', 'bundle_4_rejected.trk']) assert ret.success # File should be created even though there are no rejected streamlines diff --git a/scripts/tests/test_tractogram_filter_by_orientation.py b/src/scilpy/cli/tests/test_tractogram_filter_by_orientation.py similarity index 61% rename from scripts/tests/test_tractogram_filter_by_orientation.py rename to src/scilpy/cli/tests/test_tractogram_filter_by_orientation.py index 727cf22c9..39648cfd2 100644 --- a/scripts/tests/test_tractogram_filter_by_orientation.py +++ b/src/scilpy/cli/tests/test_tractogram_filter_by_orientation.py @@ -13,8 +13,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_filter_by_orientation.py', - '--help') + ret = script_runner.run(['scil_tractogram_filter_by_orientation', + '--help']) assert ret.success @@ -22,8 +22,9 @@ def test_execution_filtering(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'filtering', 'bundle_4.trk') - ret = script_runner.run('scil_tractogram_filter_by_orientation.py', - in_bundle, 'bundle_4_filtered.trk', - '--min_x', '20', '--max_y', '230', '--min_z', '30', - '--use_abs') + ret = script_runner.run(['scil_tractogram_filter_by_orientation', + in_bundle, 'bundle_4_filtered.trk', + '--min_x', '20', '--max_y', '230', + '--min_z', '30', + '--use_abs']) assert ret.success diff --git a/src/scilpy/cli/tests/test_tractogram_filter_by_roi.py b/src/scilpy/cli/tests/test_tractogram_filter_by_roi.py new file mode 100644 index 000000000..d1fec7e36 --- /dev/null +++ b/src/scilpy/cli/tests/test_tractogram_filter_by_roi.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import os +import tempfile + +from scilpy import SCILPY_HOME +from scilpy.io.fetcher import fetch_data, get_testing_files_dict + +# If they already exist, this only takes 5 seconds (check md5sum) +fetch_data(get_testing_files_dict(), keys=['filtering.zip']) +tmp_dir = tempfile.TemporaryDirectory() + +# toDo. Add an atlas and test option --atlas_roi +in_tractogram = os.path.join(SCILPY_HOME, 'filtering', + 'bundle_all_1mm_inliers.trk') +in_roi = os.path.join(SCILPY_HOME, 'filtering', 'mask.nii.gz') +in_bdo = os.path.join(SCILPY_HOME, 'filtering', 'sc.bdo') +in_labels = os.path.join(SCILPY_HOME, 'filtering', 'labels.nii.gz') + + +def test_help_option(script_runner): + ret = script_runner.run(['scil_tractogram_filter_by_roi', '--help']) + assert ret.success + + +def test_execution_filtering(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + ret = script_runner.run(['scil_tractogram_filter_by_roi', in_tractogram, + 'bundle_1.trk', '--display_counts', + '--drawn_roi', in_roi, 'any', 'include', + '--bdo', in_bdo, 'any', 'include', + '--x_plane', '0', 'either_end', 'exclude', + '--y_plane', '0', 'all', 'exclude', '0', + '--z_plane', '0', 'either_end', 'exclude', '1', + '--save_rejected', 'bundle_1_rejected.trk']) + assert ret.success + + +def test_execution_filtering_overwrite_distance(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + ret = script_runner.run(['scil_tractogram_filter_by_roi', in_tractogram, + 'bundle_2.trk', '--display_counts', + '--drawn_roi', in_roi, 'any', 'include', '2', + '--overwrite_distance', 'any', 'include', '4']) + assert ret.success + + +def test_execution_filtering_list(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + # Write a list of options + filelist = 'my_filelist.txt' + with open(filelist, 'w') as f: + f.write('atlas_roi {} "1:2 3:4" any include\n'.format(in_labels)) + f.write('bdo {} any include\n'.format(in_bdo)) + f.write("bdo {} any include".format(in_bdo)) + + ret = script_runner.run(['scil_tractogram_filter_by_roi', in_tractogram, + 'bundle_3.trk', '--display_counts', + '--filtering_list', filelist]) + assert ret.success diff --git a/scripts/tests/test_tractogram_filter_collisions.py b/src/scilpy/cli/tests/test_tractogram_filter_collisions.py similarity index 65% rename from scripts/tests/test_tractogram_filter_collisions.py rename to src/scilpy/cli/tests/test_tractogram_filter_collisions.py index 037f585e4..6244415e6 100644 --- a/scripts/tests/test_tractogram_filter_collisions.py +++ b/src/scilpy/cli/tests/test_tractogram_filter_collisions.py @@ -33,7 +33,7 @@ def init_data(): def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_filter_collisions.py', '--help') + ret = script_runner.run(['scil_tractogram_filter_collisions', '--help']) assert ret.success @@ -44,9 +44,9 @@ def test_execution_filtering(script_runner, monkeypatch): diameters = [5, 1] np.savetxt('diameters.txt', diameters) - ret = script_runner.run('scil_tractogram_filter_collisions.py', - 'tractogram.trk', 'diameters.txt', 'clean.trk', - '-f') + ret = script_runner.run(['scil_tractogram_filter_collisions', + 'tractogram.trk', 'diameters.txt', 'clean.trk', + '-f']) assert ret.success @@ -57,9 +57,9 @@ def test_execution_filtering_out_colliding_prefix(script_runner, monkeypatch): diameters = [5, 1] np.savetxt('diameters.txt', diameters) - ret = script_runner.run('scil_tractogram_filter_collisions.py', - 'tractogram.trk', 'diameters.txt', 'clean.trk', - '--out_colliding_prefix', 'tractogram', '-f') + ret = script_runner.run(['scil_tractogram_filter_collisions', + 'tractogram.trk', 'diameters.txt', 'clean.trk', + '--out_colliding_prefix', 'tractogram', '-f']) assert ret.success @@ -70,9 +70,9 @@ def test_execution_filtering_single_diameter(script_runner, monkeypatch): diameters = [5] np.savetxt('diameters.txt', diameters) - ret = script_runner.run('scil_tractogram_filter_collisions.py', - 'tractogram.trk', 'diameters.txt', 'clean.trk', - '-f') + ret = script_runner.run(['scil_tractogram_filter_collisions', + 'tractogram.trk', 'diameters.txt', 'clean.trk', + '-f']) assert ret.success @@ -83,9 +83,9 @@ def test_execution_filtering_no_shuffle(script_runner, monkeypatch): diameters = [5, 1] np.savetxt('diameters.txt', diameters) - ret = script_runner.run('scil_tractogram_filter_collisions.py', - 'tractogram.trk', 'diameters.txt', 'clean.trk', - '--disable_shuffling', '-f') + ret = script_runner.run(['scil_tractogram_filter_collisions', + 'tractogram.trk', 'diameters.txt', 'clean.trk', + '--disable_shuffling', '-f']) assert ret.success @@ -96,9 +96,9 @@ def test_execution_filtering_min_distance(script_runner, monkeypatch): diameters = [0.001, 0.001] np.savetxt('diameters.txt', diameters) - ret = script_runner.run('scil_tractogram_filter_collisions.py', - 'tractogram.trk', 'diameters.txt', 'clean.trk', - '--min_distance', '5', '-f') + ret = script_runner.run(['scil_tractogram_filter_collisions', + 'tractogram.trk', 'diameters.txt', 'clean.trk', + '--min_distance', '5', '-f']) assert ret.success @@ -110,9 +110,9 @@ def test_execution_filtering_metrics(script_runner, monkeypatch): diameters = [0.001, 0.001] np.savetxt('diameters.txt', diameters) - ret = script_runner.run('scil_tractogram_filter_collisions.py', - 'tractogram.trk', 'diameters.txt', 'clean.trk', - '--out_metrics', 'metrics.json', '-f') + ret = script_runner.run(['scil_tractogram_filter_collisions', + 'tractogram.trk', 'diameters.txt', 'clean.trk', + '--out_metrics', 'metrics.json', '-f']) assert ret.success @@ -124,7 +124,7 @@ def test_execution_rotation_matrix(script_runner, monkeypatch): diameters = [0.001, 0.001] np.savetxt('diameters.txt', diameters) - ret = script_runner.run('scil_tractogram_filter_collisions.py', - 'tractogram.trk', 'diameters.txt', 'clean.trk', - '--out_rotation_matrix', 'rotation.mat', '-f') + ret = script_runner.run(['scil_tractogram_filter_collisions', + 'tractogram.trk', 'diameters.txt', 'clean.trk', + '--out_rotation_matrix', 'rotation.mat', '-f']) assert ret.success diff --git a/scripts/tests/test_tractogram_flip.py b/src/scilpy/cli/tests/test_tractogram_flip.py similarity index 78% rename from scripts/tests/test_tractogram_flip.py rename to src/scilpy/cli/tests/test_tractogram_flip.py index eb0d55ee6..7fcfe7297 100644 --- a/scripts/tests/test_tractogram_flip.py +++ b/src/scilpy/cli/tests/test_tractogram_flip.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_flip.py', '--help') + ret = script_runner.run(['scil_tractogram_flip', '--help']) assert ret.success @@ -23,6 +23,6 @@ def test_execution_surface_vtk_fib(script_runner, monkeypatch): 'gyri_fanning.fib') in_fa = os.path.join(SCILPY_HOME, 'surface_vtk_fib', 'fa.nii.gz') - ret = script_runner.run('scil_tractogram_flip.py', in_fib, - 'gyri_fanning.tck', 'x', '--reference', in_fa) + ret = script_runner.run(['scil_tractogram_flip', in_fib, + 'gyri_fanning.tck', 'x', '--reference', in_fa]) assert ret.success diff --git a/scripts/tests/test_tractogram_math.py b/src/scilpy/cli/tests/test_tractogram_math.py similarity index 63% rename from scripts/tests/test_tractogram_math.py rename to src/scilpy/cli/tests/test_tractogram_math.py index e4b3a85f8..285b1e123 100644 --- a/scripts/tests/test_tractogram_math.py +++ b/src/scilpy/cli/tests/test_tractogram_math.py @@ -14,7 +14,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_math.py', '--help') + ret = script_runner.run(['scil_tractogram_math', '--help']) assert ret.success @@ -22,9 +22,9 @@ def test_execution_lazy_concatenate_no_color(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracto_1 = os.path.join(trk_path, 'fibercup_bundles.trk') in_tracto_2 = os.path.join(trk_path, 'fibercup_bundle_0.trk') - ret = script_runner.run('scil_tractogram_math.py', 'lazy_concatenate', - in_tracto_1, in_tracto_2, - 'lazy_concatenate.trk') + ret = script_runner.run(['scil_tractogram_math', 'lazy_concatenate', + in_tracto_1, in_tracto_2, + 'lazy_concatenate.trk']) assert ret.success @@ -32,9 +32,9 @@ def test_execution_lazy_concatenate_mix(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracto_1 = os.path.join(trk_path, 'fibercup_bundles_color.trk') in_tracto_2 = os.path.join(trk_path, 'fibercup_bundle_0.trk') - ret = script_runner.run('scil_tractogram_math.py', 'lazy_concatenate', - in_tracto_1, in_tracto_2, - 'lazy_concatenate_mix.trk') + ret = script_runner.run(['scil_tractogram_math', 'lazy_concatenate', + in_tracto_1, in_tracto_2, + 'lazy_concatenate_mix.trk']) assert ret.success @@ -42,8 +42,8 @@ def test_execution_union_no_color(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracto_1 = os.path.join(trk_path, 'fibercup_bundles.trk') in_tracto_2 = os.path.join(trk_path, 'fibercup_bundle_0.trk') - ret = script_runner.run('scil_tractogram_math.py', 'union', - in_tracto_1, in_tracto_2, 'union.trk') + ret = script_runner.run(['scil_tractogram_math', 'union', + in_tracto_1, in_tracto_2, 'union.trk']) assert ret.success @@ -51,8 +51,8 @@ def test_execution_intersection_no_color(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracto_1 = os.path.join(trk_path, 'fibercup_bundles.trk') in_tracto_2 = os.path.join(trk_path, 'fibercup_bundle_0.trk') - ret = script_runner.run('scil_tractogram_math.py', 'intersection', - in_tracto_1, in_tracto_2, 'intersection.trk') + ret = script_runner.run(['scil_tractogram_math', 'intersection', + in_tracto_1, in_tracto_2, 'intersection.trk']) assert ret.success @@ -60,8 +60,8 @@ def test_execution_difference_no_color(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracto_1 = os.path.join(trk_path, 'fibercup_bundles.trk') in_tracto_2 = os.path.join(trk_path, 'fibercup_bundle_0.trk') - ret = script_runner.run('scil_tractogram_math.py', 'difference', - in_tracto_1, in_tracto_2, 'difference.trk') + ret = script_runner.run(['scil_tractogram_math', 'difference', + in_tracto_1, in_tracto_2, 'difference.trk']) assert ret.success @@ -69,8 +69,8 @@ def test_execution_concatenate_no_color(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracto_1 = os.path.join(trk_path, 'fibercup_bundles.trk') in_tracto_2 = os.path.join(trk_path, 'fibercup_bundle_0.trk') - ret = script_runner.run('scil_tractogram_math.py', 'concatenate', - in_tracto_1, in_tracto_2, 'concatenate.trk') + ret = script_runner.run(['scil_tractogram_math', 'concatenate', + in_tracto_1, in_tracto_2, 'concatenate.trk']) assert ret.success @@ -78,9 +78,9 @@ def test_execution_union_no_color_robust(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracto_1 = os.path.join(trk_path, 'fibercup_bundles.trk') in_tracto_2 = os.path.join(trk_path, 'fibercup_bundle_0.trk') - ret = script_runner.run('scil_tractogram_math.py', 'union', - in_tracto_1, in_tracto_2, 'union_r.trk', - '--robust') + ret = script_runner.run(['scil_tractogram_math', 'union', + in_tracto_1, in_tracto_2, 'union_r.trk', + '--robust']) assert ret.success @@ -88,9 +88,9 @@ def test_execution_intersection_no_color_robust(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracto_1 = os.path.join(trk_path, 'fibercup_bundles.trk') in_tracto_2 = os.path.join(trk_path, 'fibercup_bundle_0.trk') - ret = script_runner.run('scil_tractogram_math.py', 'intersection', - in_tracto_1, in_tracto_2, 'intersection_r.trk', - '--robust') + ret = script_runner.run(['scil_tractogram_math', 'intersection', + in_tracto_1, in_tracto_2, 'intersection_r.trk', + '--robust']) assert ret.success @@ -98,9 +98,9 @@ def test_execution_difference_no_color_robust(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracto_1 = os.path.join(trk_path, 'fibercup_bundles.trk') in_tracto_2 = os.path.join(trk_path, 'fibercup_bundle_0.trk') - ret = script_runner.run('scil_tractogram_math.py', 'difference', - in_tracto_1, in_tracto_2, 'difference_r.trk', - '--robust') + ret = script_runner.run(['scil_tractogram_math', 'difference', + in_tracto_1, in_tracto_2, 'difference_r.trk', + '--robust']) assert ret.success @@ -108,8 +108,8 @@ def test_execution_union_color(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracto_1 = os.path.join(trk_path, 'fibercup_bundles_color.trk') in_tracto_2 = os.path.join(trk_path, 'fibercup_bundle_0_color.trk') - ret = script_runner.run('scil_tractogram_math.py', 'union', - in_tracto_1, in_tracto_2, 'union_color.trk') + ret = script_runner.run(['scil_tractogram_math', 'union', + in_tracto_1, in_tracto_2, 'union_color.trk']) assert ret.success @@ -117,8 +117,9 @@ def test_execution_intersection_color(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracto_1 = os.path.join(trk_path, 'fibercup_bundles_color.trk') in_tracto_2 = os.path.join(trk_path, 'fibercup_bundle_0_color.trk') - ret = script_runner.run('scil_tractogram_math.py', 'intersection', - in_tracto_1, in_tracto_2, 'intersection_color.trk') + ret = script_runner.run(['scil_tractogram_math', 'intersection', + in_tracto_1, in_tracto_2, + 'intersection_color.trk']) assert ret.success @@ -126,8 +127,9 @@ def test_execution_difference_color(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracto_1 = os.path.join(trk_path, 'fibercup_bundles_color.trk') in_tracto_2 = os.path.join(trk_path, 'fibercup_bundle_0_color.trk') - ret = script_runner.run('scil_tractogram_math.py', 'difference', - in_tracto_1, in_tracto_2, 'difference_color.trk') + ret = script_runner.run(['scil_tractogram_math', 'difference', + in_tracto_1, in_tracto_2, + 'difference_color.trk']) assert ret.success @@ -135,8 +137,9 @@ def test_execution_concatenate_color(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracto_1 = os.path.join(trk_path, 'fibercup_bundles_color.trk') in_tracto_2 = os.path.join(trk_path, 'fibercup_bundle_0_color.trk') - ret = script_runner.run('scil_tractogram_math.py', 'concatenate', - in_tracto_1, in_tracto_2, 'concatenate_color.trk') + ret = script_runner.run(['scil_tractogram_math', 'concatenate', + in_tracto_1, in_tracto_2, + 'concatenate_color.trk']) assert ret.success @@ -145,8 +148,8 @@ def test_execution_union_mix(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracto_1 = os.path.join(trk_path, 'fibercup_bundles_color.trk') in_tracto_2 = os.path.join(trk_path, 'fibercup_bundle_0.trk') - ret = script_runner.run('scil_tractogram_math.py', 'union', - in_tracto_1, in_tracto_2, 'union_mix.trk') + ret = script_runner.run(['scil_tractogram_math', 'union', + in_tracto_1, in_tracto_2, 'union_mix.trk']) assert not ret.success @@ -154,9 +157,9 @@ def test_execution_intersection_mix_fake(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracto_1 = os.path.join(trk_path, 'fibercup_bundles_color.trk') in_tracto_2 = os.path.join(trk_path, 'fibercup_bundle_0.trk') - ret = script_runner.run('scil_tractogram_math.py', 'intersection', - in_tracto_1, in_tracto_2, 'intersection_mix.trk', - '--fake_metadata') + ret = script_runner.run(['scil_tractogram_math', 'intersection', + in_tracto_1, in_tracto_2, 'intersection_mix.trk', + '--fake_metadata']) assert ret.success @@ -164,9 +167,10 @@ def test_execution_difference_empty_result(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracto_1 = os.path.join(trk_path, 'fibercup_bundle_0.trk') in_tracto_2 = os.path.join(trk_path, 'fibercup_bundle_0_color.trk') - ret = script_runner.run('scil_tractogram_math.py', 'difference', - in_tracto_1, in_tracto_2, - 'difference_empty_results.trk', '--no_metadata') + ret = script_runner.run(['scil_tractogram_math', 'difference', + in_tracto_1, in_tracto_2, + 'difference_empty_results.trk', + '--no_metadata']) assert ret.success @@ -174,9 +178,10 @@ def test_execution_difference_empty_input_1(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracto_1 = os.path.join(trk_path, 'empty.trk') in_tracto_2 = os.path.join(trk_path, 'fibercup_bundle_0_color.trk') - ret = script_runner.run('scil_tractogram_math.py', 'difference', - in_tracto_1, in_tracto_2, 'difference_empty_1.trk', - '--no_metadata') + ret = script_runner.run(['scil_tractogram_math', 'difference', + in_tracto_1, in_tracto_2, + 'difference_empty_1.trk', + '--no_metadata']) assert ret.success @@ -184,7 +189,8 @@ def test_execution_difference_empty_input_2(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracto_1 = os.path.join(trk_path, 'fibercup_bundle_0_color.trk') in_tracto_2 = os.path.join(trk_path, 'empty.trk') - ret = script_runner.run('scil_tractogram_math.py', 'difference', - in_tracto_1, in_tracto_2, 'difference_empty_2.trk', - '--no_metadata') + ret = script_runner.run(['scil_tractogram_math', 'difference', + in_tracto_1, in_tracto_2, + 'difference_empty_2.trk', + '--no_metadata']) assert ret.success diff --git a/scripts/tests/test_tractogram_pairwise_comparison.py b/src/scilpy/cli/tests/test_tractogram_pairwise_comparison.py similarity index 60% rename from scripts/tests/test_tractogram_pairwise_comparison.py rename to src/scilpy/cli/tests/test_tractogram_pairwise_comparison.py index 5393ce273..90ba4286d 100644 --- a/scripts/tests/test_tractogram_pairwise_comparison.py +++ b/src/scilpy/cli/tests/test_tractogram_pairwise_comparison.py @@ -16,24 +16,24 @@ def test_help_option(script_runner): - ret = script_runner.run( - 'scil_tractogram_pairwise_comparison.py', '--help') + ret = script_runner.run([ + 'scil_tractogram_pairwise_comparison', '--help']) assert ret.success def test_execution_bundles_skip(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_tractogram_pairwise_comparison.py', - in_1, in_2, '--out_dir', tmp_dir.name, - '--reference', in_ref, - '--skip_streamlines_distance') + ret = script_runner.run(['scil_tractogram_pairwise_comparison', + in_1, in_2, '--out_dir', tmp_dir.name, + '--reference', in_ref, + '--skip_streamlines_distance']) assert ret.success def test_execution_bundles(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_tractogram_pairwise_comparison.py', - in_1, in_2, '--out_dir', tmp_dir.name, - '--reference', in_ref, '-f', - '--skip_streamlines_distance') + ret = script_runner.run(['scil_tractogram_pairwise_comparison', + in_1, in_2, '--out_dir', tmp_dir.name, + '--reference', in_ref, '-f', + '--skip_streamlines_distance']) assert ret.success diff --git a/scripts/tests/test_tractogram_print_info.py b/src/scilpy/cli/tests/test_tractogram_print_info.py similarity index 81% rename from scripts/tests/test_tractogram_print_info.py rename to src/scilpy/cli/tests/test_tractogram_print_info.py index 2691b29e8..248fcb509 100644 --- a/scripts/tests/test_tractogram_print_info.py +++ b/src/scilpy/cli/tests/test_tractogram_print_info.py @@ -13,12 +13,12 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_print_info.py', '--help') + ret = script_runner.run(['scil_tractogram_print_info', '--help']) assert ret.success def test_execution_filtering(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'filtering', 'bundle_4.trk') - ret = script_runner.run('scil_tractogram_print_info.py', in_bundle) + ret = script_runner.run(['scil_tractogram_print_info', in_bundle]) assert ret.success diff --git a/src/scilpy/cli/tests/test_tractogram_project_map_to_streamlines.py b/src/scilpy/cli/tests/test_tractogram_project_map_to_streamlines.py new file mode 100644 index 000000000..e3d239e44 --- /dev/null +++ b/src/scilpy/cli/tests/test_tractogram_project_map_to_streamlines.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import os +import tempfile + +from scilpy import SCILPY_HOME +from scilpy.io.fetcher import fetch_data, get_testing_files_dict + +# If they already exist, this only takes 5 seconds (check md5sum) +fetch_data(get_testing_files_dict(), keys=['others.zip']) +tmp_dir = tempfile.TemporaryDirectory() + +in_tracto_1 = os.path.join(SCILPY_HOME, 'tracking', 'local_split_0.trk') +in_3d_map = os.path.join(SCILPY_HOME, 'tracking', 'fa.nii.gz') +in_4d_map = os.path.join(SCILPY_HOME, 'tracking', 'peaks.nii.gz') + + +def test_help_option(script_runner): + ret = script_runner.run([ + 'scil_tractogram_project_map_to_streamlines', '--help']) + assert ret.success + + +def test_execution_3D_map(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + ret = script_runner.run(['scil_tractogram_project_map_to_streamlines', + in_tracto_1, 't1_on_streamlines.trk', + '--in_maps', in_3d_map, + '--out_dpp_name', 't1']) + assert ret.success + + +def test_execution_4D_map(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + ret = script_runner.run(['scil_tractogram_project_map_to_streamlines', + in_tracto_1, 'rgb_on_streamlines.trk', + '--in_maps', in_4d_map, + '--out_dpp_name', 'rgb']) + assert ret.success + + +def test_execution_3D_map_endpoints_only(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + ret = script_runner.run(['scil_tractogram_project_map_to_streamlines', + in_tracto_1, + 't1_on_streamlines_endpoints.trk', + '--in_maps', in_3d_map, + '--out_dpp_name', 't1', + '--endpoints_only']) + assert ret.success + + +def test_execution_4D_map_endpoints_only(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + ret = script_runner.run(['scil_tractogram_project_map_to_streamlines', + in_tracto_1, + 'rgb_on_streamlines_endpoints.trk', + '--in_maps', in_4d_map, + '--out_dpp_name', 'rgb', + '--endpoints_only']) + assert ret.success + + +def test_execution_3D_map_trilinear(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + ret = script_runner.run(['scil_tractogram_project_map_to_streamlines', + in_tracto_1, + 't1_on_streamlines_trilinear.trk', + '--in_maps', in_3d_map, + '--out_dpp_name', 't1', + '--trilinear']) + assert ret.success diff --git a/src/scilpy/cli/tests/test_tractogram_project_streamlines_to_map.py b/src/scilpy/cli/tests/test_tractogram_project_streamlines_to_map.py new file mode 100644 index 000000000..4935d66e7 --- /dev/null +++ b/src/scilpy/cli/tests/test_tractogram_project_streamlines_to_map.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import os +import tempfile + +from scilpy import SCILPY_HOME +from scilpy.io.fetcher import fetch_data, get_testing_files_dict + +# If they already exist, this only takes 5 seconds (check md5sum) +fetch_data(get_testing_files_dict(), keys=['tractometry.zip']) +tmp_dir = tempfile.TemporaryDirectory() + +# toDo. For more coverage, save some DPS and DPP in a text file, and test +# options --load_dpp, --load_dps. + + +def test_help_option(script_runner): + ret = script_runner.run(['scil_tractogram_project_streamlines_to_map', + '--help']) + assert ret.success + + +def test_execution_dpp(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + in_bundle = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM_uni.trk') + in_mni = os.path.join(SCILPY_HOME, 'tractometry', 'mni_masked.nii.gz') + in_bundle_with_dpp = 'IFGWM_uni_with_dpp.trk' + + # Create our test data with dpp: add metrics as dpp. + # Or get a tractogram that already as some dpp in the test data. + script_runner.run(['scil_tractogram_project_map_to_streamlines', + in_bundle, in_bundle_with_dpp, '-f', + '--in_maps', in_mni, '--out_dpp_name', 'some_metric']) + + # Tests with dpp. + ret = script_runner.run(['scil_tractogram_project_streamlines_to_map', + in_bundle_with_dpp, 'project_dpp_', + '--use_dpp', 'some_metric', '--point_by_point', + '--to_endpoints']) + assert ret.success + + ret = script_runner.run(['scil_tractogram_project_streamlines_to_map', + in_bundle_with_dpp, 'project_mean_to_endpoints_', + '--use_dpp', 'some_metric', '--mean_streamline', + '--to_endpoints']) + assert ret.success + + ret = script_runner.run(['scil_tractogram_project_streamlines_to_map', + in_bundle_with_dpp, 'project_end_to_wm', + '--use_dpp', 'some_metric', '--mean_endpoints', + '--to_wm']) + assert ret.success + + +def test_execution_dps(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + in_bundle = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM_uni.trk') + in_mni = os.path.join(SCILPY_HOME, 'tractometry', 'mni_masked.nii.gz') + in_bundle_with_dpp = 'IFGWM_uni_with_dpp.trk' + in_bundle_with_dps = 'IFGWM_uni_with_dps.trk' + + # Create our test data with dps: add metrics as dps. + # Or get a tractogram that already as some dps in the test data. + script_runner.run(['scil_tractogram_project_map_to_streamlines', + in_bundle, in_bundle_with_dpp, '-f', + '--in_maps', in_mni, '--out_dpp_name', 'some_metric']) + script_runner.run(['scil_tractogram_dpp_math', 'min', in_bundle_with_dpp, + in_bundle_with_dps, '--in_dpp_name', 'some_metric', + '--out_keys', 'some_metric_dps', '--mode', 'dps', + '--keep_all']) + + # Tests with dps. + ret = script_runner.run(['scil_tractogram_project_streamlines_to_map', + in_bundle_with_dps, 'project_dps_', + '--use_dps', 'some_metric_dps', + '--point_by_point', '--to_wm']) + assert ret.success diff --git a/scripts/tests/test_tractogram_qbx.py b/src/scilpy/cli/tests/test_tractogram_qbx.py similarity index 75% rename from scripts/tests/test_tractogram_qbx.py rename to src/scilpy/cli/tests/test_tractogram_qbx.py index 1357fe728..3b6f83eef 100644 --- a/scripts/tests/test_tractogram_qbx.py +++ b/src/scilpy/cli/tests/test_tractogram_qbx.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_qbx.py', '--help') + ret = script_runner.run(['scil_tractogram_qbx', '--help']) assert ret.success @@ -21,6 +21,6 @@ def test_execution_filtering(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'filtering', 'bundle_all_1mm.trk') - ret = script_runner.run('scil_tractogram_qbx.py', in_bundle, '12', - 'clusters/', '--out_centroids', 'centroids.trk') + ret = script_runner.run(['scil_tractogram_qbx', in_bundle, '12', + 'clusters/', '--out_centroids', 'centroids.trk']) assert ret.success diff --git a/scripts/tests/test_tractogram_register.py b/src/scilpy/cli/tests/test_tractogram_register.py similarity index 76% rename from scripts/tests/test_tractogram_register.py rename to src/scilpy/cli/tests/test_tractogram_register.py index 8d5084060..c0ac025d4 100644 --- a/scripts/tests/test_tractogram_register.py +++ b/src/scilpy/cli/tests/test_tractogram_register.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_register.py', '--help') + ret = script_runner.run(['scil_tractogram_register', '--help']) assert ret.success @@ -25,7 +25,7 @@ def test_execution_bundles(script_runner, monkeypatch): 'bundle_0.trk') in_ref = os.path.join(SCILPY_HOME, 'bundles', 'bundle_all_1mm.nii.gz') - ret = script_runner.run('scil_tractogram_register.py', in_moving, - in_static, '--only_rigid', - '--moving_tractogram_ref', in_ref) + ret = script_runner.run(['scil_tractogram_register', in_moving, + in_static, '--only_rigid', + '--moving_tractogram_ref', in_ref]) assert ret.success diff --git a/scripts/tests/test_tractogram_remove_invalid.py b/src/scilpy/cli/tests/test_tractogram_remove_invalid.py similarity index 69% rename from scripts/tests/test_tractogram_remove_invalid.py rename to src/scilpy/cli/tests/test_tractogram_remove_invalid.py index e06f0da95..8a7d95d81 100644 --- a/scripts/tests/test_tractogram_remove_invalid.py +++ b/src/scilpy/cli/tests/test_tractogram_remove_invalid.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_remove_invalid.py', '--help') + ret = script_runner.run(['scil_tractogram_remove_invalid', '--help']) assert ret.success @@ -21,7 +21,7 @@ def test_execution_bundles(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tractogram = os.path.join(SCILPY_HOME, 'bundles', 'bundle_all_1mm.trk') - ret = script_runner.run('scil_tractogram_remove_invalid.py', - in_tractogram, 'bundle_all_1mm.trk', '--cut', - '--remove_overlapping', '--remove_single', '-f') + ret = script_runner.run(['scil_tractogram_remove_invalid', + in_tractogram, 'bundle_all_1mm.trk', '--cut', + '--remove_overlapping', '--remove_single', '-f']) assert ret.success diff --git a/scripts/tests/test_tractogram_resample.py b/src/scilpy/cli/tests/test_tractogram_resample.py similarity index 51% rename from scripts/tests/test_tractogram_resample.py rename to src/scilpy/cli/tests/test_tractogram_resample.py index abe856a94..f853daf2e 100644 --- a/scripts/tests/test_tractogram_resample.py +++ b/src/scilpy/cli/tests/test_tractogram_resample.py @@ -16,20 +16,20 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_resample.py', '--help') + ret = script_runner.run(['scil_tractogram_resample', '--help']) assert ret.success def test_execution_downsample(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_tractogram_resample.py', in_tracto, - '500', 'union_shuffle_sub_downsampled.trk') + ret = script_runner.run(['scil_tractogram_resample', in_tracto, + '500', 'union_shuffle_sub_downsampled.trk']) assert ret.success - ret = script_runner.run('scil_tractogram_resample.py', in_tracto, - '200', 'union_shuffle_sub_downsampled.trk', - '-f', '--downsample_per_cluster') + ret = script_runner.run(['scil_tractogram_resample', in_tracto, + '200', 'union_shuffle_sub_downsampled.trk', + '-f', '--downsample_per_cluster']) assert ret.success @@ -37,9 +37,9 @@ def test_execution_upsample_noise(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) # point-wise only - ret = script_runner.run('scil_tractogram_resample.py', in_tracto, - '2000', 'union_shuffle_sub_upsampled.trk', '-f', - '--point_wise_std', '0.5') + ret = script_runner.run(['scil_tractogram_resample', in_tracto, + '2000', 'union_shuffle_sub_upsampled.trk', '-f', + '--point_wise_std', '0.5']) assert ret.success @@ -47,13 +47,13 @@ def test_execution_upsample_ptt(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) # ptt only - ret = script_runner.run('scil_tractogram_resample.py', in_tracto, - '500', 'union_shuffle_sub_upsampled.trk', '-f', - '--tube_radius', '5') + ret = script_runner.run(['scil_tractogram_resample', in_tracto, + '500', 'union_shuffle_sub_upsampled.trk', '-f', + '--tube_radius', '5']) assert ret.success # both upsampling methods - ret = script_runner.run('scil_tractogram_resample.py', in_tracto, - '500', 'union_shuffle_sub_upsampled.trk', '-f', - '--point_wise_std', '10', '--tube_radius', '5') + ret = script_runner.run(['scil_tractogram_resample', in_tracto, + '500', 'union_shuffle_sub_upsampled.trk', '-f', + '--point_wise_std', '10', '--tube_radius', '5']) assert ret.success diff --git a/scripts/tests/test_tractogram_resample_nb_points.py b/src/scilpy/cli/tests/test_tractogram_resample_nb_points.py similarity index 70% rename from scripts/tests/test_tractogram_resample_nb_points.py rename to src/scilpy/cli/tests/test_tractogram_resample_nb_points.py index ffdd3915c..af8d8bf24 100644 --- a/scripts/tests/test_tractogram_resample_nb_points.py +++ b/src/scilpy/cli/tests/test_tractogram_resample_nb_points.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_resample_nb_points.py', '--help') + ret = script_runner.run(['scil_tractogram_resample_nb_points', '--help']) assert ret.success @@ -21,7 +21,7 @@ def test_execution_tractometry(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_bundle = os.path.join(SCILPY_HOME, 'tractometry', 'IFGWM_uni_c.trk') - ret = script_runner.run('scil_tractogram_resample_nb_points.py', - in_bundle, 'IFGWM_uni_c_10.trk', - '--nb_pts_per_streamline', '10') + ret = script_runner.run(['scil_tractogram_resample_nb_points', + in_bundle, 'IFGWM_uni_c_10.trk', + '--nb_pts_per_streamline', '10']) assert ret.success diff --git a/scripts/tests/test_tractogram_seed_density_map.py b/src/scilpy/cli/tests/test_tractogram_seed_density_map.py similarity index 74% rename from scripts/tests/test_tractogram_seed_density_map.py rename to src/scilpy/cli/tests/test_tractogram_seed_density_map.py index ec9e2626c..1d3ce7b85 100644 --- a/scripts/tests/test_tractogram_seed_density_map.py +++ b/src/scilpy/cli/tests/test_tractogram_seed_density_map.py @@ -13,13 +13,13 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_seed_density_map.py', '--help') + ret = script_runner.run(['scil_tractogram_seed_density_map', '--help']) assert ret.success def test_execution_processing(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracking = os.path.join(SCILPY_HOME, 'processing', 'tracking.trk') - ret = script_runner.run('scil_tractogram_seed_density_map.py', in_tracking, - 'seeds_density.nii.gz') + ret = script_runner.run(['scil_tractogram_seed_density_map', in_tracking, + 'seeds_density.nii.gz']) assert ret.success diff --git a/scripts/tests/test_tractogram_segment_connections_from_labels.py b/src/scilpy/cli/tests/test_tractogram_segment_connections_from_labels.py similarity index 76% rename from scripts/tests/test_tractogram_segment_connections_from_labels.py rename to src/scilpy/cli/tests/test_tractogram_segment_connections_from_labels.py index e0ae13ae2..dad3c7211 100644 --- a/scripts/tests/test_tractogram_segment_connections_from_labels.py +++ b/src/scilpy/cli/tests/test_tractogram_segment_connections_from_labels.py @@ -13,8 +13,8 @@ def test_help_option(script_runner): - ret = script_runner.run( - 'scil_tractogram_segment_connections_from_labels.py', '--help') + ret = script_runner.run([ + 'scil_tractogram_segment_connections_from_labels', '--help']) assert ret.success @@ -23,10 +23,11 @@ def test_execution_connectivity(script_runner, monkeypatch): in_bundle = os.path.join(SCILPY_HOME, 'connectivity', 'bundle_all_1mm.trk') in_atlas = os.path.join(SCILPY_HOME, 'connectivity', 'endpoints_atlas.nii.gz') - ret = script_runner.run( - 'scil_tractogram_segment_connections_from_labels.py', in_bundle, + ret = script_runner.run([ + 'scil_tractogram_segment_connections_from_labels', in_bundle, in_atlas, 'decompose.h5', '--min_length', '20', '--max_length', '200', '--outlier_threshold', '0.5', '--loop_max_angle', '330', '--curv_qb_distance', '10', '--processes', '1', '-v', 'DEBUG', - '--save_final', '--out_dir', os.path.join(tmp_dir.name, 'out_bundles')) + '--save_final', '--out_dir', + os.path.join(tmp_dir.name, 'out_bundles')]) assert ret.success diff --git a/scripts/tests/test_tractogram_segment_with_ROI_and_score.py b/src/scilpy/cli/tests/test_tractogram_segment_with_ROI_and_score.py similarity index 75% rename from scripts/tests/test_tractogram_segment_with_ROI_and_score.py rename to src/scilpy/cli/tests/test_tractogram_segment_with_ROI_and_score.py index c7b0769fd..9f77d895b 100644 --- a/scripts/tests/test_tractogram_segment_with_ROI_and_score.py +++ b/src/scilpy/cli/tests/test_tractogram_segment_with_ROI_and_score.py @@ -11,8 +11,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_segment_with_ROI_and_score.py', - '--help') + ret = script_runner.run(['scil_tractogram_segment_with_ROI_and_score', + '--help']) assert ret.success @@ -35,8 +35,8 @@ def test_score_bundles(script_runner, monkeypatch): with open(os.path.join("config_file.json"), "w") as f: json.dump(json_contents, f) - ret = script_runner.run('scil_tractogram_segment_with_ROI_and_score.py', - in_tractogram, "config_file.json", - 'scoring_tractogram/', '--no_empty', - '--use_gt_masks_as_all_masks') + ret = script_runner.run(['scil_tractogram_segment_with_ROI_and_score', + in_tractogram, "config_file.json", + 'scoring_tractogram/', '--no_empty', + '--use_gt_masks_as_all_masks']) assert ret.success diff --git a/scripts/tests/test_tractogram_segment_with_bundleseg.py b/src/scilpy/cli/tests/test_tractogram_segment_with_bundleseg.py similarity index 71% rename from scripts/tests/test_tractogram_segment_with_bundleseg.py rename to src/scilpy/cli/tests/test_tractogram_segment_with_bundleseg.py index 1de079e0e..7c5cf9c62 100644 --- a/scripts/tests/test_tractogram_segment_with_bundleseg.py +++ b/src/scilpy/cli/tests/test_tractogram_segment_with_bundleseg.py @@ -14,8 +14,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_segment_with_bundleseg.py', - '--help') + ret = script_runner.run(['scil_tractogram_segment_with_bundleseg', + '--help']) assert ret.success @@ -34,9 +34,9 @@ def test_execution_bundles(script_runner, monkeypatch): with open('config.json', 'w') as outfile: json.dump(tmp_config, outfile) - ret = script_runner.run('scil_tractogram_segment_with_bundleseg.py', - in_tractogram, 'config.json', - in_models, - in_aff, '--inverse', - '--processes', '1', '-v', 'WARNING') + ret = script_runner.run(['scil_tractogram_segment_with_bundleseg', + in_tractogram, 'config.json', + in_models, + in_aff, '--inverse', + '--processes', '1', '-v', 'WARNING']) assert ret.success diff --git a/scripts/tests/test_tractogram_segment_with_recobundles.py b/src/scilpy/cli/tests/test_tractogram_segment_with_recobundles.py similarity index 62% rename from scripts/tests/test_tractogram_segment_with_recobundles.py rename to src/scilpy/cli/tests/test_tractogram_segment_with_recobundles.py index 786ceb456..06df353f8 100644 --- a/scripts/tests/test_tractogram_segment_with_recobundles.py +++ b/src/scilpy/cli/tests/test_tractogram_segment_with_recobundles.py @@ -13,8 +13,8 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_segment_with_recobundles.py', - '--help') + ret = script_runner.run(['scil_tractogram_segment_with_recobundles', + '--help']) assert ret.success @@ -24,10 +24,10 @@ def test_execution_bundles(script_runner, monkeypatch): in_model = os.path.join(SCILPY_HOME, 'bundles', 'fibercup_atlas', 'subj_1', 'bundle_0.trk') in_aff = os.path.join(SCILPY_HOME, 'bundles', 'affine.txt') - ret = script_runner.run('scil_tractogram_segment_with_recobundles.py', - in_tractogram, in_model, in_aff, - 'bundle_0_reco.tck', '--inverse', - '--tractogram_clustering_thr', '12', - '--slr_threads', '1', '--out_pickle', - 'clusters.pkl') + ret = script_runner.run(['scil_tractogram_segment_with_recobundles', + in_tractogram, in_model, in_aff, + 'bundle_0_reco.tck', '--inverse', + '--tractogram_clustering_thr', '12', + '--slr_threads', '1', '--out_pickle', + 'clusters.pkl']) assert ret.success diff --git a/scripts/tests/test_tractogram_shuffle.py b/src/scilpy/cli/tests/test_tractogram_shuffle.py similarity index 76% rename from scripts/tests/test_tractogram_shuffle.py rename to src/scilpy/cli/tests/test_tractogram_shuffle.py index c2fbacf00..59c6a79db 100644 --- a/scripts/tests/test_tractogram_shuffle.py +++ b/src/scilpy/cli/tests/test_tractogram_shuffle.py @@ -13,13 +13,13 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_shuffle.py', '--help') + ret = script_runner.run(['scil_tractogram_shuffle', '--help']) assert ret.success def test_execution_tracking(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracto = os.path.join(SCILPY_HOME, 'tracking', 'union.trk') - ret = script_runner.run('scil_tractogram_shuffle.py', in_tracto, - 'union_shuffle.trk') + ret = script_runner.run(['scil_tractogram_shuffle', in_tracto, + 'union_shuffle.trk']) assert ret.success diff --git a/scripts/tests/test_tractogram_smooth.py b/src/scilpy/cli/tests/test_tractogram_smooth.py similarity index 68% rename from scripts/tests/test_tractogram_smooth.py rename to src/scilpy/cli/tests/test_tractogram_smooth.py index 67bf99f2b..418b5539d 100644 --- a/scripts/tests/test_tractogram_smooth.py +++ b/src/scilpy/cli/tests/test_tractogram_smooth.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_smooth.py', '--help') + ret = script_runner.run(['scil_tractogram_smooth', '--help']) assert ret.success @@ -21,7 +21,8 @@ def test_execution_tracking(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracto = os.path.join(SCILPY_HOME, 'tracking', 'union_shuffle_sub.trk') - ret = script_runner.run('scil_tractogram_smooth.py', in_tracto, - 'union_shuffle_sub_smooth.trk', '--gaussian', '10', - '--compress', '0.05') + ret = script_runner.run(['scil_tractogram_smooth', in_tracto, + 'union_shuffle_sub_smooth.trk', + '--gaussian', '10', + '--compress', '0.05']) assert ret.success diff --git a/scripts/tests/test_tractogram_split.py b/src/scilpy/cli/tests/test_tractogram_split.py similarity index 54% rename from scripts/tests/test_tractogram_split.py rename to src/scilpy/cli/tests/test_tractogram_split.py index cbcaa3d21..7680343fa 100644 --- a/scripts/tests/test_tractogram_split.py +++ b/src/scilpy/cli/tests/test_tractogram_split.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_tractogram_split.py', '--help') + ret = script_runner.run(['scil_tractogram_split', '--help']) assert ret.success @@ -21,16 +21,16 @@ def test_execution_tracking(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_tracto = os.path.join(SCILPY_HOME, 'tracking', 'local.trk') - ret = script_runner.run('scil_tractogram_split.py', in_tracto, - 'local_split', '--nb_chunks', '3', '-f') + ret = script_runner.run(['scil_tractogram_split', in_tracto, + 'local_split', '--nb_chunks', '3', '-f']) assert ret.success - ret = script_runner.run('scil_tractogram_split.py', in_tracto, - 'local_split', '--nb_chunks', '3', '-f', - '--split_per_cluster') + ret = script_runner.run(['scil_tractogram_split', in_tracto, + 'local_split', '--nb_chunks', '3', '-f', + '--split_per_cluster']) assert ret.success - ret = script_runner.run('scil_tractogram_split.py', in_tracto, - 'local_split', '--nb_chunks', '3', '-f', - '--do_not_randomize') + ret = script_runner.run(['scil_tractogram_split', in_tracto, + 'local_split', '--nb_chunks', '3', '-f', + '--do_not_randomize']) assert ret.success diff --git a/src/scilpy/cli/tests/test_viz_bingham_fit.py b/src/scilpy/cli/tests/test_viz_bingham_fit.py new file mode 100644 index 000000000..10f0e16eb --- /dev/null +++ b/src/scilpy/cli/tests/test_viz_bingham_fit.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import os +import tempfile + +from scilpy import SCILPY_HOME +from scilpy.io.fetcher import fetch_data, get_testing_files_dict + +fetch_data(get_testing_files_dict(), keys=['processing.zip']) +tmp_dir = tempfile.TemporaryDirectory() + + +def test_help_option(script_runner): + ret = script_runner.run(['scil_viz_bingham_fit', '--help']) + assert ret.success + + +def test_silent_without_output(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + + in_dummy = os.path.join(SCILPY_HOME, 'processing', 'fodf_bingham.nii.gz') + out = os.path.join(tmp_dir.name, 'test_bingham.png') + ret = script_runner.run(['scil_viz_bingham_fit', in_dummy, + '--silent', '--output', out]) + + assert ret.success diff --git a/scripts/tests/test_viz_bundle.py b/src/scilpy/cli/tests/test_viz_bundle.py similarity index 79% rename from scripts/tests/test_viz_bundle.py rename to src/scilpy/cli/tests/test_viz_bundle.py index 87631065b..333fdb666 100644 --- a/scripts/tests/test_viz_bundle.py +++ b/src/scilpy/cli/tests/test_viz_bundle.py @@ -8,7 +8,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_viz_bundle.py', '--help') + ret = script_runner.run(['scil_viz_bundle', '--help']) assert ret.success # Tests including VTK do not work on a server without a display @@ -20,6 +20,6 @@ def test_help_option(script_runner): # in_bundle = os.path.join( # SCILPY_HOME, 'bundles', 'fibercup_atlas', 'subj_1', 'bundle_0.trk') -# ret = script_runner.run('scil_viz_bundle.py', -# in_vol, in_bundle, 'out.png') +# ret = script_runner.run(['scil_viz_bundle', +# in_vol, in_bundle, 'out.png']) # assert ret.success diff --git a/src/scilpy/cli/tests/test_viz_bundle_screenshot_mni.py b/src/scilpy/cli/tests/test_viz_bundle_screenshot_mni.py new file mode 100644 index 000000000..ab82cd624 --- /dev/null +++ b/src/scilpy/cli/tests/test_viz_bundle_screenshot_mni.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + + +def test_help_option(script_runner): + ret = script_runner.run(['scil_viz_bundle_screenshot_mni', '--help']) + assert ret.success diff --git a/src/scilpy/cli/tests/test_viz_bundle_screenshot_mosaic.py b/src/scilpy/cli/tests/test_viz_bundle_screenshot_mosaic.py new file mode 100644 index 000000000..9db86f203 --- /dev/null +++ b/src/scilpy/cli/tests/test_viz_bundle_screenshot_mosaic.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + + +def test_help_option(script_runner): + ret = script_runner.run(['scil_bundle_clean_qbx_clusters', '--help']) + assert ret.success diff --git a/scripts/tests/test_viz_connectivity.py b/src/scilpy/cli/tests/test_viz_connectivity.py similarity index 62% rename from scripts/tests/test_viz_connectivity.py rename to src/scilpy/cli/tests/test_viz_connectivity.py index ea091be5d..4a08e5394 100644 --- a/scripts/tests/test_viz_connectivity.py +++ b/src/scilpy/cli/tests/test_viz_connectivity.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_viz_connectivity.py', '--help') + ret = script_runner.run(['scil_viz_connectivity', '--help']) assert ret.success @@ -23,9 +23,10 @@ def test_execution_connectivity(script_runner, monkeypatch): 'sc_norm.npy') in_labels_list = os.path.join(SCILPY_HOME, 'connectivity', 'labels_list.txt') - ret = script_runner.run('scil_viz_connectivity.py', in_sc, - 'sc_norm.png', '--log', '--display_legend', - '--labels_list', in_labels_list, - '--histogram', 'hist.png', '--nb_bins', '50', - '--exclude_zeros', '--chord_chart', 'sc_chord.png') + ret = script_runner.run(['scil_viz_connectivity', in_sc, + 'sc_norm.png', '--log', '--display_legend', + '--labels_list', in_labels_list, + '--histogram', 'hist.png', '--nb_bins', '50', + '--exclude_zeros', '--chord_chart', + 'sc_chord.png']) assert ret.success diff --git a/scripts/tests/test_lesions_info.py b/src/scilpy/cli/tests/test_viz_dti_screenshot.py similarity index 62% rename from scripts/tests/test_lesions_info.py rename to src/scilpy/cli/tests/test_viz_dti_screenshot.py index 1c667997d..fa8cd2fe0 100644 --- a/scripts/tests/test_lesions_info.py +++ b/src/scilpy/cli/tests/test_viz_dti_screenshot.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- + def test_help_option(script_runner): - ret = script_runner.run('scil_lesions_info.py', '--help') + ret = script_runner.run(['scil_dwi_convert_FDF', '--help']) assert ret.success diff --git a/src/scilpy/cli/tests/test_viz_fodf.py b/src/scilpy/cli/tests/test_viz_fodf.py new file mode 100644 index 000000000..e3d38f8e8 --- /dev/null +++ b/src/scilpy/cli/tests/test_viz_fodf.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import os +import tempfile + +from scilpy import SCILPY_HOME +from scilpy.io.fetcher import fetch_data, get_testing_files_dict + +fetch_data(get_testing_files_dict(), keys=['processing.zip']) +tmp_dir = tempfile.TemporaryDirectory() + + +def test_help_option(script_runner): + ret = script_runner.run(['scil_viz_fodf', '--help']) + assert ret.success + + +def test_silent_without_output(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + in_fodf = os.path.join(SCILPY_HOME, 'processing', 'fodf.nii.gz') + + ret = script_runner.run(['scil_viz_fodf', in_fodf, '--silent']) + + # Should say that requires an output with --silent mode + assert (not ret.success) + + +def test_run(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + in_fodf = os.path.join(SCILPY_HOME, 'processing', 'fodf.nii.gz') + in_mask = os.path.join(SCILPY_HOME, 'processing', 'seed.nii.gz') + # No variance file in our test data, but faking it with the fodf file. + in_variance = os.path.join(SCILPY_HOME, 'processing', 'fodf.nii.gz') + out_name = os.path.join(tmp_dir.name, 'out.png') + ret = script_runner.run(['scil_viz_fodf', in_fodf, '--silent', + '--in_transparency_mask', in_mask, + '--mask', in_mask, + '--variance', in_variance, + '--output', out_name]) + assert ret.success + + +def test_run_sphsubdivide(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + in_fodf = os.path.join(SCILPY_HOME, 'processing', 'fodf.nii.gz') + in_mask = os.path.join(SCILPY_HOME, 'processing', 'seed.nii.gz') + out_name = os.path.join(tmp_dir.name, 'out2.png') + + # Note. Cannot add --sph_subdivide to the test above, causes a memory + # crash. Without the variance, lighter. + ret = script_runner.run(['scil_viz_fodf', in_fodf, '--silent', + '--mask', in_mask, + '--sph_subdivide', '2', + '--sphere', 'repulsion100', + '--output', out_name]) + + assert ret.success diff --git a/src/scilpy/cli/tests/test_viz_gradients_screenshot.py b/src/scilpy/cli/tests/test_viz_gradients_screenshot.py new file mode 100644 index 000000000..f255277b8 --- /dev/null +++ b/src/scilpy/cli/tests/test_viz_gradients_screenshot.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + + +def test_help_option(script_runner): + ret = script_runner.run(['scil_viz_gradients_screenshot', '--help']) + assert ret.success diff --git a/src/scilpy/cli/tests/test_viz_tractogram_collisions.py b/src/scilpy/cli/tests/test_viz_tractogram_collisions.py new file mode 100644 index 000000000..e89efdb71 --- /dev/null +++ b/src/scilpy/cli/tests/test_viz_tractogram_collisions.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + + +def test_help_option(script_runner): + ret = script_runner.run(['scil_viz_tractogram_collisions', '--help']) + assert ret.success diff --git a/scripts/tests/test_viz_dti_screenshot.py b/src/scilpy/cli/tests/test_viz_tractogram_seeds.py similarity index 61% rename from scripts/tests/test_viz_dti_screenshot.py rename to src/scilpy/cli/tests/test_viz_tractogram_seeds.py index 56c47a53c..e735dc09e 100644 --- a/scripts/tests/test_viz_dti_screenshot.py +++ b/src/scilpy/cli/tests/test_viz_tractogram_seeds.py @@ -3,5 +3,5 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_viz_dti_screenshot.py', '--help') + ret = script_runner.run(['scil_viz_tractogram_seeds', '--help']) assert ret.success diff --git a/scripts/tests/test_viz_tractogram_seeds.py b/src/scilpy/cli/tests/test_viz_tractogram_seeds_3d.py similarity index 60% rename from scripts/tests/test_viz_tractogram_seeds.py rename to src/scilpy/cli/tests/test_viz_tractogram_seeds_3d.py index 46baeb10e..e735dc09e 100644 --- a/scripts/tests/test_viz_tractogram_seeds.py +++ b/src/scilpy/cli/tests/test_viz_tractogram_seeds_3d.py @@ -3,5 +3,5 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_viz_tractogram_seeds.py', '--help') + ret = script_runner.run(['scil_viz_tractogram_seeds', '--help']) assert ret.success diff --git a/scripts/tests/test_viz_volume_histogram.py b/src/scilpy/cli/tests/test_viz_volume_histogram.py similarity index 78% rename from scripts/tests/test_viz_volume_histogram.py rename to src/scilpy/cli/tests/test_viz_volume_histogram.py index 41cc09b29..716082725 100644 --- a/scripts/tests/test_viz_volume_histogram.py +++ b/src/scilpy/cli/tests/test_viz_volume_histogram.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_viz_volume_histogram.py', '--help') + ret = script_runner.run(['scil_viz_volume_histogram', '--help']) assert ret.success @@ -23,6 +23,6 @@ def test_execution_processing(script_runner, monkeypatch): 'fa.nii.gz') in_mask = os.path.join(SCILPY_HOME, 'processing', 'seed.nii.gz') - ret = script_runner.run('scil_viz_volume_histogram.py', in_fa, in_mask, - '20', 'histogram.png') + ret = script_runner.run(['scil_viz_volume_histogram', in_fa, in_mask, + '20', 'histogram.png']) assert ret.success diff --git a/scripts/tests/test_viz_volume_scatterplot.py b/src/scilpy/cli/tests/test_viz_volume_scatterplot.py similarity index 71% rename from scripts/tests/test_viz_volume_scatterplot.py rename to src/scilpy/cli/tests/test_viz_volume_scatterplot.py index 207b09698..d9fd2ec22 100644 --- a/scripts/tests/test_viz_volume_scatterplot.py +++ b/src/scilpy/cli/tests/test_viz_volume_scatterplot.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_viz_volume_scatterplot.py', '--help') + ret = script_runner.run(['scil_viz_volume_scatterplot', '--help']) assert ret.success @@ -23,8 +23,8 @@ def test_execution_processing(script_runner, monkeypatch): 'fa.nii.gz') in_y = os.path.join(SCILPY_HOME, 'plot', 'ad.nii.gz') - ret = script_runner.run('scil_viz_volume_scatterplot.py', in_x, in_y, - 'scatter_plot.png') + ret = script_runner.run(['scil_viz_volume_scatterplot', in_x, in_y, + 'scatter_plot.png']) assert ret.success @@ -36,8 +36,8 @@ def test_execution_processing_bin_mask(script_runner, monkeypatch): 'ad.nii.gz') in_mask = os.path.join(SCILPY_HOME, 'plot', 'mask_wm.nii.gz') - ret = script_runner.run('scil_viz_volume_scatterplot.py', in_x, in_y, - 'scatter_plot_m.png', '--in_bin_mask', in_mask) + ret = script_runner.run(['scil_viz_volume_scatterplot', in_x, in_y, + 'scatter_plot_m.png', '--in_bin_mask', in_mask]) assert ret.success @@ -51,9 +51,9 @@ def test_execution_processing_prob_map(script_runner, monkeypatch): 'map_wm.nii.gz') in_prob_2 = os.path.join(SCILPY_HOME, 'plot', 'map_gm.nii.gz') - ret = script_runner.run('scil_viz_volume_scatterplot.py', in_x, in_y, - 'scatter_plot_prob.png', - '--in_prob_maps', in_prob_1, in_prob_2) + ret = script_runner.run(['scil_viz_volume_scatterplot', in_x, in_y, + 'scatter_plot_prob.png', + '--in_prob_maps', in_prob_1, in_prob_2]) assert ret.success @@ -67,9 +67,9 @@ def test_execution_processing_atlas(script_runner, monkeypatch): 'atlas_brainnetome.nii.gz') atlas_lut = os.path.join(SCILPY_HOME, 'plot', 'atlas_brainnetome.json') - ret = script_runner.run('scil_viz_volume_scatterplot.py', in_x, in_y, - 'scatter_plot', '--in_atlas', in_atlas, - '--atlas_lut', atlas_lut) + ret = script_runner.run(['scil_viz_volume_scatterplot', in_x, in_y, + 'scatter_plot', '--in_atlas', in_atlas, + '--atlas_lut', atlas_lut]) assert ret.success @@ -83,10 +83,10 @@ def test_execution_processing_atlas_folder(script_runner, monkeypatch): 'atlas_brainnetome.nii.gz') atlas_lut = os.path.join(SCILPY_HOME, 'plot', 'atlas_brainnetome.json') - ret = script_runner.run('scil_viz_volume_scatterplot.py', in_x, in_y, - 'scatter_plot', '--in_atlas', in_atlas, - '--atlas_lut', atlas_lut, - '--in_folder') + ret = script_runner.run(['scil_viz_volume_scatterplot', in_x, in_y, + 'scatter_plot', '--in_atlas', in_atlas, + '--atlas_lut', atlas_lut, + '--in_folder']) assert ret.success @@ -101,9 +101,9 @@ def test_execution_processing_atlas_folder_specific_label(script_runner, 'atlas_brainnetome.nii.gz') atlas_lut = os.path.join(SCILPY_HOME, 'plot', 'atlas_brainnetome.json') - ret = script_runner.run('scil_viz_volume_scatterplot.py', in_x, in_y, - 'scatter_plot', '--in_atlas', in_atlas, - '--atlas_lut', atlas_lut, - '--specific_label', '2', '5', '7', - '--in_folder') + ret = script_runner.run(['scil_viz_volume_scatterplot', in_x, in_y, + 'scatter_plot', '--in_atlas', in_atlas, + '--atlas_lut', atlas_lut, + '--specific_label', '2', '5', '7', + '--in_folder']) assert ret.success diff --git a/scripts/tests/test_viz_volume_screenshot.py b/src/scilpy/cli/tests/test_viz_volume_screenshot.py similarity index 54% rename from scripts/tests/test_viz_volume_screenshot.py rename to src/scilpy/cli/tests/test_viz_volume_screenshot.py index 2c9509e39..af0944915 100644 --- a/scripts/tests/test_viz_volume_screenshot.py +++ b/src/scilpy/cli/tests/test_viz_volume_screenshot.py @@ -12,15 +12,19 @@ tmp_dir = tempfile.TemporaryDirectory() -def test_screenshot(script_runner, monkeypatch): - monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - in_fa = os.path.join(SCILPY_HOME, 'bst', 'fa.nii.gz') - - ret = script_runner.run("scil_viz_volume_screenshot.py", in_fa, 'fa.png', - '--display_slice_number', '--display_lr') +def test_help_option(script_runner): + ret = script_runner.run(["scil_viz_volume_screenshot", "--help"]) assert ret.success -def test_help_option(script_runner): - ret = script_runner.run("scil_viz_volume_screenshot.py", "--help") +def test_screenshot(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + in_fa = os.path.join(SCILPY_HOME, 'bst', 'fa.nii.gz') + in_mask = os.path.join(SCILPY_HOME, 'bst', 'mask.nii.gz') + ret = script_runner.run(["scil_viz_volume_screenshot", in_fa, 'fa.png', + '--slices', '50', + '--display_slice_number', '--display_lr', + '--overlays', in_mask, + '--overlays_as_contours', + '--volume_cmap_name', 'viridis']) assert ret.success diff --git a/src/scilpy/cli/tests/test_viz_volume_screenshot_mosaic.py b/src/scilpy/cli/tests/test_viz_volume_screenshot_mosaic.py new file mode 100644 index 000000000..ab82cd624 --- /dev/null +++ b/src/scilpy/cli/tests/test_viz_volume_screenshot_mosaic.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + + +def test_help_option(script_runner): + ret = script_runner.run(['scil_viz_bundle_screenshot_mni', '--help']) + assert ret.success diff --git a/scripts/tests/test_volume_apply_transform.py b/src/scilpy/cli/tests/test_volume_apply_transform.py similarity index 68% rename from scripts/tests/test_volume_apply_transform.py rename to src/scilpy/cli/tests/test_volume_apply_transform.py index 1b9ba4407..d133f2cbf 100644 --- a/scripts/tests/test_volume_apply_transform.py +++ b/src/scilpy/cli/tests/test_volume_apply_transform.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_volume_apply_transform.py', '--help') + ret = script_runner.run(['scil_volume_apply_transform', '--help']) assert ret.success @@ -25,10 +25,10 @@ def test_execution_bst(script_runner, monkeypatch): 'fa.nii.gz') in_aff = os.path.join(SCILPY_HOME, 'bst', 'output0GenericAffine.mat') - ret = script_runner.run('scil_volume_apply_transform.py', - in_model, in_fa, in_aff, - 'template_lin.nii.gz', '--inverse', - '-f') + ret = script_runner.run(['scil_volume_apply_transform', + in_model, in_fa, in_aff, + 'template_lin.nii.gz', '--inverse', + '-f']) assert ret.success @@ -40,10 +40,10 @@ def test_execution_interp_nearest(script_runner, monkeypatch): 'fa.nii.gz') in_aff = os.path.join(SCILPY_HOME, 'bst', 'output0GenericAffine.mat') - ret = script_runner.run('scil_volume_apply_transform.py', - in_model, in_fa, in_aff, - 'template_lin.nii.gz', '--inverse', - '--interp', 'nearest', '-f') + ret = script_runner.run(['scil_volume_apply_transform', + in_model, in_fa, in_aff, + 'template_lin.nii.gz', '--inverse', + '--interp', 'nearest', '-f']) assert ret.success @@ -55,8 +55,8 @@ def test_execution_interp_lin(script_runner, monkeypatch): 'fa.nii.gz') in_aff = os.path.join(SCILPY_HOME, 'bst', 'output0GenericAffine.mat') - ret = script_runner.run('scil_volume_apply_transform.py', - in_model, in_fa, in_aff, - 'template_lin.nii.gz', '--inverse', - '--interp', 'linear', '-f') + ret = script_runner.run(['scil_volume_apply_transform', + in_model, in_fa, in_aff, + 'template_lin.nii.gz', '--inverse', + '--interp', 'linear', '-f']) assert ret.success diff --git a/scripts/tests/test_volume_b0_synthesis.py b/src/scilpy/cli/tests/test_volume_b0_synthesis.py similarity index 81% rename from scripts/tests/test_volume_b0_synthesis.py rename to src/scilpy/cli/tests/test_volume_b0_synthesis.py index a9c811dc7..216291a5d 100644 --- a/scripts/tests/test_volume_b0_synthesis.py +++ b/src/scilpy/cli/tests/test_volume_b0_synthesis.py @@ -24,7 +24,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_volume_b0_synthesis.py', '--help') + ret = script_runner.run(['scil_volume_b0_synthesis', '--help']) assert ret.success @@ -45,8 +45,8 @@ def test_synthesis(script_runner, monkeypatch): nib.save(nib.Nifti1Image(b0_data.astype(np.uint8), b0_img.affine), 'b0_mask.nii.gz') - ret = script_runner.run('scil_volume_b0_synthesis.py', - in_t1, 't1_mask.nii.gz', - in_b0, 'b0_mask.nii.gz', - 'b0_synthesized.nii.gz', '-v') + ret = script_runner.run(['scil_volume_b0_synthesis', + in_t1, 't1_mask.nii.gz', + in_b0, 'b0_mask.nii.gz', + 'b0_synthesized.nii.gz', '-v']) assert ret.success diff --git a/scripts/tests/test_volume_count_non_zero_voxels.py b/src/scilpy/cli/tests/test_volume_count_non_zero_voxels.py similarity index 67% rename from scripts/tests/test_volume_count_non_zero_voxels.py rename to src/scilpy/cli/tests/test_volume_count_non_zero_voxels.py index cec9c23bc..266491db8 100644 --- a/scripts/tests/test_volume_count_non_zero_voxels.py +++ b/src/scilpy/cli/tests/test_volume_count_non_zero_voxels.py @@ -13,25 +13,25 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_volume_count_non_zero_voxels.py', '--help') + ret = script_runner.run(['scil_volume_count_non_zero_voxels', '--help']) assert ret.success def test_execution_simple_print(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_img = os.path.join(SCILPY_HOME, 'others', 'rgb.nii.gz') - ret = script_runner.run('scil_volume_count_non_zero_voxels.py', in_img) + ret = script_runner.run(['scil_volume_count_non_zero_voxels', in_img]) assert ret.success def test_execution_save_in_file(script_runner): os.chdir(os.path.expanduser(tmp_dir.name)) in_img = os.path.join(SCILPY_HOME, 'others', 'rgb.nii.gz') - ret = script_runner.run('scil_volume_count_non_zero_voxels.py', in_img, - '--out', 'printed.txt') + ret = script_runner.run(['scil_volume_count_non_zero_voxels', in_img, + '--out', 'printed.txt']) assert ret.success # Then re-use the same out file with --stats - ret = script_runner.run('scil_volume_count_non_zero_voxels.py', in_img, - '--out', 'printed.txt', '--stats') + ret = script_runner.run(['scil_volume_count_non_zero_voxels', in_img, + '--out', 'printed.txt', '--stats']) assert ret.success diff --git a/scripts/tests/test_volume_crop.py b/src/scilpy/cli/tests/test_volume_crop.py similarity index 66% rename from scripts/tests/test_volume_crop.py rename to src/scilpy/cli/tests/test_volume_crop.py index 9d3066726..a56a1c490 100644 --- a/scripts/tests/test_volume_crop.py +++ b/src/scilpy/cli/tests/test_volume_crop.py @@ -13,18 +13,18 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_volume_crop.py', '--help') + ret = script_runner.run(['scil_volume_crop', '--help']) assert ret.success def test_execution_processing(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_dwi = os.path.join(SCILPY_HOME, 'processing', 'dwi.nii.gz') - ret = script_runner.run('scil_volume_crop.py', in_dwi, 'dwi_crop.nii.gz', - '--output_bbox', 'bbox.json') + ret = script_runner.run(['scil_volume_crop', in_dwi, 'dwi_crop.nii.gz', + '--output_bbox', 'bbox.json']) assert ret.success # Then try to load back the same box - ret = script_runner.run('scil_volume_crop.py', in_dwi, 'dwi_crop2.nii.gz', - '--input_bbox', 'bbox.json') + ret = script_runner.run(['scil_volume_crop', in_dwi, 'dwi_crop2.nii.gz', + '--input_bbox', 'bbox.json']) assert ret.success diff --git a/scripts/tests/test_volume_distance_map.py b/src/scilpy/cli/tests/test_volume_distance_map.py similarity index 81% rename from scripts/tests/test_volume_distance_map.py rename to src/scilpy/cli/tests/test_volume_distance_map.py index ed5802019..078909bec 100644 --- a/scripts/tests/test_volume_distance_map.py +++ b/src/scilpy/cli/tests/test_volume_distance_map.py @@ -15,7 +15,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_volume_distance_map.py', '--help') + ret = script_runner.run(['scil_volume_distance_map', '--help']) assert ret.success @@ -27,9 +27,9 @@ def test_execution(script_runner, monkeypatch): in_mask_2 = os.path.join(SCILPY_HOME, 'tractograms', 'streamline_and_mask_operations', 'bundle_4_center.nii.gz') - ret = script_runner.run('scil_volume_distance_map.py', - in_mask_1, in_mask_2, - 'distance_map.nii.gz') + ret = script_runner.run(['scil_volume_distance_map', + in_mask_1, in_mask_2, + 'distance_map.nii.gz']) img = nib.load('distance_map.nii.gz') data = img.get_fdata() diff --git a/scripts/tests/test_volume_flip.py b/src/scilpy/cli/tests/test_volume_flip.py similarity index 79% rename from scripts/tests/test_volume_flip.py rename to src/scilpy/cli/tests/test_volume_flip.py index 2f6a57e53..4eb836c42 100644 --- a/scripts/tests/test_volume_flip.py +++ b/src/scilpy/cli/tests/test_volume_flip.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_volume_flip.py', '--help') + ret = script_runner.run(['scil_volume_flip', '--help']) assert ret.success @@ -21,6 +21,6 @@ def test_execution_surface_vtk_fib(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_fa = os.path.join(SCILPY_HOME, 'surface_vtk_fib', 'fa.nii.gz') - ret = script_runner.run('scil_volume_flip.py', in_fa, 'fa_flip.nii.gz', - 'x') + ret = script_runner.run(['scil_volume_flip', in_fa, 'fa_flip.nii.gz', + 'x']) assert ret.success diff --git a/scripts/tests/test_volume_math.py b/src/scilpy/cli/tests/test_volume_math.py similarity index 72% rename from scripts/tests/test_volume_math.py rename to src/scilpy/cli/tests/test_volume_math.py index 6631a749f..22efdcd98 100644 --- a/scripts/tests/test_volume_math.py +++ b/src/scilpy/cli/tests/test_volume_math.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_volume_math.py', '--help') + ret = script_runner.run(['scil_volume_math', '--help']) assert ret.success @@ -25,24 +25,24 @@ def test_execution_add(script_runner, monkeypatch): 'brainstem_174.nii.gz') in_img_3 = os.path.join(SCILPY_HOME, 'atlas', 'brainstem_175.nii.gz') - ret = script_runner.run('scil_volume_math.py', 'addition', - in_img_1, in_img_2, in_img_3, 'brainstem.nii.gz') + ret = script_runner.run(['scil_volume_math', 'addition', + in_img_1, in_img_2, in_img_3, 'brainstem.nii.gz']) assert ret.success def test_execution_low_thresh(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_img = os.path.join(SCILPY_HOME, 'atlas', 'brainstem.nii.gz') - ret = script_runner.run('scil_volume_math.py', 'lower_threshold', - in_img, '1', 'brainstem_bin.nii.gz') + ret = script_runner.run(['scil_volume_math', 'lower_threshold', + in_img, '1', 'brainstem_bin.nii.gz']) assert ret.success def test_execution_low_mult(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_img = os.path.join(SCILPY_HOME, 'atlas', 'brainstem_bin.nii.gz') - ret = script_runner.run('scil_volume_math.py', 'multiplication', - in_img, '16', 'brainstem_unified.nii.gz') + ret = script_runner.run(['scil_volume_math', 'multiplication', + in_img, '16', 'brainstem_unified.nii.gz']) assert ret.success @@ -54,9 +54,9 @@ def test_execution_concatenate(script_runner, monkeypatch): in_img_4 = os.path.join(SCILPY_HOME, 'atlas', 'ids', '13.nii.gz') in_img_5 = os.path.join(SCILPY_HOME, 'atlas', 'ids', '17.nii.gz') in_img_6 = os.path.join(SCILPY_HOME, 'atlas', 'ids', '18.nii.gz') - ret = script_runner.run('scil_volume_math.py', 'concatenate', - in_img_1, in_img_2, in_img_3, in_img_4, in_img_5, - in_img_6, 'concat_ids.nii.gz') + ret = script_runner.run(['scil_volume_math', 'concatenate', + in_img_1, in_img_2, in_img_3, in_img_4, in_img_5, + in_img_6, 'concat_ids.nii.gz']) assert ret.success @@ -66,7 +66,7 @@ def test_execution_concatenate_4D(script_runner, monkeypatch): in_img_2 = os.path.join(SCILPY_HOME, 'atlas', 'ids', '8_10.nii.gz') in_img_3 = os.path.join(SCILPY_HOME, 'atlas', 'ids', '12.nii.gz') in_img_4 = os.path.join(SCILPY_HOME, 'atlas', 'ids', '8_10.nii.gz') - ret = script_runner.run('scil_volume_math.py', 'concatenate', - in_img_1, in_img_2, in_img_3, in_img_4, - 'concat_ids_4d.nii.gz') + ret = script_runner.run(['scil_volume_math', 'concatenate', + in_img_1, in_img_2, in_img_3, in_img_4, + 'concat_ids_4d.nii.gz']) assert ret.success diff --git a/scripts/tests/test_volume_pairwise_comparison.py b/src/scilpy/cli/tests/test_volume_pairwise_comparison.py similarity index 76% rename from scripts/tests/test_volume_pairwise_comparison.py rename to src/scilpy/cli/tests/test_volume_pairwise_comparison.py index bb61d3ea2..07bcc238c 100644 --- a/scripts/tests/test_volume_pairwise_comparison.py +++ b/src/scilpy/cli/tests/test_volume_pairwise_comparison.py @@ -15,7 +15,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_volume_pairwise_comparison.py', '--help') + ret = script_runner.run(['scil_volume_pairwise_comparison', '--help']) assert ret.success @@ -26,8 +26,8 @@ def test_label_comparison(script_runner, monkeypatch): in_atlas_dilated = os.path.join( SCILPY_HOME, 'atlas', 'atlas_freesurfer_v2_single_brainstem_dil.nii.gz') - ret = script_runner.run('scil_volume_pairwise_comparison.py', - in_atlas, in_atlas_dilated, 'atlas.json') + ret = script_runner.run(['scil_volume_pairwise_comparison', + in_atlas, in_atlas_dilated, 'atlas.json']) assert ret.success @@ -40,8 +40,8 @@ def test_binary_comparison(script_runner, monkeypatch): 'streamline_and_mask_operations', 'bundle_4_head_tail_offset.nii.gz') - ret = script_runner.run('scil_volume_pairwise_comparison.py', - in_bin_1, in_bin_2, 'binary.json') + ret = script_runner.run(['scil_volume_pairwise_comparison', + in_bin_1, in_bin_2, 'binary.json']) assert ret.success @@ -58,8 +58,8 @@ def test_multiple_compare(script_runner, monkeypatch): 'streamline_and_mask_operations', 'bundle_4_center.nii.gz') - ret = script_runner.run('scil_volume_pairwise_comparison.py', - in_bin_1, in_bin_2, in_bin_3, 'multiple.json') + ret = script_runner.run(['scil_volume_pairwise_comparison', + in_bin_1, in_bin_2, in_bin_3, 'multiple.json']) assert ret.success @@ -76,9 +76,9 @@ def test_single_compare(script_runner, monkeypatch): 'streamline_and_mask_operations', 'bundle_4_center.nii.gz') - ret = script_runner.run('scil_volume_pairwise_comparison.py', - in_bin_1, in_bin_2, 'single.json', - '--single_compare', in_bin_3) + ret = script_runner.run(['scil_volume_pairwise_comparison', + in_bin_1, in_bin_2, 'single.json', + '--single_compare', in_bin_3]) assert ret.success @@ -95,10 +95,10 @@ def test_ratio_compare(script_runner, monkeypatch): 'streamline_and_mask_operations', 'bundle_4_center.nii.gz') - ret = script_runner.run('scil_volume_pairwise_comparison.py', - in_bin_1, in_bin_2, 'ratio.json', - '--single_compare', in_bin_3, - '--ratio') + ret = script_runner.run(['scil_volume_pairwise_comparison', + in_bin_1, in_bin_2, 'ratio.json', + '--single_compare', in_bin_3, + '--ratio']) assert ret.success @@ -109,8 +109,8 @@ def test_labels_to_mask_compare(script_runner, monkeypatch): in_mask = os.path.join( SCILPY_HOME, 'atlas', 'brainstem_bin.nii.gz') - ret = script_runner.run('scil_volume_pairwise_comparison.py', - in_atlas, 'labels_to_maskjson', - '--single_compare', in_mask, - '--labels_to_mask') + ret = script_runner.run(['scil_volume_pairwise_comparison', + in_atlas, 'labels_to_maskjson', + '--single_compare', in_mask, + '--labels_to_mask']) assert ret.success diff --git a/scripts/tests/test_volume_remove_outliers_ransac.py b/src/scilpy/cli/tests/test_volume_remove_outliers_ransac.py similarity index 75% rename from scripts/tests/test_volume_remove_outliers_ransac.py rename to src/scilpy/cli/tests/test_volume_remove_outliers_ransac.py index 834442f86..b91be68bd 100644 --- a/scripts/tests/test_volume_remove_outliers_ransac.py +++ b/src/scilpy/cli/tests/test_volume_remove_outliers_ransac.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_volume_remove_outliers_ransac.py', '--help') + ret = script_runner.run(['scil_volume_remove_outliers_ransac', '--help']) assert ret.success @@ -21,6 +21,6 @@ def test_execution_processing(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_ad = os.path.join(SCILPY_HOME, 'processing', 'ad.nii.gz') - ret = script_runner.run('scil_volume_remove_outliers_ransac.py', in_ad, - 'ad_ransanc.nii.gz') + ret = script_runner.run(['scil_volume_remove_outliers_ransac', in_ad, + 'ad_ransanc.nii.gz']) assert ret.success diff --git a/scripts/tests/test_volume_resample.py b/src/scilpy/cli/tests/test_volume_resample.py similarity index 62% rename from scripts/tests/test_volume_resample.py rename to src/scilpy/cli/tests/test_volume_resample.py index 9133e5dbe..06e978550 100644 --- a/scripts/tests/test_volume_resample.py +++ b/src/scilpy/cli/tests/test_volume_resample.py @@ -14,37 +14,37 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_volume_resample.py', '--help') + ret = script_runner.run(['scil_volume_resample', '--help']) assert ret.success def test_execution_given_size(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_volume_resample.py', in_img, - 'fa_resample_2.nii.gz', '--voxel_size', '2') + ret = script_runner.run(['scil_volume_resample', in_img, + 'fa_resample_2.nii.gz', '--voxel_size', '2']) assert ret.success def test_execution_force_voxel(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_volume_resample.py', in_img, - 'fa_resample_4.nii.gz', '--voxel_size', '4', - '--enforce_voxel_size') + ret = script_runner.run(['scil_volume_resample', in_img, + 'fa_resample_4.nii.gz', '--voxel_size', '4', + '--enforce_voxel_size']) assert ret.success def test_execution_ref(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) ref = os.path.join(SCILPY_HOME, 'others', 'fa_resample.nii.gz') - ret = script_runner.run('scil_volume_resample.py', in_img, - 'fa_resample2.nii.gz', '--ref', ref) + ret = script_runner.run(['scil_volume_resample', in_img, + 'fa_resample2.nii.gz', '--ref', ref]) assert ret.success def test_execution_ref_force(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) ref = os.path.join(SCILPY_HOME, 'others', 'fa_resample.nii.gz') - ret = script_runner.run('scil_volume_resample.py', in_img, - 'fa_resample_ref.nii.gz', '--ref', ref, - '--enforce_dimensions') + ret = script_runner.run(['scil_volume_resample', in_img, + 'fa_resample_ref.nii.gz', '--ref', ref, + '--enforce_dimensions']) assert ret.success diff --git a/scripts/tests/test_volume_reshape.py b/src/scilpy/cli/tests/test_volume_reshape.py similarity index 56% rename from scripts/tests/test_volume_reshape.py rename to src/scilpy/cli/tests/test_volume_reshape.py index 0fab76ee8..0b9bbde6e 100644 --- a/scripts/tests/test_volume_reshape.py +++ b/src/scilpy/cli/tests/test_volume_reshape.py @@ -15,46 +15,46 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_volume_reshape.py', '--help') + ret = script_runner.run(['scil_volume_reshape', '--help']) assert ret.success def test_execution_crop(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_volume_reshape.py', in_img, - 'fa_reshape.nii.gz', '--volume_size', '90', - '-f') + ret = script_runner.run(['scil_volume_reshape', in_img, + 'fa_reshape.nii.gz', '--volume_size', '90', + '-f']) assert ret.success def test_execution_pad(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_volume_reshape.py', in_img, - 'fa_reshape.nii.gz', '--volume_size', '150', - '-f') + ret = script_runner.run(['scil_volume_reshape', in_img, + 'fa_reshape.nii.gz', '--volume_size', '150', + '-f']) assert ret.success def test_execution_full_size(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_volume_reshape.py', in_img, - 'fa_reshape.nii.gz', '--volume_size', - '164', '164', '164', '-f') + ret = script_runner.run(['scil_volume_reshape', in_img, + 'fa_reshape.nii.gz', '--volume_size', + '164', '164', '164', '-f']) assert ret.success def test_execution_dtype(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) - ret = script_runner.run('scil_volume_reshape.py', in_img, - 'fa_reshape.nii.gz', '--volume_size', - '111', '133', '109', '--data_type', - 'uint8', '-f') + ret = script_runner.run(['scil_volume_reshape', in_img, + 'fa_reshape.nii.gz', '--volume_size', + '111', '133', '109', '--data_type', + 'uint8', '-f']) assert ret.success def test_execution_ref(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) ref = os.path.join(SCILPY_HOME, 'others', 'fa_resample.nii.gz') - ret = script_runner.run('scil_volume_reshape.py', in_img, - 'fa_reshape.nii.gz', '--ref', ref, '-f') + ret = script_runner.run(['scil_volume_reshape', in_img, + 'fa_reshape.nii.gz', '--ref', ref, '-f']) assert ret.success diff --git a/scripts/tests/test_volume_reslice_to_reference.py b/src/scilpy/cli/tests/test_volume_reslice_to_reference.py similarity index 67% rename from scripts/tests/test_volume_reslice_to_reference.py rename to src/scilpy/cli/tests/test_volume_reslice_to_reference.py index 9c62c48f0..724981600 100644 --- a/scripts/tests/test_volume_reslice_to_reference.py +++ b/src/scilpy/cli/tests/test_volume_reslice_to_reference.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_volume_reslice_to_reference.py', '--help') + ret = script_runner.run(['scil_volume_reslice_to_reference', '--help']) assert ret.success @@ -21,9 +21,9 @@ def test_execution_others(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_img = os.path.join(SCILPY_HOME, 'others', 't1_crop.nii.gz') in_ref = os.path.join(SCILPY_HOME, 'others', 't1.nii.gz') - ret = script_runner.run('scil_volume_reslice_to_reference.py', in_img, - in_ref, 't1_reslice.nii.gz', - '--interpolation', 'nearest') + ret = script_runner.run(['scil_volume_reslice_to_reference', in_img, + in_ref, 't1_reslice.nii.gz', + '--interpolation', 'nearest']) assert ret.success @@ -31,7 +31,7 @@ def test_execution_4D(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) in_img = os.path.join(SCILPY_HOME, 'commit_amico', 'dwi.nii.gz') in_ref = os.path.join(SCILPY_HOME, 'others', 't1.nii.gz') - ret = script_runner.run('scil_volume_reslice_to_reference.py', in_img, - in_ref, 'dwi_reslice.nii.gz', - '--interpolation', 'nearest') + ret = script_runner.run(['scil_volume_reslice_to_reference', in_img, + in_ref, 'dwi_reslice.nii.gz', + '--interpolation', 'nearest']) assert ret.success diff --git a/scripts/tests/test_volume_stats_in_ROI.py b/src/scilpy/cli/tests/test_volume_stats_in_ROI.py similarity index 61% rename from scripts/tests/test_volume_stats_in_ROI.py rename to src/scilpy/cli/tests/test_volume_stats_in_ROI.py index c03593858..d4d9297fc 100644 --- a/scripts/tests/test_volume_stats_in_ROI.py +++ b/src/scilpy/cli/tests/test_volume_stats_in_ROI.py @@ -13,7 +13,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_volume_stats_in_ROI.py', '--help') + ret = script_runner.run(['scil_volume_stats_in_ROI', '--help']) assert ret.success @@ -25,28 +25,28 @@ def test_execution_tractometry(script_runner, monkeypatch): 'mni_masked.nii.gz') # Test with a single ROI input - ret = script_runner.run('scil_volume_stats_in_ROI.py', - in_roi, '--metrics', in_ref) + ret = script_runner.run(['scil_volume_stats_in_ROI', + in_roi, '--metrics', in_ref]) assert ret.success # Test with multiple ROIs input - ret = script_runner.run('scil_volume_stats_in_ROI.py', - in_roi, in_roi, in_roi, '--metrics', in_ref) + ret = script_runner.run(['scil_volume_stats_in_ROI', + in_roi, in_roi, in_roi, '--metrics', in_ref]) assert ret.success # Test with multiple metric input - ret = script_runner.run('scil_volume_stats_in_ROI.py', - in_roi, '--metrics', in_ref, in_ref, in_ref) + ret = script_runner.run(['scil_volume_stats_in_ROI', + in_roi, '--metrics', in_ref, in_ref, in_ref]) assert ret.success # Test with multiple metric and ROIs input - ret = script_runner.run('scil_volume_stats_in_ROI.py', - in_roi, in_roi, '--metrics', in_ref, in_ref) + ret = script_runner.run(['scil_volume_stats_in_ROI', + in_roi, in_roi, '--metrics', in_ref, in_ref]) assert ret.success # Test with a metric folder metrics_dir = os.path.join(SCILPY_HOME, 'plot') in_roi = os.path.join(SCILPY_HOME, 'plot', 'mask_wm.nii.gz') - ret = script_runner.run('scil_volume_stats_in_ROI.py', - in_roi, '--metrics_dir', metrics_dir) + ret = script_runner.run(['scil_volume_stats_in_ROI', + in_roi, '--metrics_dir', metrics_dir]) assert ret.success diff --git a/scripts/tests/test_volume_stats_in_labels.py b/src/scilpy/cli/tests/test_volume_stats_in_labels.py similarity index 60% rename from scripts/tests/test_volume_stats_in_labels.py rename to src/scilpy/cli/tests/test_volume_stats_in_labels.py index 4a4471384..415fe023d 100644 --- a/scripts/tests/test_volume_stats_in_labels.py +++ b/src/scilpy/cli/tests/test_volume_stats_in_labels.py @@ -11,7 +11,7 @@ def test_help_option(script_runner): - ret = script_runner.run('scil_volume_stats_in_labels.py', '--help') + ret = script_runner.run(['scil_volume_stats_in_labels', '--help']) assert ret.success @@ -22,19 +22,19 @@ def test_execution(script_runner, monkeypatch): atlas_lut = os.path.join(SCILPY_HOME, 'plot', 'atlas_brainnetome.json') # Test with a single metric - ret = script_runner.run('scil_volume_stats_in_labels.py', - in_atlas, atlas_lut, "--metrics", in_metric) + ret = script_runner.run(['scil_volume_stats_in_labels', + in_atlas, atlas_lut, "--metrics", in_metric]) assert ret.success # Test with multiple metrics - ret = script_runner.run('scil_volume_stats_in_labels.py', - in_atlas, atlas_lut, "--metrics", - in_metric, in_metric, in_metric) + ret = script_runner.run(['scil_volume_stats_in_labels', + in_atlas, atlas_lut, "--metrics", + in_metric, in_metric, in_metric]) assert ret.success # Test with a metric folder metrics_dir = os.path.join(SCILPY_HOME, 'plot') - ret = script_runner.run('scil_volume_stats_in_labels.py', - in_atlas, atlas_lut, "--metrics_dir", - metrics_dir) + ret = script_runner.run(['scil_volume_stats_in_labels', + in_atlas, atlas_lut, "--metrics_dir", + metrics_dir]) assert ret.success diff --git a/scilpy/dwi/__init__.py b/src/scilpy/connectivity/__init__.py similarity index 100% rename from scilpy/dwi/__init__.py rename to src/scilpy/connectivity/__init__.py diff --git a/scilpy/connectivity/connectivity.py b/src/scilpy/connectivity/connectivity.py similarity index 93% rename from scilpy/connectivity/connectivity.py rename to src/scilpy/connectivity/connectivity.py index 11ed51a39..844fa10cd 100644 --- a/scilpy/connectivity/connectivity.py +++ b/src/scilpy/connectivity/connectivity.py @@ -5,7 +5,7 @@ from dipy.io.stateful_tractogram import StatefulTractogram from dipy.io.utils import is_header_compatible, get_reference_info -from dipy.tracking.streamlinespeed import length +from dipy.tracking.streamlinespeed import length, set_number_of_points from dipy.tracking.vox2track import _streamlines_in_mask import h5py import nibabel as nib @@ -38,7 +38,7 @@ def compute_triu_connectivity_from_labels(tractogram, data_labels, When using directly with a list of streamlines, streamlines must be in vox space, center origin. data_labels: np.ndarray - The loaded nifti image. + The loaded nifti image. Must be 3D. keep_background: Bool By default, the background (label 0) is not included in the matrix. If True, label 0 is kept. @@ -66,25 +66,30 @@ def compute_triu_connectivity_from_labels(tractogram, data_labels, streamlines = sfs_2_pts.streamlines else: - streamlines = tractogram + # Using directly on streamlines, no SFT. Usually not recommended, + # useful for dwi_ml methods. Calling directly dipy's resampling. + streamlines = nib.streamlines.ArraySequence(tractogram) + streamlines = set_number_of_points(streamlines, 2) ordered_labels = list(np.sort(np.unique(data_labels))) - assert ordered_labels[0] >= 0, "Only accepting positive labels." + assert ordered_labels[0] >= 0, "Only accepting positive labels, or 0." nb_labels = len(ordered_labels) logging.debug("Computing connectivity matrix for {} labels." .format(nb_labels)) matrix = np.zeros((nb_labels, nb_labels), dtype=int) - - labels = map_coordinates(data_labels, streamlines._data.T, order=0) + labels = map_coordinates(data_labels, streamlines._data.T, order=0, + mode='nearest') start_labels = labels[0::2] end_labels = labels[1::2] # sort each pair of labels for start to be smaller than end start_labels, end_labels = zip(*[sorted(pair) for pair in zip(start_labels, end_labels)]) - - np.add.at(matrix, (start_labels, end_labels), 1) + ordered_labels = list(ordered_labels) + start_index = [ordered_labels.index(label) for label in start_labels] + end_index = [ordered_labels.index(label) for label in end_labels] + np.add.at(matrix, (start_index, end_index), 1) assert matrix.sum() == len(streamlines) # Rejecting background @@ -117,7 +122,7 @@ def compute_triu_connectivity_from_labels(tractogram, data_labels, return matrix, ordered_labels, start_labels, end_labels -def load_node_nifti(directory, in_label, out_label, ref_img): +def _load_node_nifti(directory, in_label, out_label, ref_img): in_filename = os.path.join(directory, '{}_{}.nii.gz'.format(in_label, out_label)) @@ -252,8 +257,8 @@ def compute_connectivity_matrices_from_hdf5( measures_to_return['streamline_count'] = len(streamlines) if similarity_directory is not None: - density_sim = load_node_nifti(similarity_directory, - in_label, out_label, labels_img) + density_sim = _load_node_nifti(similarity_directory, + in_label, out_label, labels_img) if density_sim is None: ba_vox = 0 else: diff --git a/scilpy/connectivity/matrix_tools.py b/src/scilpy/connectivity/matrix_tools.py similarity index 93% rename from scilpy/connectivity/matrix_tools.py rename to src/scilpy/connectivity/matrix_tools.py index 11a962a40..1c7de862b 100644 --- a/scilpy/connectivity/matrix_tools.py +++ b/src/scilpy/connectivity/matrix_tools.py @@ -43,27 +43,6 @@ def compute_olo(array): return perm -def apply_olo(array, perm): - """ - Apply the permutation from compute_RCM. - - Parameters - ---------- - array: ndarray (NxN) - Sparse connectivity matrix. - perm: ndarray (N,) - Permutations for rows and columns to be applied. - - Returns - ------- - ndarray (N,N) - Reordered array. - """ - if array.ndim != 2: - raise ValueError('RCM can only be applied to 2D array.') - return array[perm].T[perm] - - def apply_reordering(array, ordering): """ Apply a non-symmetric array ordering that support non-square output. @@ -101,12 +80,12 @@ def apply_reordering(array, ordering): def evaluate_graph_measures(conn_matrix, len_matrix, avg_node_wise, small_world): """ - toDo Finish docstring - Parameters ---------- - conn_matrix: np.ndarray of shape ?? - len_matrix: np.ndarray of shape ?? + conn_matrix: np.ndarray + 2D matrix of connectivity weights. Typicaly a streamline count matrix. + len_matrix: np.ndarray + 2D matrix of bundle lengths. avg_node_wise: bool If true, return a single value for node-wise measures. small_world: bool diff --git a/src/scilpy/connectivity/tests/test_connectivity.py b/src/scilpy/connectivity/tests/test_connectivity.py new file mode 100644 index 000000000..d8c04d283 --- /dev/null +++ b/src/scilpy/connectivity/tests/test_connectivity.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +import numpy as np + +from scilpy.connectivity.connectivity import \ + compute_triu_connectivity_from_labels + + +def test_compute_triu_connectivity_from_labels(): + labels = np.asarray([[3, 4, 5, 6], + [7, 8, 9, 10], + [11, 12, 13, 14]]) + labels = labels[:, :, None] + labels = np.concatenate([labels, labels, labels], axis=-1) + # Data shape: (3, 4, 3) + + # vox space, center origin + # streamline 1 : Easy (middle voxel). + # starts at voxel (1, 1, 1) = label 8, + # ends at voxel (1.1, 0.8, 1.1) = label 8. + # streamline 2: Border management, center of the voxel + # starts at voxel (0, 1, 0) = label 4 + # ends at voxel (2, 0, 0) = label 11 + # streamline 3: Idem, but not in the center (vox, center) + tractogram = [np.asarray([[1.0, 1.0, 1.0], + [5.0, 6.1, 10.1], + [1.1, 0.8, 1.1]]), + np.asarray([[0.0, 1.0, 0.0], + [2.0, 0.0, 0.0]]), + np.asarray([[-0.3, 0.8, -0.2], + [2.1, 0.3, -0.2]])] + output, _, _, _ = compute_triu_connectivity_from_labels( + tractogram, labels) + + assert np.array_equal(output.shape, [12, 12]) # 12 labels + expected_out = np.zeros((12, 12)) + expected_out[5, 5] = 1 # One streamline with label (8, 8) => [5, 5] + expected_out[1, 8] = 2 # Two streamlines with label (4, 11) = [1, 8] + assert np.array_equal(output, expected_out) + + +def test_compute_connectivity_matrices_from_hdf5(): + # ToDo. We will have to create a test hdf5. + pass diff --git a/src/scilpy/connectivity/tests/test_matrix_tools.py b/src/scilpy/connectivity/tests/test_matrix_tools.py new file mode 100644 index 000000000..7a4fbdb88 --- /dev/null +++ b/src/scilpy/connectivity/tests/test_matrix_tools.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +import numpy as np + +from scilpy.connectivity.matrix_tools import apply_reordering + + +def test_compute_olo(): + # Simple and basically only using hierarchy's function. Not testing. + pass + + +def test_apply_reordering(): + conn_matrix = np.asarray([[1, 2, 3, 4], + [5, 6, 7, 8], + [9, 10, 11, 12], + [13, 14, 15, 16]]) + output = apply_reordering(conn_matrix, [[0, 1, 3, 2], + [1, 2, 3, 0]]) + + # Changing rows 2 and 3 + permuting columns + expected_out = np.asarray([[2, 3, 4, 1], + [6, 7, 8, 5], + [14, 15, 16, 13], + [10, 11, 12, 9]]) + assert np.array_equal(output, expected_out) + + +def test_evaluate_graph_measures(): + pass + + +def test_normalize_matrix_from_values(): + pass + + +def test_normalize_matrix_from_parcel(): + pass diff --git a/data/LUT/dk_aggregate_structures.json b/src/scilpy/data/LUT/dk_aggregate_structures.json similarity index 100% rename from data/LUT/dk_aggregate_structures.json rename to src/scilpy/data/LUT/dk_aggregate_structures.json diff --git a/data/LUT/freesurfer_desikan_killiany.json b/src/scilpy/data/LUT/freesurfer_desikan_killiany.json similarity index 100% rename from data/LUT/freesurfer_desikan_killiany.json rename to src/scilpy/data/LUT/freesurfer_desikan_killiany.json diff --git a/data/LUT/freesurfer_subcortical.json b/src/scilpy/data/LUT/freesurfer_subcortical.json similarity index 100% rename from data/LUT/freesurfer_subcortical.json rename to src/scilpy/data/LUT/freesurfer_subcortical.json diff --git a/scilpy/dwi/tests/__init__.py b/src/scilpy/data/__init__.py similarity index 100% rename from scilpy/dwi/tests/__init__.py rename to src/scilpy/data/__init__.py diff --git a/data/mni_icbm152_t1_tal_nlin_asym_09c_masked_2_5.nii.gz b/src/scilpy/data/mni_icbm152_t1_tal_nlin_asym_09c_masked_2_5.nii.gz similarity index 100% rename from data/mni_icbm152_t1_tal_nlin_asym_09c_masked_2_5.nii.gz rename to src/scilpy/data/mni_icbm152_t1_tal_nlin_asym_09c_masked_2_5.nii.gz diff --git a/data/vocabulary.json b/src/scilpy/data/vocabulary.json similarity index 100% rename from data/vocabulary.json rename to src/scilpy/data/vocabulary.json diff --git a/scilpy/gpuparallel/__init__.py b/src/scilpy/denoise/__init__.py similarity index 100% rename from scilpy/gpuparallel/__init__.py rename to src/scilpy/denoise/__init__.py diff --git a/scilpy/denoise/aodf_filter.cl b/src/scilpy/denoise/aodf_filter.cl similarity index 100% rename from scilpy/denoise/aodf_filter.cl rename to src/scilpy/denoise/aodf_filter.cl diff --git a/scilpy/denoise/asym_filtering.py b/src/scilpy/denoise/asym_filtering.py similarity index 100% rename from scilpy/denoise/asym_filtering.py rename to src/scilpy/denoise/asym_filtering.py diff --git a/scilpy/denoise/tests/test_asym_filtering.py b/src/scilpy/denoise/tests/test_asym_filtering.py similarity index 100% rename from scilpy/denoise/tests/test_asym_filtering.py rename to src/scilpy/denoise/tests/test_asym_filtering.py diff --git a/scilpy/gradients/__init__.py b/src/scilpy/dwi/__init__.py similarity index 100% rename from scilpy/gradients/__init__.py rename to src/scilpy/dwi/__init__.py diff --git a/scilpy/dwi/operations.py b/src/scilpy/dwi/operations.py similarity index 100% rename from scilpy/dwi/operations.py rename to src/scilpy/dwi/operations.py diff --git a/scilpy/image/__init__.py b/src/scilpy/dwi/tests/__init__.py similarity index 100% rename from scilpy/image/__init__.py rename to src/scilpy/dwi/tests/__init__.py diff --git a/scilpy/dwi/tests/test_operations.py b/src/scilpy/dwi/tests/test_operations.py similarity index 100% rename from scilpy/dwi/tests/test_operations.py rename to src/scilpy/dwi/tests/test_operations.py diff --git a/scilpy/dwi/tests/test_utils.py b/src/scilpy/dwi/tests/test_utils.py similarity index 100% rename from scilpy/dwi/tests/test_utils.py rename to src/scilpy/dwi/tests/test_utils.py diff --git a/scilpy/dwi/utils.py b/src/scilpy/dwi/utils.py similarity index 100% rename from scilpy/dwi/utils.py rename to src/scilpy/dwi/utils.py diff --git a/scilpy/image/tests/__init__.py b/src/scilpy/gpuparallel/__init__.py similarity index 100% rename from scilpy/image/tests/__init__.py rename to src/scilpy/gpuparallel/__init__.py diff --git a/scilpy/gpuparallel/opencl_utils.py b/src/scilpy/gpuparallel/opencl_utils.py similarity index 100% rename from scilpy/gpuparallel/opencl_utils.py rename to src/scilpy/gpuparallel/opencl_utils.py diff --git a/scilpy/io/__init__.py b/src/scilpy/gradients/__init__.py similarity index 100% rename from scilpy/io/__init__.py rename to src/scilpy/gradients/__init__.py diff --git a/scilpy/gradients/bvec_bval_tools.py b/src/scilpy/gradients/bvec_bval_tools.py similarity index 100% rename from scilpy/gradients/bvec_bval_tools.py rename to src/scilpy/gradients/bvec_bval_tools.py diff --git a/scilpy/gradients/gen_gradient_sampling.py b/src/scilpy/gradients/gen_gradient_sampling.py similarity index 100% rename from scilpy/gradients/gen_gradient_sampling.py rename to src/scilpy/gradients/gen_gradient_sampling.py diff --git a/scilpy/gradients/optimize_gradient_sampling.py b/src/scilpy/gradients/optimize_gradient_sampling.py similarity index 100% rename from scilpy/gradients/optimize_gradient_sampling.py rename to src/scilpy/gradients/optimize_gradient_sampling.py diff --git a/scilpy/gradients/tests/test_bvec_bval_tools.py b/src/scilpy/gradients/tests/test_bvec_bval_tools.py similarity index 100% rename from scilpy/gradients/tests/test_bvec_bval_tools.py rename to src/scilpy/gradients/tests/test_bvec_bval_tools.py diff --git a/scilpy/gradients/tests/test_gen_gradient_sampling.py b/src/scilpy/gradients/tests/test_gen_gradient_sampling.py similarity index 100% rename from scilpy/gradients/tests/test_gen_gradient_sampling.py rename to src/scilpy/gradients/tests/test_gen_gradient_sampling.py diff --git a/scilpy/gradients/tests/test_gradients_utils.py b/src/scilpy/gradients/tests/test_gradients_utils.py similarity index 100% rename from scilpy/gradients/tests/test_gradients_utils.py rename to src/scilpy/gradients/tests/test_gradients_utils.py diff --git a/scilpy/gradients/tests/test_optimize_gradient_sampling.py b/src/scilpy/gradients/tests/test_optimize_gradient_sampling.py similarity index 100% rename from scilpy/gradients/tests/test_optimize_gradient_sampling.py rename to src/scilpy/gradients/tests/test_optimize_gradient_sampling.py diff --git a/scilpy/gradients/utils.py b/src/scilpy/gradients/utils.py similarity index 100% rename from scilpy/gradients/utils.py rename to src/scilpy/gradients/utils.py diff --git a/scilpy/ml/__init__.py b/src/scilpy/image/__init__.py similarity index 100% rename from scilpy/ml/__init__.py rename to src/scilpy/image/__init__.py diff --git a/scilpy/image/labels.py b/src/scilpy/image/labels.py similarity index 75% rename from scilpy/image/labels.py rename to src/scilpy/image/labels.py index 98b97a989..88256e7fc 100644 --- a/scilpy/image/labels.py +++ b/src/scilpy/image/labels.py @@ -1,22 +1,25 @@ # -*- coding: utf-8 -*- -import importlib.resources as resources -import inspect +from importlib.resources import files import json import logging import os +import tqdm import numpy as np from scipy import ndimage as ndi from scipy.spatial import cKDTree +from scilpy.tractanalysis.reproducibility_measures import compute_bundle_adjacency_voxel + +SCILPY_LUT_DIR = files("scilpy").joinpath("data/LUT/") + def load_wmparc_labels(): """ Load labels dictionary of different parcellations from the Desikan-Killiany atlas. """ - lut_package = resources.files('data').joinpath('LUT') - labels_path = lut_package.joinpath('dk_aggregate_structures.json') + labels_path = SCILPY_LUT_DIR.joinpath('dk_aggregate_structures.json') with open(labels_path) as labels_file: labels = json.load(labels_file) return labels @@ -146,25 +149,6 @@ def get_labels_from_mask(mask_data, labels=None, background_label=0, return label_map -def get_lut_dir(): - """ - Return LUT directory in scilpy repository - - Returns - ------- - lut_dir: string - LUT path - """ - # Get the valid LUT choices. - import scilpy # ToDo. Is this the only way? - module_path = inspect.getfile(scilpy) - - lut_dir = os.path.join(os.path.dirname( - os.path.dirname(module_path)) + "/data/LUT/") - - return lut_dir - - def split_labels(labels_volume, label_indices): """ For each label in list, return a separate volume containing only that @@ -494,3 +478,117 @@ def merge_labels_into_mask(atlas, filtering_args): mask[atlas == int(filtering_args)] = 1 return mask + + +def harmonize_labels(original_data, min_voxel_overlap=1, max_adjacency=1e2): + """ + Harmonize lesion labels across multiple 3D volumes by ensuring consistent + labeling. + + This function takes multiple 3D NIfTI volumes with labeled regions + (e.g., lesions) and harmonizes the labels so that regions that are the same + across different volumes are assigned a consistent label. It operates by + iteratively comparing labels in each volume to those in previous volumes + and matching them based on spatial proximity and overlap. + + Parameters + ---------- + original_data : list of numpy.ndarray + A list of 3D numpy arrays where each array contains labeled regions. + Labels should be non-zero integers, where each unique integer represents + a different region or lesion. + min_voxel_overlap : int, optional + Minimum number of overlapping voxels required for two regions (lesions) + from different volumes to be considered as potentially the same lesion. + Default is 1. + max_adjacency : float, optional + Maximum distance allowed between the centroids of two regions for them + to be considered as the same lesion. Default is 1e2 (infinite). + + Returns + ------- + list of numpy.ndarray + A list of 3D numpy arrays with the same shape as `original_data`, where + labels have been harmonized across all volumes. Each region across + volumes that is identified as the same will have the same label. + """ + + relabeled_data = [np.zeros_like(data) for data in original_data] + relabeled_data[0] = original_data[0] + labels = np.unique(original_data)[1:] + + # We will iterate over all possible combinations of labels + N = len(original_data) + total_iteration = ((N * (N - 1)) // 2) + tqdm_bar = tqdm.tqdm(total=total_iteration, desc="Harmonizing labels") + + # We want to label images in order + for first_pass in range(len(original_data)): + unmatched_labels = np.unique(original_data[first_pass])[1:].tolist() + best_match_score = {label: 999999 for label in labels} + best_match_pos = {label: None for label in labels} + + # We iterate over all previous images to find the best match + for second_pass in range(0, first_pass): + tqdm_bar.update(1) + + # We check all existing labels in relabeled data + for label_ind_1 in range(len(labels)): + label_1 = labels[label_ind_1] + + if label_1 not in original_data[first_pass]: + continue + + # This check requires to at least overlap by N voxel + coord_1 = np.where(original_data[first_pass] == label_1) + overlap_labels_count = np.unique(relabeled_data[second_pass][coord_1], + return_counts=True) + + potential_labels_val = overlap_labels_count[0].tolist() + potential_labels_count = overlap_labels_count[1].tolist() + potential_labels = [] + for val, count in zip(potential_labels_val, + potential_labels_count): + if val != 0 and count > min_voxel_overlap: + potential_labels.append(val) + + # We check all labels touching the previous label + for label_2 in potential_labels: + tmp_data_1 = np.zeros_like(original_data[0]) + tmp_data_2 = np.zeros_like(original_data[0]) + + # We always compare the previous relabeled data with the next + # original data + tmp_data_1[original_data[first_pass] == label_1] = 1 + tmp_data_2[relabeled_data[second_pass] == label_2] = 1 + + # They should have a similar shape (TODO: parameters) + adjacency = compute_bundle_adjacency_voxel( + tmp_data_1, tmp_data_2) + if adjacency > max_adjacency: + continue + + if adjacency < best_match_score[label_1]: + best_match_score[label_1] = adjacency + best_match_pos[label_1] = label_2 + + # We relabel the data and keep track of the unmatched labels + for label in labels: + if best_match_pos[label] is not None: + old_label = label + new_label = best_match_pos[label] + relabeled_data[first_pass][original_data[first_pass] + == old_label] = new_label + if old_label in unmatched_labels: + unmatched_labels.remove(old_label) + + # Anything that is left should be given a new label + if first_pass == 0: + continue + next_label = np.max(relabeled_data[:first_pass]) + 1 + for label in unmatched_labels: + relabeled_data[first_pass][original_data[first_pass] + == label] = next_label + next_label += 1 + + return [data.astype(np.uint16) for data in relabeled_data] diff --git a/scilpy/image/reslice.py b/src/scilpy/image/reslice.py similarity index 100% rename from scilpy/image/reslice.py rename to src/scilpy/image/reslice.py diff --git a/scilpy/ml/bundleparc/__init__.py b/src/scilpy/image/tests/__init__.py similarity index 100% rename from scilpy/ml/bundleparc/__init__.py rename to src/scilpy/image/tests/__init__.py diff --git a/scilpy/image/tests/test_labels.py b/src/scilpy/image/tests/test_labels.py similarity index 96% rename from scilpy/image/tests/test_labels.py rename to src/scilpy/image/tests/test_labels.py index 026f0d9d1..5d7af9256 100644 --- a/scilpy/image/tests/test_labels.py +++ b/src/scilpy/image/tests/test_labels.py @@ -11,7 +11,7 @@ from scilpy.image.labels import (combine_labels, dilate_labels, get_data_as_labels, get_labels_from_mask, - get_lut_dir, remove_labels, split_labels) + remove_labels, split_labels) from scilpy.tests.arrays import ref_in_labels, ref_out_labels @@ -180,14 +180,6 @@ def test_get_labels_from_mask_custom_background(): assert_equal(labels, data) -def test_get_lut_dir(): - lut_dir = get_lut_dir() - assert os.path.isdir(lut_dir) - - lut_files = glob(os.path.join(lut_dir, '*.json')) - assert len(lut_files) == 3 - - def test_remove_labels(): in_labels = deepcopy(ref_in_labels) out_labels = remove_labels(in_labels, [3, 4, 5, 6, 7, 7]) diff --git a/scilpy/image/tests/test_volume_math.py b/src/scilpy/image/tests/test_volume_math.py similarity index 100% rename from scilpy/image/tests/test_volume_math.py rename to src/scilpy/image/tests/test_volume_math.py diff --git a/scilpy/image/tests/test_volume_metrics.py b/src/scilpy/image/tests/test_volume_metrics.py similarity index 100% rename from scilpy/image/tests/test_volume_metrics.py rename to src/scilpy/image/tests/test_volume_metrics.py diff --git a/scilpy/image/tests/test_volume_operations.py b/src/scilpy/image/tests/test_volume_operations.py similarity index 100% rename from scilpy/image/tests/test_volume_operations.py rename to src/scilpy/image/tests/test_volume_operations.py diff --git a/scilpy/image/utils.py b/src/scilpy/image/utils.py similarity index 100% rename from scilpy/image/utils.py rename to src/scilpy/image/utils.py diff --git a/scilpy/image/volume_b0_synthesis.py b/src/scilpy/image/volume_b0_synthesis.py similarity index 100% rename from scilpy/image/volume_b0_synthesis.py rename to src/scilpy/image/volume_b0_synthesis.py diff --git a/scilpy/image/volume_math.py b/src/scilpy/image/volume_math.py similarity index 100% rename from scilpy/image/volume_math.py rename to src/scilpy/image/volume_math.py diff --git a/scilpy/image/volume_metrics.py b/src/scilpy/image/volume_metrics.py similarity index 100% rename from scilpy/image/volume_metrics.py rename to src/scilpy/image/volume_metrics.py diff --git a/scilpy/image/volume_operations.py b/src/scilpy/image/volume_operations.py similarity index 99% rename from scilpy/image/volume_operations.py rename to src/scilpy/image/volume_operations.py index 577e20878..727f8847f 100644 --- a/scilpy/image/volume_operations.py +++ b/src/scilpy/image/volume_operations.py @@ -453,7 +453,7 @@ def remove_outliers_ransac(in_data, min_fit, fit_thr, max_iter): X = in_nzr_ind[0][:, np.newaxis] model_ransac = linear_model.RANSACRegressor( - base_estimator=linear_model.LinearRegression(), min_samples=min_fit, + estimator=linear_model.LinearRegression(), min_samples=min_fit, residual_threshold=fit_thr, max_trials=max_iter) model_ransac.fit(X, in_nzr_val) diff --git a/scilpy/image/volume_space_management.py b/src/scilpy/image/volume_space_management.py similarity index 100% rename from scilpy/image/volume_space_management.py rename to src/scilpy/image/volume_space_management.py diff --git a/scilpy/preprocessing/__init__.py b/src/scilpy/io/__init__.py similarity index 100% rename from scilpy/preprocessing/__init__.py rename to src/scilpy/io/__init__.py diff --git a/scilpy/io/btensor.py b/src/scilpy/io/btensor.py similarity index 100% rename from scilpy/io/btensor.py rename to src/scilpy/io/btensor.py diff --git a/scilpy/io/deprecator.py b/src/scilpy/io/deprecator.py similarity index 100% rename from scilpy/io/deprecator.py rename to src/scilpy/io/deprecator.py diff --git a/scilpy/io/dvc.py b/src/scilpy/io/dvc.py similarity index 100% rename from scilpy/io/dvc.py rename to src/scilpy/io/dvc.py diff --git a/scilpy/io/fetcher.py b/src/scilpy/io/fetcher.py similarity index 92% rename from scilpy/io/fetcher.py rename to src/scilpy/io/fetcher.py index 563d01b67..87c62645b 100644 --- a/scilpy/io/fetcher.py +++ b/src/scilpy/io/fetcher.py @@ -43,7 +43,7 @@ def get_testing_files_dict(): "bundles.zip": "54b6e2bf2dda579886efe4e2a8989486", "stats.zip": "2aeac4da5ab054b3a460fc5fdc5e4243", "bst.zip": "eed227fd246255e7417f92d49eb1066a", - "filtering.zip": "19116ff4244d057c8214ee3fe8e05f71", + "filtering.zip": "aa35388a791d803e3051a3236577ae19", "ihMT.zip": "08fcf44848ba2649aad5a5a470b3cb06", "tractometry.zip": "890bfa70e44b15c0d044085de54e00c6", "bids_json.zip": "97fd9a414849567fbfdfdb0ef400488b", @@ -59,11 +59,12 @@ def get_testing_files_dict(): "processing.zip": "1ba6869c9d8b58a9b911ba71fdd50a07", "surface_vtk_fib.zip": "241f3afd6344c967d7176b43e4a99a41", "tractograms.zip": "964113f307213523d784b3dbf3a5117a", - "mrds.zip": "5abe6092400e11e9bb2423e2c387e774" + "mrds.zip": "5abe6092400e11e9bb2423e2c387e774", + "lesions.zip": "dbd160b4c0c5d2db9cada875c0bbb00c" } -def fetch_data(files_dict, keys=None): +def fetch_data(files_dict, keys=None, verbose=True): """ Fetch data. Typical use would be with gdown. But with too many data accesses, downloaded become denied. @@ -85,8 +86,9 @@ def fetch_data(files_dict, keys=None): CURR_URL = DVC_URL + "/" + url_md5[:2] + "/" + url_md5[2:] if not os.path.isdir(full_path_no_ext): if ext == '.zip' and not os.path.isdir(full_path_no_ext): - logging.warning('Downloading and extracting {} from url {} to ' - '{}'.format(f, CURR_URL, SCILPY_HOME)) + if verbose: + logging.warning('Downloading and extracting {} from url {} to ' + '{}'.format(f, CURR_URL, SCILPY_HOME)) # Robust method to Virus/Size check from GDrive download_file_from_google_drive(CURR_URL, full_path) diff --git a/scilpy/io/gradients.py b/src/scilpy/io/gradients.py similarity index 100% rename from scilpy/io/gradients.py rename to src/scilpy/io/gradients.py diff --git a/scilpy/io/hdf5.py b/src/scilpy/io/hdf5.py similarity index 100% rename from scilpy/io/hdf5.py rename to src/scilpy/io/hdf5.py diff --git a/scilpy/io/image.py b/src/scilpy/io/image.py similarity index 100% rename from scilpy/io/image.py rename to src/scilpy/io/image.py diff --git a/scilpy/io/mti.py b/src/scilpy/io/mti.py similarity index 100% rename from scilpy/io/mti.py rename to src/scilpy/io/mti.py diff --git a/scilpy/io/streamlines.py b/src/scilpy/io/streamlines.py similarity index 100% rename from scilpy/io/streamlines.py rename to src/scilpy/io/streamlines.py diff --git a/scilpy/io/tensor.py b/src/scilpy/io/tensor.py similarity index 100% rename from scilpy/io/tensor.py rename to src/scilpy/io/tensor.py diff --git a/scilpy/io/utils.py b/src/scilpy/io/utils.py similarity index 99% rename from scilpy/io/utils.py rename to src/scilpy/io/utils.py index 28a955d96..bcaf4670f 100644 --- a/scilpy/io/utils.py +++ b/src/scilpy/io/utils.py @@ -13,6 +13,7 @@ import nibabel as nib import numpy as np from dipy.data import SPHERE_FILES +from dipy.io.stateful_tractogram import Space, Origin from dipy.io.utils import is_header_compatible from scipy.io import loadmat import six @@ -307,6 +308,11 @@ def add_bbox_arg(parser): 'streamlines).') +def add_vtk_legacy_arg(parser): + parser.add_argument('--legacy_vtk_format', action='store_true', + help='Save the VTK file in the legacy format.') + + def add_sh_basis_args(parser, mandatory=False, input_output=False): """ Add spherical harmonics (SH) bases argument. For more information about @@ -525,14 +531,14 @@ def add_volume_screenshot_args(parser, input_name, mandatory=True, cmap_parsing_group.add_argument(f"--{input_name}_cmap_name", default=default_cmap, help=f"Colormap name for the {descriptor} " - f"image data. [%(default)s]") + f"image data. [%(default)s]") opacity_parsing_group.add_argument(f"--{input_name}_opacity", type=ranged_type(float, 0., 1.), default=default_alpha, help=f"Opacity value for the " - f"{descriptor} image data. " - f"[%(default)s]") + f"{descriptor} image data. " + f"[%(default)s]") def add_default_screenshot_args(parser, slice_ids_mandatory=True, diff --git a/scilpy/io/varian_fdf.py b/src/scilpy/io/varian_fdf.py similarity index 98% rename from scilpy/io/varian_fdf.py rename to src/scilpy/io/varian_fdf.py index 7736d42a7..aa77f7d40 100644 --- a/scilpy/io/varian_fdf.py +++ b/src/scilpy/io/varian_fdf.py @@ -101,11 +101,11 @@ def read_file(file_path): # Extracts floating point numbers # ex: 'float roi[] = {3.840000,3.840000,0.035000};' # returns ['3.840000', '3.840000', '0.035000'] - float_regex = '[-+]?[0-9]*\.?[0-9]+' + float_regex = r'[-+]?[0-9]*\.?[0-9]+' # Extracts value of a line of the type: # 'int slice_no = 1;' would return '1' - named_value_regex = '= *\"*(.*[^\"])\"* *;' + named_value_regex = r'= *\"*(.*[^\"])\"* *;' # (tag_in_file, tag_in_header) find_values = (('echos', 'nechoes'), @@ -172,7 +172,7 @@ def read_file(file_path): # Extracts digits. # ex: 'float matrix[] = {128, 128};' # returns ['128', '128'] - m = re.findall('(\d+)', line.rstrip()) + m = re.findall(r'(\d+)', line.rstrip()) raw_header['shape'] = np.array([int(x) for x in m]) # Total number of data pixels diff --git a/scilpy/reconst/__init__.py b/src/scilpy/ml/__init__.py similarity index 100% rename from scilpy/reconst/__init__.py rename to src/scilpy/ml/__init__.py diff --git a/scilpy/segment/__init__.py b/src/scilpy/ml/bundleparc/__init__.py similarity index 100% rename from scilpy/segment/__init__.py rename to src/scilpy/ml/bundleparc/__init__.py diff --git a/scilpy/ml/bundleparc/attention.py b/src/scilpy/ml/bundleparc/attention.py similarity index 100% rename from scilpy/ml/bundleparc/attention.py rename to src/scilpy/ml/bundleparc/attention.py diff --git a/scilpy/ml/bundleparc/bundleparcnet.py b/src/scilpy/ml/bundleparc/bundleparcnet.py similarity index 100% rename from scilpy/ml/bundleparc/bundleparcnet.py rename to src/scilpy/ml/bundleparc/bundleparcnet.py diff --git a/scilpy/ml/bundleparc/encodings.py b/src/scilpy/ml/bundleparc/encodings.py similarity index 100% rename from scilpy/ml/bundleparc/encodings.py rename to src/scilpy/ml/bundleparc/encodings.py diff --git a/scilpy/ml/bundleparc/predict.py b/src/scilpy/ml/bundleparc/predict.py similarity index 100% rename from scilpy/ml/bundleparc/predict.py rename to src/scilpy/ml/bundleparc/predict.py diff --git a/scilpy/ml/bundleparc/tests/test_bundleparc_utils.py b/src/scilpy/ml/bundleparc/tests/test_bundleparc_utils.py similarity index 100% rename from scilpy/ml/bundleparc/tests/test_bundleparc_utils.py rename to src/scilpy/ml/bundleparc/tests/test_bundleparc_utils.py diff --git a/scilpy/ml/bundleparc/utils.py b/src/scilpy/ml/bundleparc/utils.py similarity index 100% rename from scilpy/ml/bundleparc/utils.py rename to src/scilpy/ml/bundleparc/utils.py diff --git a/scilpy/ml/utils.py b/src/scilpy/ml/utils.py similarity index 100% rename from scilpy/ml/utils.py rename to src/scilpy/ml/utils.py diff --git a/scilpy/stats/__init__.py b/src/scilpy/preprocessing/__init__.py similarity index 100% rename from scilpy/stats/__init__.py rename to src/scilpy/preprocessing/__init__.py diff --git a/scilpy/preprocessing/distortion_correction.py b/src/scilpy/preprocessing/distortion_correction.py similarity index 100% rename from scilpy/preprocessing/distortion_correction.py rename to src/scilpy/preprocessing/distortion_correction.py diff --git a/scilpy/surfaces/__init__.py b/src/scilpy/reconst/__init__.py similarity index 100% rename from scilpy/surfaces/__init__.py rename to src/scilpy/reconst/__init__.py diff --git a/scilpy/reconst/aodf.py b/src/scilpy/reconst/aodf.py similarity index 100% rename from scilpy/reconst/aodf.py rename to src/scilpy/reconst/aodf.py diff --git a/scilpy/reconst/bingham.py b/src/scilpy/reconst/bingham.py similarity index 95% rename from scilpy/reconst/bingham.py rename to src/scilpy/reconst/bingham.py index 59ee29932..e27f50038 100644 --- a/scilpy/reconst/bingham.py +++ b/src/scilpy/reconst/bingham.py @@ -72,8 +72,9 @@ def bingham_to_sf(bingham_volume, vertices): Parameters ---------- - bingham_volume: Bingham parameters volume. - A Bingham distributions volume. + bingham_volume: Array + Volume of shape (X, Y, Z, N_LOBES, NB_PARAMS) containing + the Bingham distributions parameters. Note, NB_PARAMS is usually 7. vertices: ndarray (n_vertices, 3) Sampling directions. @@ -110,8 +111,9 @@ def bingham_to_peak_direction(bingham_volume): Parameters ---------- - bingham_volume: ndarray (..., max_lobes, 9) - Bingham volume. + bingham_volume: Array + Volume of shape (X, Y, Z, N_LOBES, NB_PARAMS) containing + the Bingham distributions parameters. Note, NB_PARAMS is usually 7. Returns ------- @@ -357,8 +359,9 @@ def compute_fiber_density(bingham, m=50, mask=None, nbr_processes=None): Parameters ---------- - bingham: ndarray (X, Y, Z, max_lobes*9) - Input Bingham volume. + bingham: Array + Volume of shape (X, Y, Z, N_LOBES, NB_PARAMS) containing + the Bingham distributions parameters. Note, NB_PARAMS is usually 7. m: unsigned int, optional Number of steps along theta axis for the integration. The number of steps along the phi axis is 2*m. @@ -448,8 +451,9 @@ def compute_fiber_spread(binghams, fd): Parameters ---------- - binghams: ndarray (X, Y, Z, max_lobes*9) - Bingham volume. + binghams: Array + Volume of shape (X, Y, Z, N_LOBES, NB_PARAMS) containing + the Bingham distributions parameters. Note, NB_PARAMS is usually 7. fd: ndarray (X, Y, Z, max_lobes) Fiber density image. diff --git a/scilpy/reconst/divide.py b/src/scilpy/reconst/divide.py similarity index 100% rename from scilpy/reconst/divide.py rename to src/scilpy/reconst/divide.py diff --git a/scilpy/reconst/fiber_coherence.py b/src/scilpy/reconst/fiber_coherence.py similarity index 100% rename from scilpy/reconst/fiber_coherence.py rename to src/scilpy/reconst/fiber_coherence.py diff --git a/scilpy/reconst/fodf.py b/src/scilpy/reconst/fodf.py similarity index 100% rename from scilpy/reconst/fodf.py rename to src/scilpy/reconst/fodf.py diff --git a/scilpy/reconst/frf.py b/src/scilpy/reconst/frf.py similarity index 100% rename from scilpy/reconst/frf.py rename to src/scilpy/reconst/frf.py diff --git a/scilpy/reconst/mti.py b/src/scilpy/reconst/mti.py similarity index 100% rename from scilpy/reconst/mti.py rename to src/scilpy/reconst/mti.py diff --git a/scilpy/reconst/sh.py b/src/scilpy/reconst/sh.py similarity index 100% rename from scilpy/reconst/sh.py rename to src/scilpy/reconst/sh.py diff --git a/scilpy/reconst/tests/test_aodf.py b/src/scilpy/reconst/tests/test_aodf.py similarity index 100% rename from scilpy/reconst/tests/test_aodf.py rename to src/scilpy/reconst/tests/test_aodf.py diff --git a/scilpy/reconst/tests/test_bingham.py b/src/scilpy/reconst/tests/test_bingham.py similarity index 100% rename from scilpy/reconst/tests/test_bingham.py rename to src/scilpy/reconst/tests/test_bingham.py diff --git a/scilpy/reconst/tests/test_divide.py b/src/scilpy/reconst/tests/test_divide.py similarity index 100% rename from scilpy/reconst/tests/test_divide.py rename to src/scilpy/reconst/tests/test_divide.py diff --git a/scilpy/reconst/tests/test_fiber_coherence.py b/src/scilpy/reconst/tests/test_fiber_coherence.py similarity index 100% rename from scilpy/reconst/tests/test_fiber_coherence.py rename to src/scilpy/reconst/tests/test_fiber_coherence.py diff --git a/scilpy/reconst/tests/test_fodf.py b/src/scilpy/reconst/tests/test_fodf.py similarity index 100% rename from scilpy/reconst/tests/test_fodf.py rename to src/scilpy/reconst/tests/test_fodf.py diff --git a/scilpy/reconst/tests/test_frf.py b/src/scilpy/reconst/tests/test_frf.py similarity index 100% rename from scilpy/reconst/tests/test_frf.py rename to src/scilpy/reconst/tests/test_frf.py diff --git a/scilpy/reconst/tests/test_mti.py b/src/scilpy/reconst/tests/test_mti.py similarity index 100% rename from scilpy/reconst/tests/test_mti.py rename to src/scilpy/reconst/tests/test_mti.py diff --git a/scilpy/reconst/tests/test_sh.py b/src/scilpy/reconst/tests/test_sh.py similarity index 100% rename from scilpy/reconst/tests/test_sh.py rename to src/scilpy/reconst/tests/test_sh.py diff --git a/scilpy/reconst/tests/test_utils.py b/src/scilpy/reconst/tests/test_utils.py similarity index 100% rename from scilpy/reconst/tests/test_utils.py rename to src/scilpy/reconst/tests/test_utils.py diff --git a/scilpy/reconst/utils.py b/src/scilpy/reconst/utils.py similarity index 100% rename from scilpy/reconst/utils.py rename to src/scilpy/reconst/utils.py diff --git a/scilpy/tracking/__init__.py b/src/scilpy/segment/__init__.py similarity index 100% rename from scilpy/tracking/__init__.py rename to src/scilpy/segment/__init__.py diff --git a/scilpy/segment/bundleseg.py b/src/scilpy/segment/bundleseg.py similarity index 99% rename from scilpy/segment/bundleseg.py rename to src/scilpy/segment/bundleseg.py index a4d16d89a..f12ba728b 100644 --- a/scilpy/segment/bundleseg.py +++ b/src/scilpy/segment/bundleseg.py @@ -284,7 +284,7 @@ def prune_far_from_model(self, pruning_thr=10): tmp_dist_mat = fss.radius_search( neighb_streamlines[chuck_id:chuck_id+CHUNK_SIZE], pruning_thr) - tmp_dist_mat.data = tmp_dist_mat.data.astype(np.float16) + tmp_dist_mat.data = tmp_dist_mat.data.astype(np.float32) dist_mat_list.append(tmp_dist_mat.copy()) del tmp_dist_mat gc.collect() @@ -293,7 +293,7 @@ def prune_far_from_model(self, pruning_thr=10): for tmp_dist_mat in dist_mat_list: del tmp_dist_mat gc.collect() - dist_mat.data = dist_mat.data.astype(np.float16) + dist_mat.data = dist_mat.data.astype(np.float32) dist_mat = dist_mat.T logger.debug(f'Fast search took of dimensions {dist_mat.shape}: ' diff --git a/scilpy/segment/streamlines.py b/src/scilpy/segment/streamlines.py similarity index 100% rename from scilpy/segment/streamlines.py rename to src/scilpy/segment/streamlines.py diff --git a/scilpy/segment/tests/test_tractogram_from_roi.py b/src/scilpy/segment/tests/test_tractogram_from_roi.py similarity index 100% rename from scilpy/segment/tests/test_tractogram_from_roi.py rename to src/scilpy/segment/tests/test_tractogram_from_roi.py diff --git a/scilpy/segment/tractogram_from_roi.py b/src/scilpy/segment/tractogram_from_roi.py similarity index 100% rename from scilpy/segment/tractogram_from_roi.py rename to src/scilpy/segment/tractogram_from_roi.py diff --git a/scilpy/segment/voting_scheme.py b/src/scilpy/segment/voting_scheme.py similarity index 100% rename from scilpy/segment/voting_scheme.py rename to src/scilpy/segment/voting_scheme.py diff --git a/scilpy/tractanalysis/__init__.py b/src/scilpy/stats/__init__.py similarity index 100% rename from scilpy/tractanalysis/__init__.py rename to src/scilpy/stats/__init__.py diff --git a/scilpy/stats/matrix_stats.py b/src/scilpy/stats/matrix_stats.py similarity index 100% rename from scilpy/stats/matrix_stats.py rename to src/scilpy/stats/matrix_stats.py diff --git a/scilpy/stats/stats.py b/src/scilpy/stats/stats.py similarity index 100% rename from scilpy/stats/stats.py rename to src/scilpy/stats/stats.py diff --git a/scilpy/stats/tests/test_matrix_stats.py b/src/scilpy/stats/tests/test_matrix_stats.py similarity index 100% rename from scilpy/stats/tests/test_matrix_stats.py rename to src/scilpy/stats/tests/test_matrix_stats.py diff --git a/scilpy/stats/utils.py b/src/scilpy/stats/utils.py similarity index 100% rename from scilpy/stats/utils.py rename to src/scilpy/stats/utils.py diff --git a/scilpy/tractograms/__init__.py b/src/scilpy/surfaces/__init__.py similarity index 100% rename from scilpy/tractograms/__init__.py rename to src/scilpy/surfaces/__init__.py diff --git a/scilpy/surfaces/surface_operations.py b/src/scilpy/surfaces/surface_operations.py similarity index 100% rename from scilpy/surfaces/surface_operations.py rename to src/scilpy/surfaces/surface_operations.py diff --git a/scilpy/surfaces/tests/test_surface_operations.py b/src/scilpy/surfaces/tests/test_surface_operations.py similarity index 100% rename from scilpy/surfaces/tests/test_surface_operations.py rename to src/scilpy/surfaces/tests/test_surface_operations.py diff --git a/scilpy/surfaces/tests/test_surfaces_utils.py b/src/scilpy/surfaces/tests/test_surfaces_utils.py similarity index 100% rename from scilpy/surfaces/tests/test_surfaces_utils.py rename to src/scilpy/surfaces/tests/test_surfaces_utils.py diff --git a/scilpy/surfaces/utils.py b/src/scilpy/surfaces/utils.py similarity index 100% rename from scilpy/surfaces/utils.py rename to src/scilpy/surfaces/utils.py diff --git a/scilpy/tests/arrays.py b/src/scilpy/tests/arrays.py similarity index 100% rename from scilpy/tests/arrays.py rename to src/scilpy/tests/arrays.py diff --git a/scilpy/tests/dict.py b/src/scilpy/tests/dict.py similarity index 100% rename from scilpy/tests/dict.py rename to src/scilpy/tests/dict.py diff --git a/scilpy/tests/streamlines.py b/src/scilpy/tests/streamlines.py similarity index 100% rename from scilpy/tests/streamlines.py rename to src/scilpy/tests/streamlines.py diff --git a/scilpy/tests/utils.py b/src/scilpy/tests/utils.py similarity index 100% rename from scilpy/tests/utils.py rename to src/scilpy/tests/utils.py diff --git a/scilpy/tractograms/tests/__init__.py b/src/scilpy/tracking/__init__.py similarity index 100% rename from scilpy/tractograms/tests/__init__.py rename to src/scilpy/tracking/__init__.py diff --git a/scilpy/tracking/fibertube_utils.py b/src/scilpy/tracking/fibertube_utils.py similarity index 100% rename from scilpy/tracking/fibertube_utils.py rename to src/scilpy/tracking/fibertube_utils.py diff --git a/scilpy/tracking/local_tracking.cl b/src/scilpy/tracking/local_tracking.cl similarity index 100% rename from scilpy/tracking/local_tracking.cl rename to src/scilpy/tracking/local_tracking.cl diff --git a/scilpy/tracking/propagator.py b/src/scilpy/tracking/propagator.py similarity index 100% rename from scilpy/tracking/propagator.py rename to src/scilpy/tracking/propagator.py diff --git a/scilpy/tracking/rap.py b/src/scilpy/tracking/rap.py similarity index 100% rename from scilpy/tracking/rap.py rename to src/scilpy/tracking/rap.py diff --git a/scilpy/tracking/seed.py b/src/scilpy/tracking/seed.py similarity index 100% rename from scilpy/tracking/seed.py rename to src/scilpy/tracking/seed.py diff --git a/scilpy/tracking/tests/test_propagator.py b/src/scilpy/tracking/tests/test_propagator.py similarity index 100% rename from scilpy/tracking/tests/test_propagator.py rename to src/scilpy/tracking/tests/test_propagator.py diff --git a/scilpy/tracking/tests/test_seed.py b/src/scilpy/tracking/tests/test_seed.py similarity index 100% rename from scilpy/tracking/tests/test_seed.py rename to src/scilpy/tracking/tests/test_seed.py diff --git a/scilpy/tracking/tests/test_tracker.py b/src/scilpy/tracking/tests/test_tracker.py similarity index 100% rename from scilpy/tracking/tests/test_tracker.py rename to src/scilpy/tracking/tests/test_tracker.py diff --git a/scilpy/tracking/tracker.py b/src/scilpy/tracking/tracker.py similarity index 100% rename from scilpy/tracking/tracker.py rename to src/scilpy/tracking/tracker.py diff --git a/scilpy/tracking/utils.py b/src/scilpy/tracking/utils.py similarity index 100% rename from scilpy/tracking/utils.py rename to src/scilpy/tracking/utils.py diff --git a/scilpy/viz/__init__.py b/src/scilpy/tractanalysis/__init__.py similarity index 100% rename from scilpy/viz/__init__.py rename to src/scilpy/tractanalysis/__init__.py diff --git a/scilpy/tractanalysis/afd_along_streamlines.py b/src/scilpy/tractanalysis/afd_along_streamlines.py similarity index 98% rename from scilpy/tractanalysis/afd_along_streamlines.py rename to src/scilpy/tractanalysis/afd_along_streamlines.py index 436d39854..de2248443 100644 --- a/scilpy/tractanalysis/afd_along_streamlines.py +++ b/src/scilpy/tractanalysis/afd_along_streamlines.py @@ -3,7 +3,7 @@ from dipy.data import get_sphere from dipy.reconst.shm import sh_to_sf_matrix, sph_harm_ind_list import numpy as np -from scipy.special import lpn +from scipy.special import legendre_p_all from scilpy.reconst.utils import find_order_from_nb_coeff from scilpy.tractanalysis.voxel_boundary_intersection import\ @@ -87,7 +87,7 @@ def afd_and_rd_sums_along_streamlines(sft, fodf, fodf_basis, sphere = get_sphere(name='repulsion724') b_matrix, _ = sh_to_sf_matrix(sphere, order, fodf_basis, legacy=is_legacy) _, n = sph_harm_ind_list(order) - legendre0_at_n = lpn(order, 0)[0][n] + legendre0_at_n = legendre_p_all(order, 0)[0][n] sphere_norm = np.linalg.norm(sphere.vertices) afd_sum_map = np.zeros(shape=fodf_data.shape[:-1]) diff --git a/scilpy/tractanalysis/bingham_metric_along_streamlines.py b/src/scilpy/tractanalysis/bingham_metric_along_streamlines.py similarity index 98% rename from scilpy/tractanalysis/bingham_metric_along_streamlines.py rename to src/scilpy/tractanalysis/bingham_metric_along_streamlines.py index 91eaf7a5a..567feb08c 100644 --- a/scilpy/tractanalysis/bingham_metric_along_streamlines.py +++ b/src/scilpy/tractanalysis/bingham_metric_along_streamlines.py @@ -18,7 +18,7 @@ def bingham_metric_map_along_streamlines(sft, bingham_coeffs, StatefulTractogram containing the streamlines needed. bingham_coeffs : ndarray Array of shape (X, Y, Z, N_LOBES, NB_PARAMS) containing - the Bingham distributions parameters. + the Bingham distributions parameters. Note, NB_PARAMS is usually 7. metric : ndarray Array of shape (X, Y, Z) containing the Bingham metric of interest. max_theta : float diff --git a/scilpy/tractanalysis/bundle_operations.py b/src/scilpy/tractanalysis/bundle_operations.py similarity index 100% rename from scilpy/tractanalysis/bundle_operations.py rename to src/scilpy/tractanalysis/bundle_operations.py diff --git a/scilpy/tractanalysis/connectivity_segmentation.py b/src/scilpy/tractanalysis/connectivity_segmentation.py similarity index 100% rename from scilpy/tractanalysis/connectivity_segmentation.py rename to src/scilpy/tractanalysis/connectivity_segmentation.py diff --git a/scilpy/tractanalysis/distance_to_centroid.py b/src/scilpy/tractanalysis/distance_to_centroid.py similarity index 100% rename from scilpy/tractanalysis/distance_to_centroid.py rename to src/scilpy/tractanalysis/distance_to_centroid.py diff --git a/scilpy/tractanalysis/fibertube_scoring.py b/src/scilpy/tractanalysis/fibertube_scoring.py similarity index 100% rename from scilpy/tractanalysis/fibertube_scoring.py rename to src/scilpy/tractanalysis/fibertube_scoring.py diff --git a/scilpy/tractanalysis/fixel_density.py b/src/scilpy/tractanalysis/fixel_density.py similarity index 100% rename from scilpy/tractanalysis/fixel_density.py rename to src/scilpy/tractanalysis/fixel_density.py diff --git a/scilpy/tractanalysis/json_utils.py b/src/scilpy/tractanalysis/json_utils.py similarity index 100% rename from scilpy/tractanalysis/json_utils.py rename to src/scilpy/tractanalysis/json_utils.py diff --git a/scilpy/tractanalysis/mrds_along_streamlines.py b/src/scilpy/tractanalysis/mrds_along_streamlines.py similarity index 100% rename from scilpy/tractanalysis/mrds_along_streamlines.py rename to src/scilpy/tractanalysis/mrds_along_streamlines.py diff --git a/scilpy/tractanalysis/reproducibility_measures.py b/src/scilpy/tractanalysis/reproducibility_measures.py similarity index 98% rename from scilpy/tractanalysis/reproducibility_measures.py rename to src/scilpy/tractanalysis/reproducibility_measures.py index 054d3d16f..9e9e58498 100755 --- a/scilpy/tractanalysis/reproducibility_measures.py +++ b/src/scilpy/tractanalysis/reproducibility_measures.py @@ -744,6 +744,12 @@ def compare_volume_wrapper(data_1, data_2, voxel_size=1, ratio=False, union_values = np.union1d(unique_values_1, unique_values_2) + measures_name = ['adjacency_voxels', + 'dice_voxels', + 'hausdorff', + 'volume_overlap', + 'volume_overreach'] + dict_measures = {} for val in union_values: binary_1 = np.zeros(data_1.shape, dtype=np.uint8) @@ -755,6 +761,15 @@ def compare_volume_wrapper(data_1, data_2, voxel_size=1, ratio=False, else: binary_2[data_2 == val] = 1 + if np.count_nonzero(binary_1) == 0 or np.count_nonzero(binary_2) == 0: + tmp_dict = dict.fromkeys(measures_name, np.nan) + for measure_name in measures_name: + if measure_name not in dict_measures: + dict_measures[measure_name] = {} + dict_measures[measure_name].update( + {int(val): tmp_dict[measure_name]}) + continue + # These measures are in mm^3 volume_overlap = np.count_nonzero(binary_1 * binary_2) volume_overreach = np.abs(np.count_nonzero( @@ -776,12 +791,6 @@ def compare_volume_wrapper(data_1, data_2, voxel_size=1, ratio=False, hausdorff_vox = compute_hausdorff_voxel(binary_1, binary_2) - measures_name = ['adjacency_voxels', - 'dice_voxels', - 'hausdorff', - 'volume_overlap', - 'volume_overreach'] - # If computing ratio, voxel size does not make sense if ratio: voxel_size = 1. diff --git a/scilpy/tractanalysis/scoring.py b/src/scilpy/tractanalysis/scoring.py similarity index 100% rename from scilpy/tractanalysis/scoring.py rename to src/scilpy/tractanalysis/scoring.py diff --git a/scilpy/tractanalysis/streamlines_metrics.pyx b/src/scilpy/tractanalysis/streamlines_metrics.pyx similarity index 100% rename from scilpy/tractanalysis/streamlines_metrics.pyx rename to src/scilpy/tractanalysis/streamlines_metrics.pyx diff --git a/scilpy/tractanalysis/tests/test_fixel_density.py b/src/scilpy/tractanalysis/tests/test_fixel_density.py similarity index 100% rename from scilpy/tractanalysis/tests/test_fixel_density.py rename to src/scilpy/tractanalysis/tests/test_fixel_density.py diff --git a/scilpy/tractanalysis/tests/test_json_utils.py b/src/scilpy/tractanalysis/tests/test_json_utils.py similarity index 100% rename from scilpy/tractanalysis/tests/test_json_utils.py rename to src/scilpy/tractanalysis/tests/test_json_utils.py diff --git a/scilpy/tractanalysis/tests/test_reproducibility_measures.py b/src/scilpy/tractanalysis/tests/test_reproducibility_measures.py similarity index 90% rename from scilpy/tractanalysis/tests/test_reproducibility_measures.py rename to src/scilpy/tractanalysis/tests/test_reproducibility_measures.py index f1e3ed335..8d0596037 100644 --- a/scilpy/tractanalysis/tests/test_reproducibility_measures.py +++ b/src/scilpy/tractanalysis/tests/test_reproducibility_measures.py @@ -64,15 +64,15 @@ def test_tractogram_pairwise_comparison(): # Comparing with values obtained when creating this test. np.testing.assert_almost_equal(np.mean(acc_norm[~np.isnan(acc_norm)]), - 0.6590763379712203, decimal=6) + 0.659076, decimal=3) np.testing.assert_almost_equal(np.mean(corr_norm[~np.isnan(corr_norm)]), - 0.6263207793235779, decimal=6) + 0.626320, decimal=3) np.testing.assert_almost_equal(np.max(corr_norm[~np.isnan(corr_norm)]), - 0.99676438850212097, decimal=6) + 0.996764, decimal=3) np.testing.assert_almost_equal(np.mean(diff_norm[~np.isnan(diff_norm)]), - 0.7345049471266359, decimal=6) + 0.734504, decimal=3) np.testing.assert_almost_equal(np.mean(heatmap[~np.isnan(heatmap)]), - 0.7395923591441349, decimal=6) + 0.739592, decimal=3) # Supervise the number of NaNs in each output. # Note. Not the same because: diff --git a/scilpy/tractanalysis/todi.py b/src/scilpy/tractanalysis/todi.py similarity index 100% rename from scilpy/tractanalysis/todi.py rename to src/scilpy/tractanalysis/todi.py diff --git a/scilpy/tractanalysis/todi_util.py b/src/scilpy/tractanalysis/todi_util.py similarity index 100% rename from scilpy/tractanalysis/todi_util.py rename to src/scilpy/tractanalysis/todi_util.py diff --git a/scilpy/tractanalysis/voxel_boundary_intersection.pyx b/src/scilpy/tractanalysis/voxel_boundary_intersection.pyx similarity index 100% rename from scilpy/tractanalysis/voxel_boundary_intersection.pyx rename to src/scilpy/tractanalysis/voxel_boundary_intersection.pyx diff --git a/scilpy/viz/backends/__init__.py b/src/scilpy/tractograms/__init__.py similarity index 100% rename from scilpy/viz/backends/__init__.py rename to src/scilpy/tractograms/__init__.py diff --git a/scilpy/tractograms/dps_and_dpp_management.py b/src/scilpy/tractograms/dps_and_dpp_management.py similarity index 92% rename from scilpy/tractograms/dps_and_dpp_management.py rename to src/scilpy/tractograms/dps_and_dpp_management.py index 5390bf063..d4e9ed308 100644 --- a/scilpy/tractograms/dps_and_dpp_management.py +++ b/src/scilpy/tractograms/dps_and_dpp_management.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import numpy as np +from nibabel.streamlines.array_sequence import ArraySequence from scilpy.viz.color import clip_and_normalize_data_for_cmap @@ -59,8 +60,9 @@ def add_data_as_color_dpp(sft, cmap, data, clip_outliers=False, min_range=None, data = np.hstack(data) values, lbound, ubound = clip_and_normalize_data_for_cmap( - data, clip_outliers, min_range, max_range, - min_cmap, max_cmap, log, LUT) + data, clip_outliers=clip_outliers, + min_range=min_range, max_range=max_range, + min_cmap=min_cmap, max_cmap=max_cmap, log=log, LUT=LUT) # Important: values are in float after clip_and_normalize. color = np.asarray(cmap(values)[:, 0:3]) * 255 @@ -105,9 +107,10 @@ def convert_dps_to_dpp(sft, keys, overwrite=False): if key in sft.data_per_point and not overwrite: raise ValueError("Dpp key {} already existed. Please allow " "overwriting.".format(key)) - sft.data_per_point[key] = [[val]*len(s) for val, s in - zip(sft.data_per_streamline[key], - sft.streamlines)] + dps_data = sft.data_per_streamline[key] + dpp_data = ArraySequence([np.tile(dps_data[i], (len(s), 1)) + for i, s in enumerate(sft.streamlines)]) + sft.data_per_point[key] = dpp_data del sft.data_per_streamline[key] return sft @@ -252,7 +255,7 @@ def perform_operation_on_dpp(op_name, sft, dpp_name, endpoints_only=False): Returns ------- - new_data_per_point: list[np.ndarray] + new_data_per_point: ArraySequence The values that could now be associated to a new data_per_point key. """ call_op = OPERATIONS[op_name] @@ -262,16 +265,13 @@ def perform_operation_on_dpp(op_name, sft, dpp_name, endpoints_only=False): this_data_per_point = np.nan * np.ones((len(s), 1)) this_data_per_point[0] = call_op(s[0]) this_data_per_point[-1] = call_op(s[-1]) - new_data_per_point.append(np.asarray(this_data_per_point)[:, None]) + new_data_per_point.append(this_data_per_point) else: new_data_per_point = [] for s in sft.data_per_point[dpp_name]: - this_data_per_point = [] - for p in s: - this_data_per_point.append(call_op(p)) - new_data_per_point.append(np.asarray(this_data_per_point)[:, None]) + new_data_per_point.append([call_op(p) for p in s]) - return new_data_per_point + return ArraySequence(new_data_per_point) def perform_operation_dpp_to_dps(op_name, sft, dpp_name, endpoints_only=False): @@ -315,7 +315,7 @@ def perform_operation_dpp_to_dps(op_name, sft, dpp_name, endpoints_only=False): s_np = np.asarray(s) new_data_per_streamline.append(call_op(s_np)) - return new_data_per_streamline + return np.array(new_data_per_streamline) def perform_correlation_on_endpoints(sft, dpp_name='metric'): @@ -339,23 +339,23 @@ def perform_correlation_on_endpoints(sft, dpp_name='metric'): for s in sft.data_per_point[dpp_name]: new_data_per_streamline.append(np.corrcoef(s[0], s[-1])[0, 1]) - return new_data_per_streamline + return np.array(new_data_per_streamline) def _stream_mean(array): - return np.squeeze(np.mean(array, axis=0)) + return np.atleast_1d(np.mean(array, axis=0)) def _stream_sum(array): - return np.squeeze(np.sum(array, axis=0)) + return np.atleast_1d(np.sum(array, axis=0)) def _stream_min(array): - return np.squeeze(np.min(array, axis=0)) + return np.atleast_1d(np.min(array, axis=0)) def _stream_max(array): - return np.squeeze(np.max(array, axis=0)) + return np.atleast_1d(np.max(array, axis=0)) OPERATIONS = { diff --git a/scilpy/tractograms/intersection_finder.py b/src/scilpy/tractograms/intersection_finder.py similarity index 99% rename from scilpy/tractograms/intersection_finder.py rename to src/scilpy/tractograms/intersection_finder.py index 20e1e95a0..bdcdcd350 100644 --- a/scilpy/tractograms/intersection_finder.py +++ b/src/scilpy/tractograms/intersection_finder.py @@ -227,7 +227,7 @@ def build_tractograms(self, save_colliding): out_collisions.append(self._collisions[si]) elif not self._excluded[si]: out_streamlines.append(s) - out_diameters.append(self.diameters[si]) + out_diameters.append(np.array([self.diameters[si]])) if self._obstacle[si]: out_obstacle.append(s) diff --git a/scilpy/tractograms/lazy_tractogram_operations.py b/src/scilpy/tractograms/lazy_tractogram_operations.py similarity index 100% rename from scilpy/tractograms/lazy_tractogram_operations.py rename to src/scilpy/tractograms/lazy_tractogram_operations.py diff --git a/scilpy/tractograms/streamline_and_mask_operations.py b/src/scilpy/tractograms/streamline_and_mask_operations.py similarity index 99% rename from scilpy/tractograms/streamline_and_mask_operations.py rename to src/scilpy/tractograms/streamline_and_mask_operations.py index 98fcae889..6afe59834 100644 --- a/scilpy/tractograms/streamline_and_mask_operations.py +++ b/src/scilpy/tractograms/streamline_and_mask_operations.py @@ -3,7 +3,7 @@ from multiprocessing import Pool import numpy as np -from dipy.io.stateful_tractogram import StatefulTractogram, Space, Origin +from dipy.io.stateful_tractogram import StatefulTractogram from nibabel.streamlines import ArraySequence @@ -328,7 +328,7 @@ def cut_streamlines_with_mask(sft, mask, new_sft = StatefulTractogram.from_sft( new_strmls, sft) - + # Put back the original space and origin new_sft.to_space(orig_space) new_sft.to_origin(orig_origin) @@ -600,9 +600,9 @@ def _intersects_two_rois(roi_data_1, roi_data_2, strl_indices, # Find all the points of the streamline that are in the ROIs roi_data_1_intersect = map_coordinates( - roi_data_1, strl_indices.T, order=0, mode='constant', cval=0) + roi_data_1, strl_indices.T, order=0, mode='nearest') roi_data_2_intersect = map_coordinates( - roi_data_2, strl_indices.T, order=0, mode='constant', cval=0) + roi_data_2, strl_indices.T, order=0, mode='nearest') # Get the indices of the voxels intersecting with the ROIs in_strl_indices = np.argwhere(roi_data_1_intersect).squeeze(-1) diff --git a/scilpy/tractograms/streamline_operations.py b/src/scilpy/tractograms/streamline_operations.py similarity index 99% rename from scilpy/tractograms/streamline_operations.py rename to src/scilpy/tractograms/streamline_operations.py index 4cfda74d1..e3215bd39 100644 --- a/scilpy/tractograms/streamline_operations.py +++ b/src/scilpy/tractograms/streamline_operations.py @@ -656,6 +656,8 @@ def resample_streamlines_step_size(sft, step_size): # Return to original space resampled_sft.to_space(orig_space) + resampled_sft.streamlines._data = resampled_sft.streamlines._data.astype( + np.float32) return resampled_sft @@ -1101,4 +1103,4 @@ def find_seed_indexes_on_streamlines(seeds, streamlines, atol=1.e-8): raise ValueError('A seed coordinate was not found on streamline.') seed_indexes.append(seed_index) - return seed_indexes + return np.array(seed_indexes, dtype=np.uint32) diff --git a/scripts/__init__.py b/src/scilpy/tractograms/tests/__init__.py similarity index 100% rename from scripts/__init__.py rename to src/scilpy/tractograms/tests/__init__.py diff --git a/scilpy/tractograms/tests/test_dps_and_dpp_management.py b/src/scilpy/tractograms/tests/test_dps_and_dpp_management.py similarity index 98% rename from scilpy/tractograms/tests/test_dps_and_dpp_management.py rename to src/scilpy/tractograms/tests/test_dps_and_dpp_management.py index c32f2eace..6f3dd7e07 100644 --- a/scilpy/tractograms/tests/test_dps_and_dpp_management.py +++ b/src/scilpy/tractograms/tests/test_dps_and_dpp_management.py @@ -70,7 +70,7 @@ def test_add_data_as_color_dpp(): def test_convert_dps_to_dpp(): fake_sft = _get_small_sft() - fake_sft.data_per_streamline['my_dps'] = [5, 6] + fake_sft.data_per_streamline['my_dps'] = np.array([5, 6]) # Converting fake_sft = convert_dps_to_dpp(fake_sft, 'my_dps') @@ -78,7 +78,7 @@ def test_convert_dps_to_dpp(): assert list(fake_sft.data_per_point.keys()) == ['my_dps'] # Add again, will fail. Allow overwrite. - fake_sft.data_per_streamline['my_dps'] = [5, 6] + fake_sft.data_per_streamline['my_dps'] = np.array([5, 6]) failed = False try: _ = convert_dps_to_dpp(fake_sft, 'my_dps') @@ -183,6 +183,7 @@ def test_perform_operation_on_dpp(): # Option 'endpoints only': dpp = perform_operation_on_dpp('max', fake_sft, 'my_dpp', endpoints_only=True) + fake_sft.data_per_point['my_dpp2'] = dpp assert nan_array_equal(dpp[0].squeeze(), [1.0, np.nan, 1]) assert nan_array_equal(dpp[1].squeeze(), [2.0, np.nan, 2]) diff --git a/scilpy/tractograms/tests/test_lazy_tractogram_operations.py b/src/scilpy/tractograms/tests/test_lazy_tractogram_operations.py similarity index 100% rename from scilpy/tractograms/tests/test_lazy_tractogram_operations.py rename to src/scilpy/tractograms/tests/test_lazy_tractogram_operations.py diff --git a/scilpy/tractograms/tests/test_streamline_and_mask_operations.py b/src/scilpy/tractograms/tests/test_streamline_and_mask_operations.py similarity index 99% rename from scilpy/tractograms/tests/test_streamline_and_mask_operations.py rename to src/scilpy/tractograms/tests/test_streamline_and_mask_operations.py index 1305241ec..0289c0db6 100644 --- a/scilpy/tractograms/tests/test_streamline_and_mask_operations.py +++ b/src/scilpy/tractograms/tests/test_streamline_and_mask_operations.py @@ -62,6 +62,7 @@ def _setup_files(): # Load sft sft = load_tractogram(in_sft, reference) + sft.streamlines._data = sft.streamlines._data.astype(np.float32) return sft, reference, head_tail_rois, head_tail_offset_rois, center_roi @@ -395,7 +396,7 @@ def test_compute_streamline_segment(): streamline between two rois. """ - sft, reference, _, head_tail_offset_rois, _ = _setup_files() + sft, _, _, head_tail_offset_rois, _ = _setup_files() sft.to_vox() sft.to_corner() diff --git a/scilpy/tractograms/tests/test_streamline_operations.py b/src/scilpy/tractograms/tests/test_streamline_operations.py similarity index 100% rename from scilpy/tractograms/tests/test_streamline_operations.py rename to src/scilpy/tractograms/tests/test_streamline_operations.py diff --git a/scilpy/tractograms/tests/test_tractogram_operations.py b/src/scilpy/tractograms/tests/test_tractogram_operations.py similarity index 99% rename from scilpy/tractograms/tests/test_tractogram_operations.py rename to src/scilpy/tractograms/tests/test_tractogram_operations.py index fb8112cd7..9d4ef40b4 100644 --- a/scilpy/tractograms/tests/test_tractogram_operations.py +++ b/src/scilpy/tractograms/tests/test_tractogram_operations.py @@ -38,7 +38,7 @@ sft = load_tractogram(in_sft, 'same')[0:4] # Faking data_per_streamline -sft.data_per_streamline['test'] = [1] * len(sft) +sft.data_per_streamline['test'] = np.ones(len(sft)) sft.data_per_point['test2'] = [[[1, 2, 3]] * len(s) for s in sft.streamlines] diff --git a/scilpy/tractograms/tractogram_operations.py b/src/scilpy/tractograms/tractogram_operations.py similarity index 99% rename from scilpy/tractograms/tractogram_operations.py rename to src/scilpy/tractograms/tractogram_operations.py index a8a0cdff7..d2c175458 100644 --- a/scilpy/tractograms/tractogram_operations.py +++ b/src/scilpy/tractograms/tractogram_operations.py @@ -55,7 +55,8 @@ def shuffle_streamlines(sft, rng_seed=None): The shuffled tractogram. """ indices = np.arange(len(sft.streamlines)) - random.shuffle(indices, random=rng_seed) + random.seed(rng_seed) + random.shuffle(indices) streamlines = sft.streamlines[indices] data_per_streamline = sft.data_per_streamline[indices] diff --git a/scilpy/tractograms/uncompress.pyx b/src/scilpy/tractograms/uncompress.pyx similarity index 100% rename from scilpy/tractograms/uncompress.pyx rename to src/scilpy/tractograms/uncompress.pyx diff --git a/scilpy/utils/__init__.py b/src/scilpy/utils/__init__.py similarity index 100% rename from scilpy/utils/__init__.py rename to src/scilpy/utils/__init__.py diff --git a/scilpy/utils/filenames.py b/src/scilpy/utils/filenames.py similarity index 100% rename from scilpy/utils/filenames.py rename to src/scilpy/utils/filenames.py diff --git a/scilpy/utils/metrics_tools.py b/src/scilpy/utils/metrics_tools.py similarity index 100% rename from scilpy/utils/metrics_tools.py rename to src/scilpy/utils/metrics_tools.py diff --git a/scilpy/utils/scilpy_bot.py b/src/scilpy/utils/scilpy_bot.py similarity index 94% rename from scilpy/utils/scilpy_bot.py rename to src/scilpy/utils/scilpy_bot.py index 0bd3563e0..e7a2f1e98 100644 --- a/scilpy/utils/scilpy_bot.py +++ b/src/scilpy/utils/scilpy_bot.py @@ -1,27 +1,23 @@ # -*- coding: utf-8 -*- import ast from colorama import Fore, Style +from importlib.resources import files import pathlib import re import subprocess +from tqdm import tqdm import nltk from nltk.stem import PorterStemmer -from tqdm import tqdm + +from scilpy import SCILPY_HOME SPACING_LEN = 80 stemmer = PorterStemmer() -try: - nltk.download('punkt', quiet=True) - nltk.download('wordnet', quiet=True) -except ImportError: - raise ImportError("You must install the 'nltk' package to use this script." - "Please run 'pip install nltk'.") # Path to the JSON file containing script information and keywords -VOCAB_FILE_PATH = pathlib.Path( - __file__).parent.parent.parent/'data' / 'vocabulary.json' +VOCAB_FILE_PATH = files("scilpy").joinpath("data/vocabulary.json") OBJECTS = [ @@ -205,26 +201,24 @@ def _generate_help_files(): the main scripts directory. """ - scripts_dir = pathlib.Path(__file__).parent.parent.parent / 'scripts' - help_dir = scripts_dir / '.hidden' + scripts_dir = files("scilpy").joinpath("cli") + # Hidden directory to store help files + hidden_dir = pathlib.Path(SCILPY_HOME) / ".hidden" + hidden_dir.mkdir(exist_ok=True) scripts = [script for script in scripts_dir.glob('*.py') if script.name not in ['__init__.py', 'scil_search_keywords.py']] - helps = [help for help in help_dir.glob('*.help')] + helps = [help for help in hidden_dir.glob('*.help')] scripts_to_regenerate = [script for script in scripts - if help_dir / f'{script.name}.help' not in helps] + if hidden_dir / f'{script.name}.help' not in helps] # Check if all help files are present if len(scripts_to_regenerate) == 0: print("All help files are already generated.") return - # Hidden directory to store help files - hidden_dir = scripts_dir / '.hidden' - hidden_dir.mkdir(exist_ok=True) - # Iterate over all scripts and generate help files for script in tqdm(scripts_to_regenerate): help_file = hidden_dir / f'{script.name}.help' diff --git a/scilpy/utils/spatial.py b/src/scilpy/utils/spatial.py similarity index 100% rename from scilpy/utils/spatial.py rename to src/scilpy/utils/spatial.py diff --git a/scilpy/utils/tests/test_scilpy_bot.py b/src/scilpy/utils/tests/test_scilpy_bot.py similarity index 80% rename from scilpy/utils/tests/test_scilpy_bot.py rename to src/scilpy/utils/tests/test_scilpy_bot.py index 9d3ee5303..7177084ba 100644 --- a/scilpy/utils/tests/test_scilpy_bot.py +++ b/src/scilpy/utils/tests/test_scilpy_bot.py @@ -1,3 +1,4 @@ +import pytest from scilpy.utils.scilpy_bot import ( _make_title, _get_docstring_from_script_path, @@ -6,12 +7,16 @@ _extract_keywords_and_phrases, _calculate_score ) +have_nltk = True + +@pytest.mark.skipif(not have_nltk, reason="Requires NLTK") def test_make_title(): result = _make_title("Test Title") assert "Test Title" in result +@pytest.mark.skipif(not have_nltk, reason="Requires NLTK") def test_get_docstring_from_script_path(tmp_path): script_content = '"""This is a test docstring."""' script_path = tmp_path / "test_script.py" @@ -20,6 +25,7 @@ def test_get_docstring_from_script_path(tmp_path): assert result == "This is a test docstring." +@pytest.mark.skipif(not have_nltk, reason="Requires NLTK") def test_split_first_sentence(): text = "This is the first sentence. This is the second sentence." first, remaining = _split_first_sentence(text) @@ -27,24 +33,28 @@ def test_split_first_sentence(): assert remaining == " This is the second sentence." +@pytest.mark.skipif(not have_nltk, reason="Requires NLTK") def test_stem_keywords(): keywords = ["running", "jumps"] result = _stem_keywords(keywords) assert result == ["run", "jump"] +@pytest.mark.skipif(not have_nltk, reason="Requires NLTK") def test_stem_text(): text = "Running and jumping." result = _stem_text(text) assert result == "run and jump ." +@pytest.mark.skipif(not have_nltk, reason="Requires NLTK") def test_stem_phrase(): phrase = "Running quickly" result = _stem_phrase(phrase) assert result == "run quickli" +@pytest.mark.skipif(not have_nltk, reason="Requires NLTK") def test_highlight_keywords(): text = "Running and jumping." stemmed_keywords = ["run"] @@ -52,6 +62,7 @@ def test_highlight_keywords(): assert "Running" in result +@pytest.mark.skipif(not have_nltk, reason="Requires NLTK") def test_get_synonyms(): synonyms_data = [["run", "sprint"], ["jump", "leap"]] result = _get_synonyms("run", synonyms_data) @@ -59,6 +70,7 @@ def test_get_synonyms(): assert len(result) == 2 +@pytest.mark.skipif(not have_nltk, reason="Requires NLTK") def test_extract_keywords_and_phrases(): keywords = ["running", "jumps", "quick run"] result_keywords, result_phrases = _extract_keywords_and_phrases(keywords) @@ -72,6 +84,7 @@ def test_extract_keywords_and_phrases(): assert "quick run" in result_phrases +@pytest.mark.skipif(not have_nltk, reason="Requires NLTK") def test_stem_word_specific(): result = _stem_word("streamlines") assert result == "streamlin" @@ -86,6 +99,7 @@ def test_stem_word_specific(): assert result == "tractometri" +@pytest.mark.skipif(not have_nltk, reason="Requires NLTK") def test_calculate_score(): keywords = ["run"] phrases = ["quick run"] diff --git a/scilpy/version.py b/src/scilpy/version.py similarity index 99% rename from scilpy/version.py rename to src/scilpy/version.py index 538d1e903..298977536 100644 --- a/scilpy/version.py +++ b/src/scilpy/version.py @@ -7,7 +7,7 @@ # Format expected by setup.py and doc/source/conf.py: string of form "X.Y.Z" _version_major = 2 _version_minor = 1 -_version_micro = 0 +_version_micro = 1 _version_extra = '' # Construct full version string from these. diff --git a/scripts/legacy/__init__.py b/src/scilpy/viz/__init__.py similarity index 100% rename from scripts/legacy/__init__.py rename to src/scilpy/viz/__init__.py diff --git a/scripts/tests/__init__.py b/src/scilpy/viz/backends/__init__.py similarity index 100% rename from scripts/tests/__init__.py rename to src/scilpy/viz/backends/__init__.py diff --git a/scilpy/viz/backends/fury.py b/src/scilpy/viz/backends/fury.py similarity index 98% rename from scilpy/viz/backends/fury.py rename to src/scilpy/viz/backends/fury.py index 30f6ab5c3..3cd8888a5 100644 --- a/scilpy/viz/backends/fury.py +++ b/src/scilpy/viz/backends/fury.py @@ -202,7 +202,9 @@ def create_scene(actors, orientation, slice_index, volume_shape, aspect_ratio, def create_interactive_window(scene, window_size, interactor, *, - title="Viewer", open_window=True): + title="Viewer", open_window=True + ): # pragma: no cover + # (Function ignored from coverage statistics) """ Create a 3D window with the content of scene, equiped with an interactor. diff --git a/scilpy/viz/backends/pil.py b/src/scilpy/viz/backends/pil.py similarity index 99% rename from scilpy/viz/backends/pil.py rename to src/scilpy/viz/backends/pil.py index d4c51cf26..731229807 100644 --- a/scilpy/viz/backends/pil.py +++ b/src/scilpy/viz/backends/pil.py @@ -21,6 +21,7 @@ def any2grayscale(array_2d): Returns ------- + Data: np.ndarray Grayscale `unit8` data in [0, 255] range. """ diff --git a/scilpy/viz/backends/vtk.py b/src/scilpy/viz/backends/vtk.py similarity index 100% rename from scilpy/viz/backends/vtk.py rename to src/scilpy/viz/backends/vtk.py diff --git a/scilpy/viz/color.py b/src/scilpy/viz/color.py similarity index 95% rename from scilpy/viz/color.py rename to src/scilpy/viz/color.py index a91a8c8f9..a76159b25 100644 --- a/scilpy/viz/color.py +++ b/src/scilpy/viz/color.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +import logging from dipy.io.stateful_tractogram import StatefulTractogram from fury import colormap @@ -41,7 +42,7 @@ def convert_color_names_to_rgb(names): def generate_n_colors(n, generator=colormap.distinguishable_colormap, - pick_from_base10=True, shuffle=False): + pick_from_base10=True): """ Generate a set of N colors. When using the default parameters, colors will always be unique. When using a custom generator, ensure it generates unique @@ -58,8 +59,6 @@ def generate_n_colors(n, generator=colormap.distinguishable_colormap, pick_from_base10 : bool When True, start picking from the base 10 colors before using the generator funtion (see BASE_COLORS_10). - shuffle : bool - Shuffle the color list before returning. Returns ------- @@ -77,9 +76,6 @@ def generate_n_colors(n, generator=colormap.distinguishable_colormap, (_colors, generator(nb_colors=n - len(_colors), exclude=_colors)), axis=0) - if shuffle: - np.random.shuffle(_colors) - return _colors @@ -167,8 +163,6 @@ def clip_and_normalize_data_for_cmap( the first value of the LUT is set everywhere where data==1, etc. """ # Make sure data type is float - if isinstance(data, list): - data = np.asarray(data) data = data.astype(float) if LUT is not None: @@ -288,7 +282,7 @@ def prepare_colorbar_figure(cmap, lbound, ubound, nb_values=255, nb_ticks=10, def ambiant_occlusion(sft, colors, factor=4): """ Apply ambiant occlusion to a set of colors based on point density - around each points. + around each point. Parameters ---------- @@ -306,6 +300,17 @@ def ambiant_occlusion(sft, colors, factor=4): """ pts = sft.streamlines._data + + if np.min(colors) < 0: + logging.warning("Minimal color in 'color' was less than 0 ({}). Are " + "you sure that this dpp contains colors?" + .format(np.min(colors))) + if np.max(colors) > 1: + # Normalizing + logging.debug("'colors' contained data between 0 and {}, normalizing." + .format(np.max(colors))) + colors = colors / np.max(colors) + hsv = mcolors.rgb_to_hsv(colors) tree = KDTree(pts) diff --git a/scilpy/viz/gradients.py b/src/scilpy/viz/gradients.py similarity index 80% rename from scilpy/viz/gradients.py rename to src/scilpy/viz/gradients.py index cfcc8cabb..9dc72b2ae 100644 --- a/scilpy/viz/gradients.py +++ b/src/scilpy/viz/gradients.py @@ -14,7 +14,7 @@ def plot_each_shell(ms, centroids, plot_sym_vecs=True, use_sphere=True, same_color=False, rad=0.025, opacity=1.0, ofile=None, - ores=(300, 300), titles=None): + ores=(300, 300), titles=None, silent=False): """ Plot each shell @@ -35,11 +35,14 @@ def plot_each_shell(ms, centroids, plot_sym_vecs=True, use_sphere=True, opacity: float opacity for the shells ofile: str - output filename + output filename. If not set, no output will be saved. ores: tuple resolution of the output png titles: list of str titles for the windows, one per shell + silent: bool + If True, skips interactive visualization. In that case, titles will + not be added to the window. """ _colors = generate_n_colors(len(ms)) @@ -69,19 +72,20 @@ def plot_each_shell(ms, centroids, plot_sym_vecs=True, use_sphere=True, if plot_sym_vecs: pts_actor = actor.point(-shell, _colors[i], point_radius=rad) scene.add(pts_actor) - if titles is not None: - if len(titles) == len(ms): - window.show(scene, title=titles[i]) - elif isinstance(titles, str): - window.show(scene, title=titles) - elif len(titles) == 1: - window.show(scene, title=titles[0]) + if not silent: + if titles is not None: + if len(titles) == len(ms): + window.show(scene, title=titles[i]) + elif isinstance(titles, str): + window.show(scene, title=titles) + elif len(titles) == 1: + window.show(scene, title=titles[0]) + else: + logging.warning('No title could be added to the windows ' + 'since the given format is incorrect.') + window.show(scene) else: - logging.warning('No title could be added to the windows since ' - 'the given format is incorrect.') window.show(scene) - else: - window.show(scene) if ofile: filename = ofile + '_shell_' + str(int(centroids[i])) + '.png' @@ -94,7 +98,7 @@ def plot_each_shell(ms, centroids, plot_sym_vecs=True, use_sphere=True, def plot_proj_shell(ms, use_sym=True, use_sphere=True, same_color=False, rad=0.025, opacity=1.0, ofile=None, ores=(300, 300), - title=None): + title=None, silent=None): """ Plot each shell @@ -113,11 +117,14 @@ def plot_proj_shell(ms, use_sym=True, use_sphere=True, same_color=False, opacity: float opacity for the shells ofile: str - output filename + output filename. If not set, no output will be saved. ores: tuple resolution of the output png title: str title for the window + silent: bool + If True, skips interactive visualization. Useful for debugging. + In that case, titles will not be added to the window. """ _colors = generate_n_colors(len(ms)) @@ -146,10 +153,12 @@ def plot_proj_shell(ms, use_sym=True, use_sphere=True, same_color=False, if use_sym: pts_actor = actor.point(-shell, _colors[i], point_radius=rad) scene.add(pts_actor) - if title is not None: - window.show(scene, title=title) - else: - window.show(scene) + if not silent: + if title is not None: + window.show(scene, title=title) + else: + window.show(scene) + if ofile: filename = ofile + '.png' # Legacy. When this snapshotting gets updated to align with the @@ -177,7 +186,7 @@ def build_ms_from_shell_idx(bvecs, shell_idx): """ S = len(set(shell_idx)) - if (-1 in set(shell_idx)): + if -1 in set(shell_idx): S -= 1 ms = [] diff --git a/scilpy/viz/legacy/__init__.py b/src/scilpy/viz/legacy/__init__.py similarity index 100% rename from scilpy/viz/legacy/__init__.py rename to src/scilpy/viz/legacy/__init__.py diff --git a/scilpy/viz/legacy/chord_chart.py b/src/scilpy/viz/legacy/chord_chart.py similarity index 100% rename from scilpy/viz/legacy/chord_chart.py rename to src/scilpy/viz/legacy/chord_chart.py diff --git a/scilpy/viz/plot.py b/src/scilpy/viz/plot.py similarity index 100% rename from scilpy/viz/plot.py rename to src/scilpy/viz/plot.py diff --git a/scilpy/viz/screenshot.py b/src/scilpy/viz/screenshot.py similarity index 98% rename from scilpy/viz/screenshot.py rename to src/scilpy/viz/screenshot.py index 9424890b0..4c509d92a 100644 --- a/scilpy/viz/screenshot.py +++ b/src/scilpy/viz/screenshot.py @@ -31,6 +31,8 @@ def screenshot_volume(img, orientation, slice_ids, size, labelmap=None): Slice indices. size : array-like Size of the screenshot image (pixels). + labelmap: str, vtkLookupTable, optional + Either a vtk lookup table or a matplotlib colormap name. Returns ------- @@ -157,7 +159,7 @@ def compose_image(img_scene, img_size, slice_number, *, corner_position=(0, 0), Labelmap scene data. labelmap_alpha : float Alpha value for labelmap overlay in range [0, 1]. - overlays_scene : np.ndarray, optional + overlays_scene : list[np.ndarray], optional Overlays scene data. overlays_alpha : float Alpha value for the overlays in range [0, 1]. diff --git a/scilpy/viz/slice.py b/src/scilpy/viz/slice.py similarity index 94% rename from scilpy/viz/slice.py rename to src/scilpy/viz/slice.py index 5f10d3705..a53bb9d3e 100644 --- a/scilpy/viz/slice.py +++ b/src/scilpy/viz/slice.py @@ -41,7 +41,7 @@ def create_texture_slicer(texture, orientation, slice_index, *, mask=None, offset : float The offset of the texture image. Defaults to 0.5. lut : str, vtkLookupTable, optional - Either a vtk lookup table or a matplotlib name for one. + Either a vtk lookup table or a matplotlib colormap name. interpolation : str Interpolation mode for the texture image. Choices are nearest or linear. Defaults to nearest. @@ -235,6 +235,8 @@ def create_odf_slicer(sh_fodf, orientation, slice_index, sphere, sh_order, Factor that multiplies sqrt(variance). variance_color : tuple, optional Color of the variance fODF data, in RGB. + is_legacy: bool + Whether the SH basis is used in legacy formats [True]. Returns ------- @@ -282,8 +284,10 @@ def create_bingham_slicer(data, orientation, slice_index, Parameters ---------- - data: ndarray (X, Y, Z, 9 * nb_lobes) - The Bingham volume. + data: Array + Volume of shape (X, Y, Z, N_LOBES, NB_PARAMS) containing + the Bingham distributions parameters. Note, NB_PARAMS is usually 7. + One of X, Y, Z should be of value 1 (one slice). orientation: str Name of the axis to visualize. Choices are axial, coronal and sagittal. slice_index: int @@ -300,10 +304,14 @@ def create_bingham_slicer(data, orientation, slice_index, ODF slicer actors representing the Bingham distributions. """ shape = data.shape + if len(shape) != 5: + raise ValueError('Expecting bingham data to be 5D ' + '(x, y, z, N_LOBES, NB_PARAMS), but got {}' + .format(shape)) nb_lobes = shape[-2] colors = [c * 255 for c in generate_n_colors(nb_lobes)] - # lmax norm for normalization + # lmax norm for normalization: first bingham param, averaged on lobes lmaxnorm = np.max(np.abs(data[..., 0]), axis=-1) bingham_sf = bingham_to_sf(data, sphere.vertices) diff --git a/scilpy/viz/utils.py b/src/scilpy/viz/utils.py similarity index 100% rename from scilpy/viz/utils.py rename to src/scilpy/viz/utils.py