[5d12a0]: / ants / registration / invert_displacement_field.py

Download this file

52 lines (35 with data), 1.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
__all__ = ['invert_displacement_field']
import ants
from ants.internal import get_lib_fn
def invert_displacement_field(displacement_field,
inverse_field_initial_estimate,
maximum_number_of_iterations=20,
mean_error_tolerance_threshold=0.001,
max_error_tolerance_threshold=0.1,
enforce_boundary_condition=True):
"""
Invert displacement field.
Arguments
---------
displacement_field : ANTsImage displacement field
displacement field
inverse_field_initial_estimate : ANTsImage displacement field
initial guess
maximum_number_of_iterations : integer
number of iterations
mean_error_tolerance_threshold : float
mean error tolerance threshold
max_error_tolerance_threshold : float
max error tolerance threshold
enforce_boundary_condition : bool
enforce stationary boundary condition
Example
-------
>>> import ants
"""
libfn = get_lib_fn('invertDisplacementFieldD%i' % displacement_field.dimension)
inverse_field = libfn(displacement_field.pointer, inverse_field_initial_estimate.pointer,
maximum_number_of_iterations, mean_error_tolerance_threshold,
max_error_tolerance_threshold, enforce_boundary_condition)
new_image = ants.from_pointer(inverse_field).clone('float')
return new_image