diff --git a/src/murfey/client/contexts/atlas.py b/src/murfey/client/contexts/atlas.py index 9ccfda43d..04869e89e 100644 --- a/src/murfey/client/contexts/atlas.py +++ b/src/murfey/client/contexts/atlas.py @@ -116,12 +116,12 @@ def post_transfer_epu( ): source = _get_source(transferred_file, environment) if source: - atlas_mrc = transferred_file.with_suffix(".mrc") + atlas_jpg = transferred_file.with_suffix(".jpg") 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.relative_to(source.parent) with open(transferred_file, "rb") as atlas_xml: atlas_xml_data = xmltodict.parse(atlas_xml) @@ -183,16 +183,16 @@ 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] + 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_mrc.relative_to(source.parent) + ) / atlas_jpg.relative_to(source.parent) else: transferred_atlas = "" capture_post( 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(), }, 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 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) 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", },