diff --git a/clinica/pipelines/dwi_preprocessing_using_t1/__init__.py b/clinica/pipelines/dwi_preprocessing_using_t1/__init__.py index d65db5ea0c..f00831fce2 100644 --- a/clinica/pipelines/dwi_preprocessing_using_t1/__init__.py +++ b/clinica/pipelines/dwi_preprocessing_using_t1/__init__.py @@ -1 +1 @@ -from . import dwi_preprocessing_using_t1_cli +from . import cli diff --git a/clinica/pipelines/dwi_preprocessing_using_t1/dwi_preprocessing_using_t1_cli.py b/clinica/pipelines/dwi_preprocessing_using_t1/cli.py similarity index 96% rename from clinica/pipelines/dwi_preprocessing_using_t1/dwi_preprocessing_using_t1_cli.py rename to clinica/pipelines/dwi_preprocessing_using_t1/cli.py index 224196cb4d..80f17a17c3 100644 --- a/clinica/pipelines/dwi_preprocessing_using_t1/dwi_preprocessing_using_t1_cli.py +++ b/clinica/pipelines/dwi_preprocessing_using_t1/cli.py @@ -43,7 +43,7 @@ def cli( from clinica.utils.ux import print_end_pipeline - from .dwi_preprocessing_using_t1_pipeline import DwiPreprocessingUsingT1 + from .pipeline import DwiPreprocessingUsingT1 parameters = { "low_bval": low_bval, diff --git a/clinica/pipelines/dwi_preprocessing_using_t1/dwi_preprocessing_using_t1_pipeline.py b/clinica/pipelines/dwi_preprocessing_using_t1/pipeline.py similarity index 98% rename from clinica/pipelines/dwi_preprocessing_using_t1/dwi_preprocessing_using_t1_pipeline.py rename to clinica/pipelines/dwi_preprocessing_using_t1/pipeline.py index c4a2486a3f..2b18a98690 100644 --- a/clinica/pipelines/dwi_preprocessing_using_t1/dwi_preprocessing_using_t1_pipeline.py +++ b/clinica/pipelines/dwi_preprocessing_using_t1/pipeline.py @@ -176,7 +176,7 @@ def build_output_node(self): from clinica.utils.nipype import container_from_filename, fix_join - from .dwi_preprocessing_using_t1_utils import rename_into_caps + from .utils import rename_into_caps container_path = npe.Node( nutil.Function( @@ -257,15 +257,12 @@ def build_core_nodes(self): from clinica.utils.dwi import compute_average_b0_task - from .dwi_preprocessing_using_t1_utils import ( + from .utils import ( init_input_node, prepare_reference_b0_task, print_end_pipeline, ) - from .dwi_preprocessing_using_t1_workflows import ( - eddy_fsl_pipeline, - epi_pipeline, - ) + from .workflows import eddy_fsl_pipeline, epi_pipeline init_node = npe.Node( interface=nutil.Function( diff --git a/clinica/pipelines/dwi_preprocessing_using_t1/dwi_preprocessing_using_t1_utils.py b/clinica/pipelines/dwi_preprocessing_using_t1/utils.py similarity index 98% rename from clinica/pipelines/dwi_preprocessing_using_t1/dwi_preprocessing_using_t1_utils.py rename to clinica/pipelines/dwi_preprocessing_using_t1/utils.py index bc28eb2ee4..f268be1f79 100644 --- a/clinica/pipelines/dwi_preprocessing_using_t1/dwi_preprocessing_using_t1_utils.py +++ b/clinica/pipelines/dwi_preprocessing_using_t1/utils.py @@ -88,7 +88,7 @@ def broadcast_matrix_filename_to_match_b_vector_length( """Return a list of the matrix filename repeated as many times as there are B-vectors.""" import numpy as np - from clinica.pipelines.dwi_preprocessing_using_t1.dwi_preprocessing_using_t1_utils import ( # noqa + from clinica.pipelines.dwi_preprocessing_using_t1.utils import ( # noqa broadcast_filename_into_list, ) @@ -287,7 +287,7 @@ def prepare_reference_b0_task( """Task called be Nipype to execute prepare_reference_b0.""" from pathlib import Path - from clinica.pipelines.dwi_preprocessing_using_t1.dwi_preprocessing_using_t1_utils import ( # noqa + from clinica.pipelines.dwi_preprocessing_using_t1.utils import ( # noqa prepare_reference_b0, ) from clinica.utils.dwi import DWIDataset @@ -496,9 +496,7 @@ def register_b0( If the pipeline ran successfully, this file should be located in : working_directory / b0_coregistration / concat_ref_moving / merged_files.nii.gz """ - from clinica.pipelines.dwi_preprocessing_using_t1.dwi_preprocessing_using_t1_workflows import ( - b0_flirt_pipeline, - ) + from clinica.pipelines.dwi_preprocessing_using_t1.workflows import b0_flirt_pipeline b0_flirt = b0_flirt_pipeline(num_b0s=nb_b0s) b0_flirt.inputs.inputnode.in_file = str(extracted_b0_filename) diff --git a/clinica/pipelines/dwi_preprocessing_using_t1/dwi_preprocessing_using_t1_workflows.py b/clinica/pipelines/dwi_preprocessing_using_t1/workflows.py similarity index 99% rename from clinica/pipelines/dwi_preprocessing_using_t1/dwi_preprocessing_using_t1_workflows.py rename to clinica/pipelines/dwi_preprocessing_using_t1/workflows.py index 1213b4ee58..6882a694f4 100644 --- a/clinica/pipelines/dwi_preprocessing_using_t1/dwi_preprocessing_using_t1_workflows.py +++ b/clinica/pipelines/dwi_preprocessing_using_t1/workflows.py @@ -83,10 +83,7 @@ def eddy_fsl_pipeline( from nipype.interfaces.fsl import BET from nipype.interfaces.fsl.epi import Eddy - from .dwi_preprocessing_using_t1_utils import ( - generate_acq_file_task, - generate_index_file_task, - ) + from .utils import generate_acq_file_task, generate_index_file_task inputnode = pe.Node( niu.IdentityInterface( @@ -397,7 +394,7 @@ def perform_ants_registration( import nipype.interfaces.utility as niu import nipype.pipeline.engine as pe - from .dwi_preprocessing_using_t1_utils import ( + from .utils import ( broadcast_matrix_filename_to_match_b_vector_length, change_itk_transform_type, rotate_b_vectors, @@ -605,8 +602,6 @@ def perform_dwi_epi_correction( This workflow benefits a lot from parallelization as most operations are done on single DWI direction. """ - import os - import nipype.interfaces.ants as ants import nipype.interfaces.fsl as fsl import nipype.interfaces.io as nio diff --git a/test/nonregression/pipelines/dwi/preprocessing/using_t1/test_full_t1_pipeline.py b/test/nonregression/pipelines/dwi/preprocessing/using_t1/test_full_t1_pipeline.py index 67f6166d25..d78ff6ef9c 100644 --- a/test/nonregression/pipelines/dwi/preprocessing/using_t1/test_full_t1_pipeline.py +++ b/test/nonregression/pipelines/dwi/preprocessing/using_t1/test_full_t1_pipeline.py @@ -23,7 +23,7 @@ def test_dwi_preprocessing_using_t1(cmdopt, tmp_path): def run_dwi_preprocessing_using_t1( input_dir: Path, output_dir: Path, ref_dir: Path, working_dir: Path ) -> None: - from clinica.pipelines.dwi_preprocessing_using_t1.dwi_preprocessing_using_t1_pipeline import ( + from clinica.pipelines.dwi_preprocessing_using_t1.pipeline import ( DwiPreprocessingUsingT1, ) diff --git a/test/nonregression/pipelines/dwi/preprocessing/using_t1/test_t1_sub_workflows.py b/test/nonregression/pipelines/dwi/preprocessing/using_t1/test_t1_sub_workflows.py index 1e095b0860..4c28fc7bd1 100644 --- a/test/nonregression/pipelines/dwi/preprocessing/using_t1/test_t1_sub_workflows.py +++ b/test/nonregression/pipelines/dwi/preprocessing/using_t1/test_t1_sub_workflows.py @@ -15,9 +15,7 @@ @pytest.mark.fast def test_dwi_b0_flirt(cmdopt, tmp_path): - from clinica.pipelines.dwi_preprocessing_using_t1.dwi_preprocessing_using_t1_workflows import ( - b0_flirt_pipeline, - ) + from clinica.pipelines.dwi_preprocessing_using_t1.workflows import b0_flirt_pipeline base_dir = Path(cmdopt["input"]) input_dir, tmp_dir, ref_dir = configure_paths(base_dir, tmp_path, "DWIB0Flirt") @@ -41,9 +39,7 @@ def test_dwi_b0_flirt(cmdopt, tmp_path): @pytest.mark.slow def test_dwi_epi_pipeline(cmdopt, tmp_path): - from clinica.pipelines.dwi_preprocessing_using_t1.dwi_preprocessing_using_t1_workflows import ( - epi_pipeline, - ) + from clinica.pipelines.dwi_preprocessing_using_t1.workflows import epi_pipeline base_dir = Path(cmdopt["input"]) input_dir, tmp_dir, ref_dir = configure_paths(base_dir, tmp_path, "DWIEPIPipeline") @@ -89,7 +85,7 @@ def test_dwi_perform_ants_registration(cmdopt, tmp_path): import nibabel as nib - from clinica.pipelines.dwi_preprocessing_using_t1.dwi_preprocessing_using_t1_workflows import ( + from clinica.pipelines.dwi_preprocessing_using_t1.workflows import ( perform_ants_registration, ) @@ -152,7 +148,7 @@ def test_dwi_perform_ants_registration(cmdopt, tmp_path): @pytest.mark.slow def test_dwi_perform_dwi_epi_correction(cmdopt, tmp_path): - from clinica.pipelines.dwi_preprocessing_using_t1.dwi_preprocessing_using_t1_workflows import ( + from clinica.pipelines.dwi_preprocessing_using_t1.workflows import ( perform_dwi_epi_correction, ) @@ -192,9 +188,7 @@ def test_dwi_perform_dwi_epi_correction(cmdopt, tmp_path): @pytest.mark.slow def test_dwi_eddy_fsl(cmdopt, tmp_path): - from clinica.pipelines.dwi_preprocessing_using_t1.dwi_preprocessing_using_t1_workflows import ( - eddy_fsl_pipeline, - ) + from clinica.pipelines.dwi_preprocessing_using_t1.workflows import eddy_fsl_pipeline base_dir = Path(cmdopt["input"]) input_dir, tmp_dir, ref_dir = configure_paths(base_dir, tmp_path, "DWIEddyFSL") diff --git a/test/unittests/pipelines/dwi_preprocessing_using_t1/test_dwi_preprocessing_using_t1_utils.py b/test/unittests/pipelines/dwi_preprocessing_using_t1/test_dwi_preprocessing_using_t1_utils.py index 2e62e37d9a..bc9339cf68 100644 --- a/test/unittests/pipelines/dwi_preprocessing_using_t1/test_dwi_preprocessing_using_t1_utils.py +++ b/test/unittests/pipelines/dwi_preprocessing_using_t1/test_dwi_preprocessing_using_t1_utils.py @@ -2,7 +2,7 @@ import pytest from numpy.testing import assert_array_almost_equal, assert_array_equal -from clinica.pipelines.dwi_preprocessing_using_t1.dwi_preprocessing_using_t1_utils import ( +from clinica.pipelines.dwi_preprocessing_using_t1.utils import ( broadcast_matrix_filename_to_match_b_vector_length, change_itk_transform_type, extract_sub_ses_folder_name, @@ -181,7 +181,7 @@ def test_rotate_b_vectors_wrong_content_in_vector_file(tmp_path): def test_configure_working_directory(tmp_path): import hashlib - from clinica.pipelines.dwi_preprocessing_using_t1.dwi_preprocessing_using_t1_utils import ( + from clinica.pipelines.dwi_preprocessing_using_t1.utils import ( configure_working_directory, ) @@ -199,9 +199,7 @@ def test_configure_working_directory(tmp_path): def test_compute_reference_b0_errors(tmp_path): import numpy as np - from clinica.pipelines.dwi_preprocessing_using_t1.dwi_preprocessing_using_t1_utils import ( - compute_reference_b0, - ) + from clinica.pipelines.dwi_preprocessing_using_t1.utils import compute_reference_b0 (tmp_path / "b0.nii.gz").touch() np.savetxt(tmp_path / "foo.bval", [1000] * 9) @@ -221,9 +219,7 @@ def test_compute_reference_b0_with_single_b0(tmp_path): import numpy as np from numpy.testing import assert_array_equal - from clinica.pipelines.dwi_preprocessing_using_t1.dwi_preprocessing_using_t1_utils import ( - compute_reference_b0, - ) + from clinica.pipelines.dwi_preprocessing_using_t1.utils import compute_reference_b0 b0_data = 4.0 * np.ones((5, 5, 5, 1)) b0_img = nib.Nifti1Image(b0_data, affine=np.eye(4)) @@ -258,9 +254,7 @@ def test_compute_reference_b0_with_multiple_b0(tmp_path, mocker, clean_working_d import numpy as np from numpy.testing import assert_array_equal - from clinica.pipelines.dwi_preprocessing_using_t1.dwi_preprocessing_using_t1_utils import ( - compute_reference_b0, - ) + from clinica.pipelines.dwi_preprocessing_using_t1.utils import compute_reference_b0 working_directory = tmp_path / "tmp" working_directory.mkdir() @@ -273,7 +267,7 @@ def test_compute_reference_b0_with_multiple_b0(tmp_path, mocker, clean_working_d assert not mocked_output.exists() mocked_output.parent.mkdir(parents=True) mocker.patch( - "clinica.pipelines.dwi_preprocessing_using_t1.dwi_preprocessing_using_t1_utils.register_b0", + "clinica.pipelines.dwi_preprocessing_using_t1.utils.register_b0", return_value=mocked_output, ) # Build a dataset with 3 B0 volumes @@ -325,14 +319,12 @@ def test_prepare_reference_b0(tmp_path, mocker): import numpy as np from numpy.testing import assert_array_equal - from clinica.pipelines.dwi_preprocessing_using_t1.dwi_preprocessing_using_t1_utils import ( - prepare_reference_b0, - ) + from clinica.pipelines.dwi_preprocessing_using_t1.utils import prepare_reference_b0 from clinica.utils.dwi import DWIDataset mocked_output = tmp_path / "reference_b0_volume.nii.gz" mocker.patch( - "clinica.pipelines.dwi_preprocessing_using_t1.dwi_preprocessing_using_t1_utils.compute_reference_b0", + "clinica.pipelines.dwi_preprocessing_using_t1.utils.compute_reference_b0", return_value=mocked_output, ) ref_b0_data = 5.0 * np.ones((5, 5, 5, 1))