Skip to content

Commit 14ee131

Browse files
committed
If no size is present for a search map, just have to insert something reasonable enough
1 parent 8301d7e commit 14ee131

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/murfey/client/contexts/tomo_metadata.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,27 @@ def post_transfer(
215215
sm_data = xmltodict.parse(sm_xml.read())
216216

217217
# This bit gets SearchMap size
218-
sm_width = int(sm_data["TileSetXml"]["ImageSize"]["a:width"])
219-
sm_height = int(sm_data["TileSetXml"]["ImageSize"]["a:height"])
218+
try:
219+
sm_width = int(sm_data["TileSetXml"]["ImageSize"]["a:width"])
220+
sm_height = int(sm_data["TileSetXml"]["ImageSize"]["a:height"])
221+
except KeyError:
222+
logger.warning(f"Unable to find size for SearchMap {transferred_file}")
223+
readout_width = int(
224+
sm_data["TileSetXml"]["AcquisitionSettings"]["a:camera"][
225+
"ReadoutArea"
226+
]["b:width"]
227+
)
228+
readout_height = int(
229+
sm_data["TileSetXml"]["AcquisitionSettings"]["a:camera"][
230+
"ReadoutArea"
231+
]["b:height"]
232+
)
233+
sm_width = int(
234+
8005 * readout_width / max(readout_height, readout_width)
235+
)
236+
sm_height = int(
237+
8005 * readout_height / max(readout_height, readout_width)
238+
)
220239

221240
sm_url = f"{str(environment.url.geturl())}{url_path_for('session_control.tomo_router', 'register_search_map', session_id=environment.murfey_session, sm_name=transferred_file.parent.name)}"
222241
capture_post(

0 commit comments

Comments
 (0)