from typing import Counter


def get_years(dicom_metadata):
    """Creates a mapping from years to number of DICOMs.

    Arguments:
        dicom_metadata(list): An array of DICOM metadata.
    Returns:
        A dictionary mapping year or "None" to the
        number of DICOMs from that year.
    """

    years = [row['StudyDate'][:4] if row.get('StudyDate', None) else 'None' for row in dicom_metadata]
    year_counts = Counter(years)

    return dict(year_counts)