Skip to content

Commit f95b861

Browse files
committed
Avoid marking some metadata as SPA
1 parent cd98ad8 commit f95b861

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/murfey/client/analyser.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,17 @@ def _find_context(self, file_path: Path) -> bool:
159159
return True
160160

161161
# Tomography and SPA workflow checks
162-
split_file_name = file_path.name.split("_")
163-
if split_file_name:
164-
if "gain" in split_file_name[-1]:
162+
split_file_stem = file_path.stem.split("_")
163+
if split_file_stem:
164+
if split_file_stem[-1] == "gain":
165165
return False
166166

167167
# Files starting with "FoilHole" belong to the SPA workflow
168-
if split_file_name[0].startswith("FoilHole"):
168+
if split_file_stem[0].startswith("FoilHole") and split_file_stem[-1] in [
169+
"Fractions",
170+
"fractions",
171+
"EER",
172+
]:
169173
if not self._context:
170174
logger.info("Acquisition software: EPU")
171175
self._context = SPAModularContext("epu", self._basepath)
@@ -174,11 +178,8 @@ def _find_context(self, file_path: Path) -> bool:
174178

175179
# Files starting with "Position" belong to the standard tomography workflow
176180
if (
177-
split_file_name[0] == "Position"
178-
or "[" in file_path.name
179-
or "Fractions" in split_file_name[-1]
180-
or "fractions" in split_file_name[-1]
181-
or "EER" in split_file_name[-1]
181+
split_file_stem[0] == "Position"
182+
or split_file_stem[-1] in ["Fractions", "fractions", "EER"]
182183
or file_path.suffix == ".mdoc"
183184
):
184185
if not self._context:

tests/client/test_analyser.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ def test_find_context(file_and_context, tmp_path):
4545
"visit/Position_1_gain.tiff",
4646
"visit/FoilHole_01234_gain.tiff",
4747
"visit/file_1.mrc",
48+
"visit/FoilHole_01234.mrc",
49+
"visit/FoilHole_01234.jpg",
50+
"visit/FoilHole_01234.xml",
4851
]
4952

5053

@@ -66,7 +69,7 @@ def test_analyser_setup_and_stopping(tmp_path):
6669

6770

6871
def test_analyser_tomo_determination(tmp_path):
69-
tomo_file = tmp_path / "Position_1_[30.0].tiff"
72+
tomo_file = tmp_path / "Position_1_[30.0]_fractions.tiff"
7073
analyser = Analyser(tmp_path)
7174
analyser.start()
7275
analyser.queue.put(tomo_file)
@@ -75,7 +78,7 @@ def test_analyser_tomo_determination(tmp_path):
7578

7679

7780
def test_analyser_epu_determination(tmp_path):
78-
tomo_file = tmp_path / "FoilHole_12345_Data_6789.tiff"
81+
tomo_file = tmp_path / "FoilHole_12345_Data_6789_Fractions.tiff"
7982
analyser = Analyser(tmp_path)
8083
analyser.start()
8184
analyser.queue.put(tomo_file)

0 commit comments

Comments
 (0)