Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/murfey/workflows/tomo/tomo_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ def register_batch_position_in_database(
]
)

# Apply stage corrections to the location
corrected_vector = np.matmul(
np.linalg.inv(reference_shift_matrix),
np.matmul(
Expand All @@ -339,7 +340,10 @@ def register_batch_position_in_database(
),
),
)
centre_batch_pixel = corrected_vector / search_map.pixel_size + [
# Invert y coordinate
inverted_corrected_vector = np.matmul([[1, 0], [0, -1]], corrected_vector)
# Apply shift from centre
centre_batch_pixel = inverted_corrected_vector / search_map.pixel_size + [
search_map.width / 2,
search_map.height / 2,
]
Expand All @@ -354,7 +358,7 @@ def register_batch_position_in_database(
tilt_series.y_location = (
(
centre_batch_pixel[1]
- batch_parameters.y_beamshift / search_map.pixel_size
+ batch_parameters.y_beamshift / search_map.pixel_size
)
* 512
/ search_map.width
Expand Down
8 changes: 4 additions & 4 deletions tests/workflows/tomo/test_tomo_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ def test_register_batch_position_update(murfey_db_session: Session):

# These two should have been updated, values are known as used identity matrices
bp_final_parameters = murfey_db_session.exec(select(TiltSeries)).one()
assert bp_final_parameters.x_location == 880 * 512 / search_map.width
assert bp_final_parameters.y_location == 1780 * 512 / search_map.width
assert bp_final_parameters.x_location == 880 * 512 / 2000
assert bp_final_parameters.y_location == (4000 - 1780) * 512 / 2000


def test_register_batch_position_update_skip(murfey_db_session: Session):
Expand Down Expand Up @@ -361,5 +361,5 @@ def test_register_batch_position_new(murfey_db_session: Session):

# These two should have been updated, values are known as used identity matrices
bp_final_parameters = murfey_db_session.exec(select(TiltSeries)).one()
assert bp_final_parameters.x_location == 880 * 512 / search_map.width
assert bp_final_parameters.y_location == 1780 * 512 / search_map.width
assert bp_final_parameters.x_location == 880 * 512 / 2000
assert bp_final_parameters.y_location == (4000 - 1780) * 512 / 2000