Skip to content

Commit 65b9994

Browse files
committed
Flip the tomogram y coordinates so origin is at top
1 parent e4eaaf0 commit 65b9994

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/murfey/workflows/tomo/tomo_metadata.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ def register_batch_position_in_database(
329329
]
330330
)
331331

332+
# Apply stage corrections to the location
332333
corrected_vector = np.matmul(
333334
np.linalg.inv(reference_shift_matrix),
334335
np.matmul(
@@ -339,7 +340,10 @@ def register_batch_position_in_database(
339340
),
340341
),
341342
)
342-
centre_batch_pixel = corrected_vector / search_map.pixel_size + [
343+
# Invert y coordinate
344+
inverted_corrected_vector = np.matmul([[1, 0], [0, -1]], corrected_vector)
345+
# Apply shift from centre
346+
centre_batch_pixel = inverted_corrected_vector / search_map.pixel_size + [
343347
search_map.width / 2,
344348
search_map.height / 2,
345349
]

tests/workflows/tomo/test_tomo_metadata.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ def test_register_batch_position_update(murfey_db_session: Session):
249249

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

255255

256256
def test_register_batch_position_update_skip(murfey_db_session: Session):
@@ -361,5 +361,5 @@ def test_register_batch_position_new(murfey_db_session: Session):
361361

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

0 commit comments

Comments
 (0)