Skip to content

Commit

Permalink
ENH: Enable setting the random seed for pet-linear
Browse files Browse the repository at this point in the history
  • Loading branch information
ghisvail committed May 28, 2023
1 parent 9e105da commit 431ea2a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions clinica/pipelines/pet_linear/pet_linear_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@
@cli_param.argument.acq_label
@cli_param.argument.suvr_reference_region
@cli_param.option_group.pipeline_specific_options
@cli_param.option_group.option(
@cli_param.option.option(
"-ui",
"--uncropped_image",
is_flag=True,
help="Do not crop the image with template (cropped image are suggested for using with DL models)",
)
@cli_param.option_group.option(
@cli_param.option.option(
"--save_pet_in_t1w_space",
is_flag=True,
help="Save the PET image in the T1w space computed in the intermediate step of the pipeline",
)
@cli_param.option.random_seed
@cli_param.option_group.common_pipelines_options
@cli_param.option.subjects_sessions_tsv
@cli_param.option.working_directory
Expand All @@ -37,6 +38,7 @@ def cli(
suvr_reference_region: str,
uncropped_image: bool = False,
save_pet_in_t1w_space: bool = False,
random_seed: Optional[int] = None,
subjects_sessions_tsv: Optional[str] = None,
working_directory: Optional[str] = None,
n_procs: Optional[int] = None,
Expand Down Expand Up @@ -64,6 +66,7 @@ def cli(
"suvr_reference_region": suvr_reference_region,
"uncropped_image": uncropped_image,
"save_PETinT1w": save_pet_in_t1w_space,
"random_seed": random_seed,
}

pipeline = PETLinear(
Expand Down
6 changes: 5 additions & 1 deletion clinica/pipelines/pet_linear/pet_linear_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ def build_core_nodes(self):
ants_applytransform_nonlinear_node.inputs.dimension = 3
ants_applytransform_nonlinear_node.inputs.reference_image = self.ref_template

if random_seed := self.parameters.get("random_seed", None):
ants_registration_nonlinear_node.inputs.random_seed = random_seed

normalize_intensity_node = npe.Node(
name="intensityNormalization",
interface=nutil.Function(
Expand Down Expand Up @@ -380,7 +383,8 @@ def build_core_nodes(self):
(concatenate_node, ants_applytransform_node, [("transforms_list", "transforms")]),
# STEP 3
(self.input_node, ants_registration_nonlinear_node, [("t1w", "moving_image")]),
(ants_registration_nonlinear_node, ants_applytransform_nonlinear_node, [("reverse_forward_transforms", "transforms")]),
(ants_registration_nonlinear_node, ants_applytransform_nonlinear_node,
[("reverse_forward_transforms", "transforms")]),
(ants_applytransform_node, ants_applytransform_nonlinear_node, [("output_image", "input_image")]),
(ants_applytransform_node, normalize_intensity_node, [("output_image", "input_img")]),
(ants_applytransform_nonlinear_node, normalize_intensity_node, [("output_image", "norm_img")]),
Expand Down

0 comments on commit 431ea2a

Please sign in to comment.