import re


def getroi(roilabel, h, fh):
    """
    Returns:
        list: [row0,col0,nrow,ncol] or [y0,x0,ny,nx]
    """

    # ROI from label
    roi = []
    if roilabel in h:
        roi = [int(s) for s in re.split("[<>,\-x ]+", h[roilabel]) if len(s) != 0]
        # camera takes x as the first dimension, python takes y
        roi = [roi[1], roi[0], roi[3], roi[2]]

    # ROI from dimensions
    if len(roi) != 4:
        # edf: dim2 => rows, dim1 => cols
        roi = [0, 0, int(fh.dim2), int(fh.dim1)]

    return roi