Skip to content

Commit e296f39

Browse files
committed
Look for references based on file naming
1 parent 975c2f3 commit e296f39

1 file changed

Lines changed: 20 additions & 18 deletions

File tree

  • src/murfey/client/contexts

src/murfey/client/contexts/sxt.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,26 @@ def _find_reference(txrm_file: Path) -> Path | None:
3636
)
3737
candidates.sort(key=lambda x: x.timestamp, reverse=True)
3838
for ref_option in candidates:
39-
mosaic_size = 1
40-
with OleFileIO(ref_option.full_path) as xrm_ole:
41-
# Find images which are not mosaics (txrm spec typos this as mosiac)
42-
if xrm_ole.exists("ImageInfo/MosiacRows") and xrm_ole.exists(
43-
"ImageInfo/MosiacColumns"
44-
):
45-
mosaic_size = int(
46-
np.frombuffer(
47-
xrm_ole.openstream("ImageInfo/MosiacRows").getvalue(), np.int32
48-
)[0]
49-
* np.frombuffer(
50-
xrm_ole.openstream("ImageInfo/MosiacColumns").getvalue(),
51-
np.int32,
52-
)[0]
53-
)
54-
if mosaic_size == 0:
55-
logger.info(f"Found reference {ref_option.name}")
56-
return Path(ref_option.full_path)
39+
if "ref" in ref_option.name.lower():
40+
mosaic_size = 1
41+
with OleFileIO(ref_option.full_path) as xrm_ole:
42+
# Find images which are not mosaics (txrm spec typos this as mosiac)
43+
if xrm_ole.exists("ImageInfo/MosiacRows") and xrm_ole.exists(
44+
"ImageInfo/MosiacColumns"
45+
):
46+
mosaic_size = int(
47+
np.frombuffer(
48+
xrm_ole.openstream("ImageInfo/MosiacRows").getvalue(),
49+
np.int32,
50+
)[0]
51+
* np.frombuffer(
52+
xrm_ole.openstream("ImageInfo/MosiacColumns").getvalue(),
53+
np.int32,
54+
)[0]
55+
)
56+
if mosaic_size == 0:
57+
logger.info(f"Found reference {ref_option.name}")
58+
return Path(ref_option.full_path)
5759
logger.warning(f"No reference found for {txrm_file}")
5860
return None
5961

0 commit comments

Comments
 (0)