import pandas as pd

for i in range(5):
    tb_log_dir = '../../tb_log/'
    original = pd.read_csv('cross{}/test.csv'.format(i))
    mri_score = pd.read_csv(tb_log_dir + 'CNN_fusion_cross{}_fold0/test_eval.csv'.format(i))[["COG_score", "ADD_score", "filename"]]
    result = pd.merge(original, mri_score, how="left", on=["filename"])
    result.to_csv('cross{}/test_mri.csv'.format(i), index=False)

    original = pd.read_csv('cross{}/valid.csv'.format(i))
    mri_score = pd.read_csv(tb_log_dir + 'CNN_fusion_cross{}_fold0/valid_eval.csv'.format(i))[["COG_score", "ADD_score", "filename"]]
    result = pd.merge(original, mri_score, how="left", on=["filename"])
    result.to_csv('cross{}/valid_mri.csv'.format(i), index=False)

    original = pd.read_csv('cross{}/OASIS.csv'.format(i))
    mri_score = pd.read_csv(tb_log_dir + 'CNN_fusion_cross{}_fold0/OASIS_eval.csv'.format(i))[["COG_score", "ADD_score", "filename"]]
    result = pd.merge(original, mri_score, how="left", on=["filename"])
    result.to_csv('cross{}/OASIS_mri.csv'.format(i), index=False)

    original = pd.read_csv('cross{}/train.csv'.format(i))
    mri_score1 = pd.read_csv(tb_log_dir + 'CNN_fusion_cross{}_fold1/valid_eval.csv'.format(i))[["COG_score", "ADD_score", "filename"]]
    mri_score2 = pd.read_csv(tb_log_dir + 'CNN_fusion_cross{}_fold2/valid_eval.csv'.format(i))[["COG_score", "ADD_score", "filename"]]
    mri_score3 = pd.read_csv(tb_log_dir + 'CNN_fusion_cross{}_fold3/valid_eval.csv'.format(i))[["COG_score", "ADD_score", "filename"]]
    mri_score = pd.concat([mri_score1, mri_score2, mri_score3])
    result = pd.merge(original, mri_score, how="left", on=["filename"])
    result.to_csv('cross{}/train_mri.csv'.format(i), index=False)
