From 09d6fc0ba9c1f53e06e777efbe778a579af6b9f5 Mon Sep 17 00:00:00 2001 From: yxd92326 Date: Wed, 16 Sep 2026 16:20:43 +0100 Subject: [PATCH 1/5] Want jpg not mrc --- src/murfey/client/contexts/atlas.py | 34 +++++++++++++++++------------ 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/murfey/client/contexts/atlas.py b/src/murfey/client/contexts/atlas.py index 9ccfda43d..602ba6744 100644 --- a/src/murfey/client/contexts/atlas.py +++ b/src/murfey/client/contexts/atlas.py @@ -116,12 +116,15 @@ def post_transfer_epu( ): source = _get_source(transferred_file, environment) if source: - atlas_mrc = transferred_file.with_suffix(".mrc") - transferred_atlas_jpg = _atlas_destination( - environment, - source, - Path(self._machine_config.get("rsync_basepath", "")), - ) / atlas_mrc.relative_to(source.parent).with_suffix(".jpg") + atlas_jpg = transferred_file.with_suffix(".jpg") + transferred_atlas_jpg = ( + _atlas_destination( + environment, + source, + Path(self._machine_config.get("rsync_basepath", "")), + ) + / atlas_jpg + ) with open(transferred_file, "rb") as atlas_xml: atlas_xml_data = xmltodict.parse(atlas_xml) @@ -183,16 +186,19 @@ def post_transfer_epu( # Make sure a dcg is requested before doing grid squares source = _get_source(transferred_file, environment) - atlas_mrc_glob = list(transferred_file.parent.glob("Atlas_*.mrc")) + atlas_jpg_glob = list(transferred_file.parent.glob("Atlas_*.jpg")) if source: - if atlas_mrc_glob: - atlas_mrc = atlas_mrc_glob[0] - transferred_atlas: str | Path = _atlas_destination( - environment, - source, - Path(self._machine_config.get("rsync_basepath", "")), - ) / atlas_mrc.relative_to(source.parent) + if atlas_jpg_glob: + atlas_jpg = atlas_jpg_glob[0] + transferred_atlas: str | Path = ( + _atlas_destination( + environment, + source, + Path(self._machine_config.get("rsync_basepath", "")), + ) + / atlas_jpg + ) else: transferred_atlas = "" capture_post( From fd17d3638a8b732aeb32502d7eabba14e6cbee73 Mon Sep 17 00:00:00 2001 From: yxd92326 Date: Wed, 16 Sep 2026 16:20:56 +0100 Subject: [PATCH 2/5] missing register --- src/murfey/server/api/session_control.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/murfey/server/api/session_control.py b/src/murfey/server/api/session_control.py index 7f2519d5b..b40069ad4 100644 --- a/src/murfey/server/api/session_control.py +++ b/src/murfey/server/api/session_control.py @@ -375,6 +375,7 @@ def register_atlas( murfey.server._transport_object.send( murfey.server._transport_object.feedback_queue, { + "register": "spa.smartem_atlas", "session_id": session_id, "atlas_registration_data": atlas_registration_data.model_dump(), }, From 5e74d824b68dcf1bdef63ebab065c880f0ed13a1 Mon Sep 17 00:00:00 2001 From: yxd92326 Date: Wed, 16 Sep 2026 16:21:38 +0100 Subject: [PATCH 3/5] Handle case of single gs on tile --- src/murfey/util/spa_metadata.py | 41 +++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/src/murfey/util/spa_metadata.py b/src/murfey/util/spa_metadata.py index 2a11ffebf..cae2da554 100644 --- a/src/murfey/util/spa_metadata.py +++ b/src/murfey/util/spa_metadata.py @@ -95,7 +95,8 @@ def get_grid_square_atlas_positions( break if not required_key: continue - for gs in nodes[required_key]: + if isinstance(nodes[required_key], dict): + gs = nodes[required_key] if not isinstance(gs, dict): continue if not grid_square or gs["key"] == grid_square: @@ -115,7 +116,43 @@ def get_grid_square_atlas_positions( float(gs["value"]["b:PositionOnTheAtlas"]["c:Rotation"]), ) if grid_square: - break + return gs_pix_positions + else: + for gs in nodes[required_key]: + if not isinstance(gs, dict): + continue + if not grid_square or gs["key"] == grid_square: + gs_pix_positions[gs["key"]] = ( + int( + float( + gs["value"]["b:PositionOnTheAtlas"]["c:Center"]["d:x"] + ) + ), + int( + float( + gs["value"]["b:PositionOnTheAtlas"]["c:Center"]["d:y"] + ) + ), + float(gs["value"]["b:PositionOnTheAtlas"]["c:Physical"]["d:x"]) + * 1e9, + float(gs["value"]["b:PositionOnTheAtlas"]["c:Physical"]["d:y"]) + * 1e9, + int( + float( + gs["value"]["b:PositionOnTheAtlas"]["c:Size"]["d:width"] + ) + ), + int( + float( + gs["value"]["b:PositionOnTheAtlas"]["c:Size"][ + "d:height" + ] + ) + ), + float(gs["value"]["b:PositionOnTheAtlas"]["c:Rotation"]), + ) + if grid_square: + return gs_pix_positions return gs_pix_positions From d582eb4461e5269080f97fa186ddd838b62efefa Mon Sep 17 00:00:00 2001 From: yxd92326 Date: Wed, 16 Sep 2026 16:22:06 +0100 Subject: [PATCH 4/5] unpack object --- src/murfey/workflows/spa/smartem_atlas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/murfey/workflows/spa/smartem_atlas.py b/src/murfey/workflows/spa/smartem_atlas.py index 2aec4cf75..b1d18b479 100644 --- a/src/murfey/workflows/spa/smartem_atlas.py +++ b/src/murfey/workflows/spa/smartem_atlas.py @@ -31,7 +31,7 @@ def smartem_atlas(message: dict, murfey_db: SQLModelSession): session_id = message.get("session_id") - atlas_registration_data = AtlasRegistration(message["atlas_registration_data"]) + atlas_registration_data = AtlasRegistration(**message["atlas_registration_data"]) if SMARTEM_ACTIVE and atlas_registration_data.acquisition_uuid is not None: session = murfey_db.exec( select(MurfeySession).where(MurfeySession.id == session_id) From a72e45bfd18dfd8a9660374aa8f2219ad42a7544 Mon Sep 17 00:00:00 2001 From: yxd92326 Date: Wed, 16 Sep 2026 16:33:52 +0100 Subject: [PATCH 5/5] Atlas should be relative --- src/murfey/client/contexts/atlas.py | 26 ++++++++++---------------- tests/client/contexts/test_atlas.py | 4 ++-- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/murfey/client/contexts/atlas.py b/src/murfey/client/contexts/atlas.py index 602ba6744..04869e89e 100644 --- a/src/murfey/client/contexts/atlas.py +++ b/src/murfey/client/contexts/atlas.py @@ -117,14 +117,11 @@ def post_transfer_epu( source = _get_source(transferred_file, environment) if source: atlas_jpg = transferred_file.with_suffix(".jpg") - transferred_atlas_jpg = ( - _atlas_destination( - environment, - source, - Path(self._machine_config.get("rsync_basepath", "")), - ) - / atlas_jpg - ) + transferred_atlas_jpg = _atlas_destination( + environment, + source, + Path(self._machine_config.get("rsync_basepath", "")), + ) / atlas_jpg.relative_to(source.parent) with open(transferred_file, "rb") as atlas_xml: atlas_xml_data = xmltodict.parse(atlas_xml) @@ -191,14 +188,11 @@ def post_transfer_epu( if source: if atlas_jpg_glob: atlas_jpg = atlas_jpg_glob[0] - transferred_atlas: str | Path = ( - _atlas_destination( - environment, - source, - Path(self._machine_config.get("rsync_basepath", "")), - ) - / atlas_jpg - ) + transferred_atlas: str | Path = _atlas_destination( + environment, + source, + Path(self._machine_config.get("rsync_basepath", "")), + ) / atlas_jpg.relative_to(source.parent) else: transferred_atlas = "" capture_post( diff --git a/tests/client/contexts/test_atlas.py b/tests/client/contexts/test_atlas.py index a3ca5122f..428625862 100644 --- a/tests/client/contexts/test_atlas.py +++ b/tests/client/contexts/test_atlas.py @@ -102,7 +102,7 @@ def test_atlas_context_dm(mock_capture_post, tmp_path): # Write sample dm file atlas_dm = tmp_path / "cm12345-6/Supervisor_atlas/Sample2/Atlas/Atlas.dm" atlas_dm.parent.mkdir(parents=True) - (tmp_path / "cm12345-6/Supervisor_atlas/Sample2/Atlas/Atlas_01.mrc").touch() + (tmp_path / "cm12345-6/Supervisor_atlas/Sample2/Atlas/Atlas_01.jpg").touch() grid_square_values = ( "" "12001500" @@ -147,7 +147,7 @@ def test_atlas_context_dm(mock_capture_post, tmp_path): "experiment_type_id": 44, # Atlas "tag": str(atlas_dm.parent), "sample": 2, - "atlas": "/base/destination/cm12345-6/Supervisor_atlas/Sample2/Atlas/Atlas_01.mrc", + "atlas": "/base/destination/cm12345-6/Supervisor_atlas/Sample2/Atlas/Atlas_01.jpg", "create_smartem_grid": True, "acquisition_uuid": "uuid1", },