Skip to content

Commit

Permalink
[FIX] Correct the pet-linear pipeline (#1348)
Browse files Browse the repository at this point in the history
* Use T1W linear for non linear registration

* run precommit

* Update clinica/pipelines/pet/linear/pipeline.py

* Update clinica/pipelines/pet/linear/pipeline.py

---------

Co-authored-by: Gensollen <[email protected]>
  • Loading branch information
ravih18 and NicolasGensollen authored Oct 24, 2024
1 parent 48c12ab commit 00e1839
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions clinica/pipelines/pet/linear/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get_input_fields(self) -> List[str]:
list of str :
A list of (string) input fields name.
"""
return ["pet", "t1w", "t1w_to_mni"]
return ["pet", "t1w", "t1w_to_mni", "t1w_linear"]

def get_output_fields(self) -> List[str]:
"""Specify the list of possible outputs of this pipeline.
Expand Down Expand Up @@ -66,7 +66,12 @@ def _build_input_node(self):
ClinicaException,
)
from clinica.utils.image import get_mni_template
from clinica.utils.input_files import T1W_NII, T1W_TO_MNI_TRANSFORM
from clinica.utils.input_files import (
T1W_LINEAR,
T1W_LINEAR_CROPPED,
T1W_NII,
T1W_TO_MNI_TRANSFORM,
)
from clinica.utils.inputs import (
clinica_file_reader,
format_clinica_file_reader_errors,
Expand Down Expand Up @@ -101,6 +106,21 @@ def _build_input_node(self):
)

# Inputs from t1-linear pipeline
# T1w images registered
t1w_linear_file_pattern = (
T1W_LINEAR
if self.parameters.get("uncropped_image", False)
else T1W_LINEAR_CROPPED
)
t1w_linear_files, t1w_linear_errors = clinica_file_reader(
self.subjects, self.sessions, self.caps_directory, t1w_linear_file_pattern
)
if t1w_linear_errors:
raise ClinicaCAPSError(
format_clinica_file_reader_errors(
t1w_linear_errors, t1w_linear_file_pattern
)
)
# Transformation files from T1w files to MNI:
t1w_to_mni_transformation_files, t1w_to_mni_errors = clinica_file_reader(
self.subjects, self.sessions, self.caps_directory, T1W_TO_MNI_TRANSFORM
Expand All @@ -122,6 +142,7 @@ def _build_input_node(self):
("t1w", t1w_files),
("pet", pet_files),
("t1w_to_mni", t1w_to_mni_transformation_files),
("t1w_linear", t1w_linear_files),
],
synchronize=True,
interface=nutil.IdentityInterface(fields=self.get_input_fields()),
Expand All @@ -131,6 +152,7 @@ def _build_input_node(self):
(read_input_node, self.input_node, [("t1w", "t1w")]),
(read_input_node, self.input_node, [("pet", "pet")]),
(read_input_node, self.input_node, [("t1w_to_mni", "t1w_to_mni")]),
(read_input_node, self.input_node, [("t1w_linear", "t1w_linear")]),
]
)

Expand Down Expand Up @@ -392,12 +414,12 @@ def _build_core_nodes(self):
(
self.input_node,
ants_registration_nonlinear_node,
[("t1w", "moving_image")],
[("t1w_linear", "moving_image")],
),
(
ants_registration_nonlinear_node,
ants_applytransform_nonlinear_node,
[("reverse_forward_transforms", "transforms")],
[("forward_transforms", "transforms")],
),
(
ants_applytransform_node,
Expand Down

0 comments on commit 00e1839

Please sign in to comment.