Skip to content

Commit

Permalink
[REF] Move class PETPipeline to new clinica.pipelines.pet module (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasGensollen authored Jul 8, 2024
1 parent 0659783 commit 70afb52
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 28 deletions.
25 changes: 0 additions & 25 deletions clinica/pipelines/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1001,28 +1001,3 @@ def _check_custom_dependencies(self) -> None:
@abc.abstractmethod
def _check_pipeline_parameters(self) -> None:
"""Check pipeline parameters."""


class PETPipeline(Pipeline):
def _check_pipeline_parameters(self) -> None:
"""Check pipeline parameters."""
if "acq_label" not in self.parameters.keys():
raise KeyError("Missing compulsory acq_label key in pipeline parameter.")
self.parameters.setdefault("reconstruction_method", None)

def _get_pet_scans_query(self) -> dict:
"""Return the query to retrieve PET scans."""
from clinica.utils.input_files import bids_pet_nii
from clinica.utils.pet import ReconstructionMethod, Tracer

pet_tracer = None
if self.parameters["acq_label"] is not None:
pet_tracer = Tracer(self.parameters["acq_label"])

reconstruction_method = None
if self.parameters["reconstruction_method"] is not None:
reconstruction_method = ReconstructionMethod(
self.parameters["reconstruction_method"]
)

return bids_pet_nii(pet_tracer, reconstruction_method)
Empty file.
26 changes: 26 additions & 0 deletions clinica/pipelines/pet/engine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from clinica.pipelines.engine import Pipeline


class PETPipeline(Pipeline):
def _check_pipeline_parameters(self) -> None:
"""Check pipeline parameters."""
if "acq_label" not in self.parameters.keys():
raise KeyError("Missing compulsory acq_label key in pipeline parameter.")
self.parameters.setdefault("reconstruction_method", None)

def _get_pet_scans_query(self) -> dict:
"""Return the query to retrieve PET scans."""
from clinica.utils.input_files import bids_pet_nii
from clinica.utils.pet import ReconstructionMethod, Tracer

pet_tracer = None
if self.parameters["acq_label"] is not None:
pet_tracer = Tracer(self.parameters["acq_label"])

reconstruction_method = None
if self.parameters["reconstruction_method"] is not None:
reconstruction_method = ReconstructionMethod(
self.parameters["reconstruction_method"]
)

return bids_pet_nii(pet_tracer, reconstruction_method)
2 changes: 1 addition & 1 deletion clinica/pipelines/pet_linear/pet_linear_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from nipype import config

from clinica.pipelines.engine import PETPipeline
from clinica.pipelines.pet.engine import PETPipeline

cfg = dict(execution={"parameterize_dirs": False})
config.update_config(cfg)
Expand Down
2 changes: 1 addition & 1 deletion clinica/pipelines/pet_surface/pet_surface_pipeline.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List

from clinica.pipelines.engine import PETPipeline
from clinica.pipelines.pet.engine import PETPipeline


class PetSurface(PETPipeline):
Expand Down
2 changes: 1 addition & 1 deletion clinica/pipelines/pet_volume/pet_volume_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from nipype import config

from clinica.pipelines.engine import PETPipeline
from clinica.pipelines.pet.engine import PETPipeline

# Use hash instead of parameters for iterables folder names
# Otherwise path will be too long and generate OSError
Expand Down

0 comments on commit 70afb52

Please sign in to comment.