Skip to content

Commit ba586ab

Browse files
authored
Update FIB metadata parsing and registration logic (#825)
* Updated 'number_from_name' so that it can handle the folder naming pattern associated with the FIB waffle method * Updated milling progress registration logic so that it uses the latest available stage position value present in the metadata
1 parent 62abcff commit ba586ab

3 files changed

Lines changed: 179 additions & 206 deletions

File tree

src/murfey/util/fib.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
General functinos specific to the FIB workflow
33
"""
44

5-
import re
5+
from pathlib import Path
66

77

88
def number_from_name(name: str) -> int:
@@ -11,11 +11,19 @@ def number_from_name(name: str) -> int:
1111
auto-incremented with parenthesised numbers (e.g. "Lamella (2)"), with
1212
the first site/image typically not having a number.
1313
14+
For sites set up and acquired manually, they will be saved in folders
15+
labelled "Site #1", "Site #2", etc.
16+
1417
This function extracts the number from the file name, and returns 1 if
1518
no such number is found.
1619
"""
17-
return (
18-
int(match.group(1))
19-
if (match := re.search(r"^[\w\s]+\((\d+)\)$", name)) is not None
20-
else 1
21-
)
20+
# Ensure only the stem is extracted for parsing
21+
stem = Path(name).stem
22+
# Handle naming pattern for sites acquired without autoTEM
23+
if "#" in stem:
24+
return int(stem.rpartition("#")[-1])
25+
# Handle naming pattern for sites acquired with autoTEM
26+
if "(" in stem and stem.endswith(")"):
27+
return int(stem[stem.rfind("(") + 1 : -1])
28+
# Names without '()' or '#' should return 1
29+
return 1

0 commit comments

Comments
 (0)