-
etspy.base.TomoStack.tilt_align(method: 'CoM' | 'MaxImage', slices: ndarray | None =
None
, nslices: int | None =None
, limit: float =10
, delta: float =0.1
, plot_results: bool =False
, also_shift: bool =False
, shift_limit: int =20
)[source] Align the tilt axis of a TomoStack.
Uses either a center-of-mass approach or a maximum image approach
Available methods are
'CoM'
and'MaxImage'
:CoM: Track the center of mass (CoM) of the projections at three locations. Fit the motion of the CoM as a function of tilt to that expected for an ideal cylinder to calculate an X-shift at each location. Perform a linear fit of the three X-shifts to calculate an ideal rotation.
MaxImage: Perform automated determination of the tilt axis of a TomoStack by analyzing features in the projected maximum image. A combination of edge detection and Hough transform analysis is used to determine the global rotation of the stack. Optionally, the global shift of the tilt axis can also be calculated by minimization of the sum of the reconstruction.
- Parameters:¶
- method: 'CoM' | 'MaxImage'¶
Algorithm to use for registration alignment. Must be either
'CoM'
or'MaxImage'
.- slices: ndarray | None =
None
¶ (Only used when
method == "CoM"
) Locations at which to perform the Center of Mass analysis. If not provided, an appropriate list of slices will be automatically determined.- nslices: int | None =
None
¶ (Only used when
method == "CoM"
) Nubmer of slices to use for the center of mass analysis (only used if theslices
parameter is not specified). IfNone
, a value of 10% of the x-axis size will be used, clamped to the range [3, 50], as calculated in thetilt_com()
function.- limit: float =
10
¶ (Only used when
method == "MaxImage"
) Maximum rotation angle for MaxImage calculation- delta: float =
0.1
¶ (Only used when
method == "MaxImage"
) Angular increment in degrees for MaxImage calculation- plot_results: bool =
False
¶ (Only used when
method == "MaxImage"
) IfTrue
, plot the maximum image along with the lines determined by Hough analysis- also_shift: bool =
False
¶ (Only used when
method == "MaxImage"
) IfTrue
, also calculate and apply the global shift perpendicular to the tilt by minimizing the sum of the reconstruction- shift_limit: int =
20
¶ (Only used when
method == "MaxImage"
) The limit of shifts applied ifalso_shift
is set toTrue
- Returns:¶
out – Copy of the input stack rotated by calculated angle
- Return type:¶
Examples¶
- Align tilt axis using the center of mass (CoM) method:
>>> import etspy.datasets as ds >>> import numpy as np >>> stack = ds.get_needle_data() >>> reg = stack.stack_register('PC', show_progressbar=False) >>> method = 'CoM' >>> ali = reg.tilt_align(method, slices=np.array([50,100,160]))
- Align tilt axis using the maximum image method:
>>> import etspy.datasets as ds >>> stack = ds.get_needle_data() >>> reg = stack.stack_register('PC', show_progressbar=False) >>> method = 'MaxImage' >>> ali = reg.tilt_align(method)