Skip to content

Commit 07d7eeb

Browse files
committed
Moved CLEM context determination logic to the start of the '_find_context' function, as it conflicts with some of the metadata determindation logic for SPA and Tomo
1 parent f95b861 commit 07d7eeb

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/murfey/client/analyser.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -118,21 +118,6 @@ def _find_context(self, file_path: Path) -> bool:
118118
in the Context classes themselves.
119119
"""
120120
logger.debug(f"Finding context using file {str(file_path)!r}")
121-
if "atlas" in file_path.parts:
122-
self._context = SPAMetadataContext("epu", self._basepath)
123-
return True
124-
125-
if "Metadata" in file_path.parts or file_path.name == "EpuSession.dm":
126-
self._context = SPAMetadataContext("epu", self._basepath)
127-
return True
128-
elif (
129-
"Batch" in file_path.parts
130-
or "SearchMaps" in file_path.parts
131-
or "Thumbnails" in file_path.parts
132-
or file_path.name == "Session.dm"
133-
):
134-
self._context = TomographyMetadataContext("tomo", self._basepath)
135-
return True
136121

137122
# CLEM workflow checks
138123
# Look for LIF and XLIF files
@@ -141,9 +126,9 @@ def _find_context(self, file_path: Path) -> bool:
141126
return True
142127
# Look for TIFF files associated with CLEM workflow
143128
# Leica's autosave mode seems to name the TIFFs in the format
144-
# PostionXX--ZXX-CXX.tif
129+
# PostionXX--ZXX--CXX.tif
145130
if (
146-
"--" in file_path.name
131+
all(pattern in file_path.name for pattern in ("--Z", "--C"))
147132
and file_path.suffix in (".tiff", ".tif")
148133
and self._environment
149134
):
@@ -159,6 +144,22 @@ def _find_context(self, file_path: Path) -> bool:
159144
return True
160145

161146
# Tomography and SPA workflow checks
147+
if "atlas" in file_path.parts:
148+
self._context = SPAMetadataContext("epu", self._basepath)
149+
return True
150+
151+
if "Metadata" in file_path.parts or file_path.name == "EpuSession.dm":
152+
self._context = SPAMetadataContext("epu", self._basepath)
153+
return True
154+
elif (
155+
"Batch" in file_path.parts
156+
or "SearchMaps" in file_path.parts
157+
or "Thumbnails" in file_path.parts
158+
or file_path.name == "Session.dm"
159+
):
160+
self._context = TomographyMetadataContext("tomo", self._basepath)
161+
return True
162+
162163
split_file_stem = file_path.stem.split("_")
163164
if split_file_stem:
164165
if split_file_stem[-1] == "gain":

0 commit comments

Comments
 (0)