def dicom_age_in_years(age_string):
    """Helper function to extract DICOM age into float

    Parameters
    ----------
    age_string : str
        The age string as defined in the DICOM standard,
        see http://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_6.2.html

    Returns
    -------
    float or None
        The age or None if any conversiomn went wrong.
    """
    try:
        units = age_string[-1]
        value = age_string[0:-1]
    except IndexError:
        return
    try:
        age = float(value)
    except ValueError:
        return

    if units == "Y":
        # default
        pass
    elif units == "M":
        age /= 12
    elif units == "W":
        age /= 52
    elif units == "D":
        age /= 365
    else:
        # unknown
        return
    return age