Skip to content

Commit 7ea973e

Browse files
Scale search map dimensions and location to be those on jpg (#635)
The size and location of the search maps we insert into ispyb are currently those on the atlas mrc. This scales them to be those on the jpg, and also scales the location of tomograms on search maps. Also inserts an angle of 0 and handles inserting atlas pixel size when a data collection group is first made. Something similar will probably be needed for the tomogram sizes on search maps, but that may need to be done in pato as there is an extra scaling based on pixel sizes as well.
1 parent 64894b1 commit 7ea973e

File tree

4 files changed

+53
-10
lines changed

4 files changed

+53
-10
lines changed

src/murfey/server/feedback.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,6 +1982,7 @@ def feedback_callback(header: dict, message: dict) -> None:
19821982
session_id=message["session_id"],
19831983
tag=message.get("tag"),
19841984
)
1985+
dcgid = murfey_dcg.id
19851986
else:
19861987
record = DataCollectionGroup(
19871988
sessionId=ispyb_session_id,
@@ -1999,9 +2000,14 @@ def feedback_callback(header: dict, message: dict) -> None:
19992000
atlas_id = murfey.server._transport_object.do_insert_atlas(
20002001
atlas_record
20012002
)["return_value"]
2003+
else:
2004+
atlas_id = None
20022005
murfey_dcg = db.DataCollectionGroup(
20032006
id=dcgid,
20042007
atlas_id=atlas_id,
2008+
atlas=message.get("atlas", ""),
2009+
atlas_pixel_size=message.get("atlas_pixel_size"),
2010+
sample=message.get("sample"),
20052011
session_id=message["session_id"],
20062012
tag=message.get("tag"),
20072013
)

src/murfey/server/ispyb.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,34 @@ def do_insert_search_map(
405405
search_map_parameters.pixel_size *= (
406406
search_map_parameters.height / search_map_parameters.height_on_atlas
407407
)
408+
search_map_parameters.height = (
409+
int(search_map_parameters.height / 7.8)
410+
if search_map_parameters.height
411+
else None
412+
)
413+
search_map_parameters.width = (
414+
int(search_map_parameters.width / 7.8)
415+
if search_map_parameters.width
416+
else None
417+
)
418+
search_map_parameters.x_location = (
419+
int(search_map_parameters.x_location / 7.8)
420+
if search_map_parameters.x_location
421+
else None
422+
)
423+
search_map_parameters.y_location = (
424+
int(search_map_parameters.y_location / 7.8)
425+
if search_map_parameters.y_location
426+
else None
427+
)
408428
record = GridSquare(
409429
atlasId=atlas_id,
410430
gridSquareImage=search_map_parameters.image,
411431
pixelLocationX=search_map_parameters.x_location,
412432
pixelLocationY=search_map_parameters.y_location,
413433
height=search_map_parameters.height_on_atlas,
414434
width=search_map_parameters.width_on_atlas,
435+
angle=0,
415436
stageLocationX=search_map_parameters.x_stage_position,
416437
stageLocationY=search_map_parameters.y_stage_position,
417438
pixelSize=search_map_parameters.pixel_size,
@@ -452,13 +473,19 @@ def do_update_search_map(
452473
if search_map_parameters.image:
453474
grid_square.gridSquareImage = search_map_parameters.image
454475
if search_map_parameters.x_location:
455-
grid_square.pixelLocationX = search_map_parameters.x_location
476+
grid_square.pixelLocationX = int(
477+
search_map_parameters.x_location / 7.8
478+
)
456479
if search_map_parameters.y_location:
457-
grid_square.pixelLocationY = search_map_parameters.y_location
480+
grid_square.pixelLocationY = int(
481+
search_map_parameters.y_location / 7.8
482+
)
458483
if search_map_parameters.height_on_atlas:
459-
grid_square.height = search_map_parameters.height_on_atlas
484+
grid_square.height = int(
485+
search_map_parameters.height_on_atlas / 7.8
486+
)
460487
if search_map_parameters.width_on_atlas:
461-
grid_square.width = search_map_parameters.width_on_atlas
488+
grid_square.width = int(search_map_parameters.width_on_atlas / 7.8)
462489
if search_map_parameters.x_stage_position:
463490
grid_square.stageLocationX = search_map_parameters.x_stage_position
464491
if search_map_parameters.y_stage_position:

src/murfey/workflows/tomo/tomo_metadata.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,20 @@ def register_batch_position_in_database(
339339
search_map.height / 2,
340340
]
341341
tilt_series.x_location = (
342-
centre_batch_pixel[0] - batch_parameters.x_beamshift / search_map.pixel_size
342+
(
343+
centre_batch_pixel[0]
344+
- batch_parameters.x_beamshift / search_map.pixel_size
345+
)
346+
* 512
347+
/ search_map.width
343348
)
344349
tilt_series.y_location = (
345-
centre_batch_pixel[1] - batch_parameters.y_beamshift / search_map.pixel_size
350+
(
351+
centre_batch_pixel[1]
352+
- batch_parameters.y_beamshift / search_map.pixel_size
353+
)
354+
* 512
355+
/ search_map.width
346356
)
347357
else:
348358
logger.warning(

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
253-
assert bp_final_parameters.y_location == 1780
252+
assert bp_final_parameters.x_location == 880 * 512 / search_map.width
253+
assert bp_final_parameters.y_location == 1780 * 512 / search_map.width
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
365-
assert bp_final_parameters.y_location == 1780
364+
assert bp_final_parameters.x_location == 880 * 512 / search_map.width
365+
assert bp_final_parameters.y_location == 1780 * 512 / search_map.width

0 commit comments

Comments
 (0)