Skip to content

Commit

Permalink
fix deskew regression
Browse files Browse the repository at this point in the history
  • Loading branch information
talonchandler committed Aug 6, 2024
1 parent 40ec608 commit b2010d7
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions mantis/analysis/deskew.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@ def _get_averaged_shape(deskewed_data_shape: tuple, average_window_width: int) -


def _get_transform_matrix(
data_shape: tuple, ls_angle_deg: float, px_to_scan_ratio: float, keep_overhang: bool
ls_angle_deg: float, px_to_scan_ratio: float
):
"""
Compute affine transformation matrix used to deskew data.
Parameters
----------
data_shape : tuple
ls_angle_deg : float
px_to_scan_ratio : float
keep_overhang : bool
Expand All @@ -73,23 +72,20 @@ def _get_transform_matrix(
matrix : np.array
Affine transformation matrix.
"""
Z, Y, X = data_shape

ct = np.cos(ls_angle_deg * np.pi / 180)
Z_shift = 0
if not keep_overhang:
Z_shift = int(np.floor(Y * ct * px_to_scan_ratio))

matrix = np.array(
[
[
-px_to_scan_ratio * ct,
0,
px_to_scan_ratio,
Z_shift,
0,
],
[-1, 0, 0, Y - 1],
[0, -1, 0, X - 1],
[-1, 0, 0, 0],
[0, -1, 0, 0],
[0, 0, 0, 1],

]
)

Expand Down Expand Up @@ -192,7 +188,7 @@ def deskew_data(
"""
# Prepare transforms
matrix = _get_transform_matrix(
raw_data.shape, ls_angle_deg, px_to_scan_ratio, keep_overhang
ls_angle_deg, px_to_scan_ratio,
)

output_shape, _ = get_deskewed_data_shape(
Expand Down

0 comments on commit b2010d7

Please sign in to comment.