from pathlib import Path
import re


def getPathImageIndex(path: Path) -> int:
    """Extracts the image # from the file name"""
    stem = path.stem
    numbers = re.findall(r"\d+", stem)
    fileIndexStr = numbers[0]  # File index # as a string
    fileIndex = int(fileIndexStr)  # File index as a number
    return fileIndex