def get_final_dx_groups(final_exam):
    """This function separates the final exam data into diagnosis groups.
    
    Each dataframe that is returned follows a group of patients based on their 
    progression during the study. cn_cn means a group that was 'CN' at baseline
    and 'CN' at final exam, while mci_ad means a group that was 'MCI' at baseline
    and 'AD' at final exam. This function only contains data for the final exam
    
    Returns a tuple containing the following items:
    cn_cn_f, cn_mci_f, cn_ad_f, mci_cn_f, mci_mci_f, mci_ad_f, ad_cn_f, ad_mci_f, ad_ad_f
    """
    
    # filter the data
    cn_cn_f = final_exam[(final_exam.DX == 'CN') & (final_exam.DX_bl2 == 'CN')]
    cn_mci_f = final_exam[(final_exam.DX == 'MCI') & (final_exam.DX_bl2 == 'CN')]
    cn_ad_f = final_exam[(final_exam.DX == 'AD') & (final_exam.DX_bl2 == 'CN')]
    mci_cn_f = final_exam[(final_exam.DX == 'CN') & (final_exam.DX_bl2 == 'MCI')]
    mci_mci_f = final_exam[(final_exam.DX == 'MCI') & (final_exam.DX_bl2 == 'MCI')]
    mci_ad_f = final_exam[(final_exam.DX == 'AD') & (final_exam.DX_bl2 == 'MCI')]
    ad_cn_f = final_exam[(final_exam.DX == 'CN') & (final_exam.DX_bl2 == 'AD')]
    ad_mci_f = final_exam[(final_exam.DX == 'MCI') & (final_exam.DX_bl2 == 'AD')]
    ad_ad_f = final_exam[(final_exam.DX == 'AD') & (final_exam.DX_bl2 == 'AD')]
    
    return (cn_cn_f, cn_mci_f, cn_ad_f, mci_cn_f, mci_mci_f, mci_ad_f, ad_cn_f, ad_mci_f, ad_ad_f)