import re


def _make_dict_from_hdr(dict_string):
    """Generates a dictionary from a portion of the header.

    Works for Config and Dicom.
    """
    pattern = re.compile(
            '<Param(Long|String|Double)\\."([^"]+)">  { ([^}]+)  }')
    out = {}
    for dtype, name, data in pattern.findall(dict_string):
        if dtype == "String":
            out[name] = data[1:-1]
        if dtype == "Long":
            if " " in data:
                out[name] = [int(x) for x in data.split()]
            else:
                out[name] = int(data)
        if dtype == "Double":
            out[name] = float(data.rstrip().split(" ")[-1])
    return out