diff --git a/clinica/pipelines/pet/volume/pipeline.py b/clinica/pipelines/pet/volume/pipeline.py index 6bb6e9393..201f787dc 100644 --- a/clinica/pipelines/pet/volume/pipeline.py +++ b/clinica/pipelines/pet/volume/pipeline.py @@ -1,5 +1,3 @@ -from typing import List - from nipype import config from clinica.pipelines.engine import GroupPipeline @@ -34,7 +32,7 @@ def _check_custom_dependencies(self) -> None: """Check dependencies that can not be listed in the `info.json` file.""" pass - def get_input_fields(self) -> List[str]: + def get_input_fields(self) -> list[str]: """Specify the list of possible inputs of this pipeline. Returns @@ -53,7 +51,7 @@ def get_input_fields(self) -> List[str]: "reference_mask", ] - def get_output_fields(self) -> List[str]: + def get_output_fields(self) -> list[str]: """Specify the list of possible outputs of this pipeline. Returns diff --git a/clinica/pipelines/pet/volume/utils.py b/clinica/pipelines/pet/volume/utils.py index 994288756..327e5722f 100644 --- a/clinica/pipelines/pet/volume/utils.py +++ b/clinica/pipelines/pet/volume/utils.py @@ -1,6 +1,6 @@ from os import PathLike from pathlib import Path -from typing import List, Tuple, Union +from typing import Union import nibabel as nib import numpy as np @@ -35,7 +35,7 @@ def init_input_node(pet_nii: str) -> str: return pet_nii -def _check_non_empty_tissue_list(tissues: List[PathLike]) -> None: +def _check_non_empty_tissue_list(tissues: list[PathLike]) -> None: """Check that provided list is non-empty.""" if len(tissues) == 0: raise RuntimeError( @@ -44,8 +44,8 @@ def _check_non_empty_tissue_list(tissues: List[PathLike]) -> None: def _aggregate_tissue_images( - tissues: List[PathLike], -) -> Tuple[np.ndarray, np.ndarray, Nifti1Header]: + tissues: list[PathLike], +) -> tuple[np.ndarray, np.ndarray, Nifti1Header]: """Aggregates the image data contained in the tissue images provided. Parameters @@ -74,7 +74,7 @@ def _aggregate_tissue_images( return data, first_image.affine, first_image.header -def create_binary_mask(tissues: List[PathLike], threshold: float = 0.3) -> Path: +def create_binary_mask(tissues: list[PathLike], threshold: float = 0.3) -> Path: """Create a binary mask Nifti1Image from the list of tissues. Tissue images are summed and the result is thresholded with the @@ -135,7 +135,7 @@ def apply_binary_mask(image: Path, binary_mask: Path) -> Path: return masked_image_path -def create_pvc_mask(tissues: List[PathLike]) -> Path: +def create_pvc_mask(tissues: list[PathLike]) -> Path: """Create a pvc mask from tissue list. Parameters @@ -224,7 +224,7 @@ def normalize_to_reference(pet_image: Path, region_mask: Path) -> Path: return suvr_pet_path -def compute_atlas_statistics(image: Path, atlas_names: List[str]) -> List[Path]: +def compute_atlas_statistics(image: Path, atlas_names: list[str]) -> list[Path]: """Generate regional measure from atlas_list in TSV files. For each atlas name provided it calculates for the input image the mean diff --git a/clinica/pipelines/t1_volume_tissue_segmentation/t1_volume_tissue_segmentation_utils.py b/clinica/pipelines/t1_volume_tissue_segmentation/t1_volume_tissue_segmentation_utils.py index 46120e9fe..a1e7c8c5d 100644 --- a/clinica/pipelines/t1_volume_tissue_segmentation/t1_volume_tissue_segmentation_utils.py +++ b/clinica/pipelines/t1_volume_tissue_segmentation/t1_volume_tissue_segmentation_utils.py @@ -7,11 +7,10 @@ from nipype.interfaces.base import ( File, InputMultiPath, - OutputMultiPath, - TraitedSpec, traits, ) -from nipype.interfaces.spm.base import SPMCommand, SPMCommandInputSpec +from nipype.interfaces.spm.base import SPMCommandInputSpec +from nipype.interfaces.spm.preprocess import ApplyDeformations from nipype.utils.filemanip import filename_to_list, list_to_filename @@ -129,11 +128,7 @@ class ApplySegmentationDeformationInput(SPMCommandInputSpec): ) -class ApplySegmentationDeformationOutput(TraitedSpec): - out_files = OutputMultiPath(File(exists=True), desc="Transformed files") - - -class ApplySegmentationDeformation(SPMCommand): +class ApplySegmentationDeformation(ApplyDeformations): """Uses SPM to apply a deformation field obtained from Segmentation routine to a given file Examples @@ -147,10 +142,6 @@ class ApplySegmentationDeformation(SPMCommand): """ input_spec = ApplySegmentationDeformationInput - output_spec = ApplySegmentationDeformationOutput - - _jobtype = "util" - _jobname = "defs" def _format_arg(self, opt, spec, val): """Convert input to appropriate format for spm""" @@ -159,11 +150,3 @@ def _format_arg(self, opt, spec, val): if opt == "in_files": return np.array(filename_to_list(val), dtype=object) return val - - def _list_outputs(self): - outputs = self._outputs().get() - outputs["out_files"] = [] - for filename in self.inputs.in_files: - _, fname = os.path.split(filename) - outputs["out_files"].append(os.path.realpath("w%s" % fname)) - return outputs