def scan_year(visit, studyid='TON'):
    """
    Retrieve the year in which a scan was collected.

    Parameters
    ----------
    visit : str or int
        Visit number
    studyid: str, optional
        Specifies the study from which files will be retrieved. Valid
        values are 'THD' and 'TON'.

    Returns
    -------
    sc_year : int
        Actual scan year
    """
    if type(visit) is str:
        visit = int(visit[-1:])
    if studyid == 'TON':
        years = [2012, 2013, 2014]
    else:
        years = [2008, 2009, 2010, 2011]
    sc_year = years[visit-1]
    return sc_year