Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions clinica/pipelines/pet/volume/pipeline.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import List

from nipype import config

from clinica.pipelines.engine import GroupPipeline
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
14 changes: 7 additions & 7 deletions clinica/pipelines/pet/volume/utils.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand All @@ -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"""
Expand All @@ -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