from pathlib import Path


def extract_tomostar_from_image_name(filename: str) -> str:
    """
    from a given filename, expected to be from the 'rlnImageName' column of a STAR file output by M
    extract the tomogram name
    :param filename:
    :return:
    """
    p = Path(filename)
    tomo_name = p.parts[-2]
    tomostar = tomo_name + '.tomostar'
    return tomostar