diff --git a/sdcflows/data/sd_syn.json b/sdcflows/data/sd_syn.json index 57b28ed082..d317223db7 100644 --- a/sdcflows/data/sd_syn.json +++ b/sdcflows/data/sd_syn.json @@ -5,7 +5,7 @@ "dimension": 3, "interpolation": "Linear", "metric": [ ["Mattes", "Mattes"], ["Mattes", "Mattes"] ], - "metric_weight": [ [0.5, 0.5], [0.5, 0.5] ], + "metric_weight": [ [0.9, 0.1], [0.8, 0.2] ], "number_of_iterations": [ [ 200, 100 ], [ 10 ] ], "output_transform_prefix": "fmap_syn", "radius_or_number_of_bins": [ [48, 48], [48, 48] ], diff --git a/sdcflows/data/sd_syn_sloppy.json b/sdcflows/data/sd_syn_sloppy.json index 9560c48fd1..a2aab7c042 100644 --- a/sdcflows/data/sd_syn_sloppy.json +++ b/sdcflows/data/sd_syn_sloppy.json @@ -5,7 +5,7 @@ "dimension": 3, "interpolation": "Linear", "metric": [ ["Mattes", "Mattes"], ["Mattes", "Mattes"] ], - "metric_weight": [ [0.5, 0.5], [0.5, 0.5] ], + "metric_weight": [ [0.9, 0.1], [0.8, 0.2] ], "number_of_iterations": [ [ 20, 10 ], [ 2 ] ], "output_transform_prefix": "fmap_syn", "radius_or_number_of_bins": [ [48, 48], [48, 48] ], diff --git a/sdcflows/workflows/fit/syn.py b/sdcflows/workflows/fit/syn.py index 1d4b7a55c4..31429800f9 100644 --- a/sdcflows/workflows/fit/syn.py +++ b/sdcflows/workflows/fit/syn.py @@ -39,6 +39,7 @@ "anat_mask", "sd_prior", ) +MAX_LAPLACIAN_WEIGHT = 0.5 def init_syn_sdc_wf( @@ -48,6 +49,7 @@ def init_syn_sdc_wf( debug=False, name="syn_sdc_wf", omp_nthreads=1, + laplacian_weight=None, sd_prior=True, **kwargs, ): @@ -82,6 +84,11 @@ def init_syn_sdc_wf( Name for this workflow omp_nthreads : :obj:`int` Parallelize internal tasks across the number of CPUs given by this option. + laplacian_weight : :obj:`tuple` (optional) + Tuple of two weights of the Laplacian term in the SyN cost function (one weight per + registration level). + sd_prior : :obj:`bool` + Enable using a prior map to regularize the SyN cost function. Inputs ------ @@ -229,6 +236,16 @@ def init_syn_sdc_wf( syn.inputs.output_warped_image = debug syn.inputs.output_inverse_warped_image = debug + if laplacian_weight is not None: + laplacian_weight = ( + max(min(laplacian_weight[0], MAX_LAPLACIAN_WEIGHT), 0.0), + max(min(laplacian_weight[1], MAX_LAPLACIAN_WEIGHT), 0.0), + ) + syn.inputs.metric_weight = [ + [1.0 - laplacian_weight[0], laplacian_weight[0]], + [1.0 - laplacian_weight[1], laplacian_weight[1]], + ] + if debug: syn.inputs.args = "--write-interval-volumes 2"