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
12 changes: 6 additions & 6 deletions src/murfey/client/contexts/atlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions src/murfey/server/api/session_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
Expand Down
41 changes: 39 additions & 2 deletions src/murfey/util/spa_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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


Expand Down
2 changes: 1 addition & 1 deletion src/murfey/workflows/spa/smartem_atlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tests/client/contexts/test_atlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
"<value><b:PositionOnTheAtlas>"
"<c:Center><d:x>1200</d:x><d:y>1500</d:y></c:Center>"
Expand Down Expand Up @@ -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",
},
Expand Down