util.py 409 Bytes
Newer Older
1
2
3
import re


4
5
6
7
8
9
10
11
12
13
14
15
class NoWavelengthError(Exception):
    pass


def get_bbi_wl(fn):
    """Extract wavelength from string formatted as WL656 indicating 656nm wavelenght.
    Returns: wavelength in nm
    """
    match = re.search(r"WL(\d+)", fn)
    if not match:
        raise NoWavelengthError(f"Could not determine wavelength from {fn}, expeced a wavelength format like 'WLXXX'")
    return int(match.group(1))