Skip to content

Commit d61a4ef

Browse files
authored
Merge pull request #484 from nipreps/enh/syn-laplacian-weight
ENH: Allow changing laplacians weights in SyN registration metric
2 parents fd8220d + 9371efd commit d61a4ef

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

sdcflows/data/sd_syn.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"dimension": 3,
66
"interpolation": "Linear",
77
"metric": [ ["Mattes", "Mattes"], ["Mattes", "Mattes"] ],
8-
"metric_weight": [ [0.5, 0.5], [0.5, 0.5] ],
8+
"metric_weight": [ [0.9, 0.1], [0.8, 0.2] ],
99
"number_of_iterations": [ [ 200, 100 ], [ 10 ] ],
1010
"output_transform_prefix": "fmap_syn",
1111
"radius_or_number_of_bins": [ [48, 48], [48, 48] ],

sdcflows/data/sd_syn_sloppy.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"dimension": 3,
66
"interpolation": "Linear",
77
"metric": [ ["Mattes", "Mattes"], ["Mattes", "Mattes"] ],
8-
"metric_weight": [ [0.5, 0.5], [0.5, 0.5] ],
8+
"metric_weight": [ [0.9, 0.1], [0.8, 0.2] ],
99
"number_of_iterations": [ [ 20, 10 ], [ 2 ] ],
1010
"output_transform_prefix": "fmap_syn",
1111
"radius_or_number_of_bins": [ [48, 48], [48, 48] ],

sdcflows/workflows/fit/syn.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"anat_mask",
4040
"sd_prior",
4141
)
42+
MAX_LAPLACIAN_WEIGHT = 0.5
4243

4344

4445
def init_syn_sdc_wf(
@@ -48,6 +49,7 @@ def init_syn_sdc_wf(
4849
debug=False,
4950
name="syn_sdc_wf",
5051
omp_nthreads=1,
52+
laplacian_weight=None,
5153
sd_prior=True,
5254
**kwargs,
5355
):
@@ -82,6 +84,11 @@ def init_syn_sdc_wf(
8284
Name for this workflow
8385
omp_nthreads : :obj:`int`
8486
Parallelize internal tasks across the number of CPUs given by this option.
87+
laplacian_weight : :obj:`tuple` (optional)
88+
Tuple of two weights of the Laplacian term in the SyN cost function (one weight per
89+
registration level).
90+
sd_prior : :obj:`bool`
91+
Enable using a prior map to regularize the SyN cost function.
8592
8693
Inputs
8794
------
@@ -229,6 +236,16 @@ def init_syn_sdc_wf(
229236
syn.inputs.output_warped_image = debug
230237
syn.inputs.output_inverse_warped_image = debug
231238

239+
if laplacian_weight is not None:
240+
laplacian_weight = (
241+
max(min(laplacian_weight[0], MAX_LAPLACIAN_WEIGHT), 0.0),
242+
max(min(laplacian_weight[1], MAX_LAPLACIAN_WEIGHT), 0.0),
243+
)
244+
syn.inputs.metric_weight = [
245+
[1.0 - laplacian_weight[0], laplacian_weight[0]],
246+
[1.0 - laplacian_weight[1], laplacian_weight[1]],
247+
]
248+
232249
if debug:
233250
syn.inputs.args = "--write-interval-volumes 2"
234251

0 commit comments

Comments
 (0)