|
a |
|
b/ants/registration/integrate_velocity_field.py |
|
|
1 |
|
|
|
2 |
__all__ = ['integrate_velocity_field'] |
|
|
3 |
|
|
|
4 |
import ants |
|
|
5 |
from ants.internal import get_lib_fn |
|
|
6 |
|
|
|
7 |
|
|
|
8 |
def integrate_velocity_field(velocity_field, |
|
|
9 |
lower_integration_bound=0.0, |
|
|
10 |
upper_integration_bound=1.0, |
|
|
11 |
number_of_integration_steps=10): |
|
|
12 |
""" |
|
|
13 |
Integrate velocity field. |
|
|
14 |
|
|
|
15 |
Arguments |
|
|
16 |
--------- |
|
|
17 |
velocity_field : ANTsImage velocity field |
|
|
18 |
time-varying displacement field |
|
|
19 |
|
|
|
20 |
lower_integration_bound: float |
|
|
21 |
Lower time bound for integration in [0, 1] |
|
|
22 |
|
|
|
23 |
upper_integration_bound: float |
|
|
24 |
Upper time bound for integration in [0, 1] |
|
|
25 |
|
|
|
26 |
number_of_integation_steps: integer |
|
|
27 |
Number of integration steps used in the Runge-Kutta solution |
|
|
28 |
|
|
|
29 |
Example |
|
|
30 |
------- |
|
|
31 |
>>> import ants |
|
|
32 |
>>> fi = ants.image_read( ants.get_data( "r16" ) ) |
|
|
33 |
>>> mi = ants.image_read( ants.get_data( "r27" ) ) |
|
|
34 |
>>> reg = ants.registration(fi, mi, "TV[2]") |
|
|
35 |
>>> velocity_field = ants.image_read(reg['velocityfield'][0]) |
|
|
36 |
>>> field = ants.integrate_velocity_field(velocity_field, 0.0, 1.0, 10) |
|
|
37 |
>>> temp=ants.apply_ants_transform_to_image( |
|
|
38 |
ants.transform_from_displacement_field( field ), mi, fi ) |
|
|
39 |
""" |
|
|
40 |
|
|
|
41 |
libfn = get_lib_fn('integrateVelocityFieldD%i' % (velocity_field.dimension-1)) |
|
|
42 |
integrated_field = libfn(velocity_field.pointer, lower_integration_bound, |
|
|
43 |
upper_integration_bound, number_of_integration_steps) |
|
|
44 |
|
|
|
45 |
new_image = ants.from_pointer(integrated_field).clone('float') |
|
|
46 |
return new_image |
|
|
47 |
|
|
|
48 |
|