from pathlib import Path
import re


def get_decoder_id(decoder_dir):
    """
    Get information about a learned decoder from its output directory name.
    """
    decoder_dir = decoder_dir.name if isinstance(decoder_dir, Path) else decoder_dir
    model, run, step, subject = re.findall("^([\w_]+)-(\d+)-(\d+)-([\w\d]+)$", decoder_dir)[0]
    return model, int(run), int(step), subject