<reponame>tetsuzawa/spatial-research<gh_stars>0
import sys

import fire
import pandas as pd


def show_calced_result(subjects=None, times="1"):
    if subjects is None:
        subjects = ["ISHISAKI", "AKAISHI", "SATOU", "IZUMI", "ASADA", "CONNOLLY", "KUBOTA", "TORIKI", "SEINO"]
    ##########################################################################################################
    # 計算した角度毎の前後誤知覚率,平均定位誤差,標本標準偏差のまとめ
    ##########################################################################################################

    result_dict = {}
    for i in range(len(subjects)):
        result_dict[f"S{i + 1}"] = {}

    for subject_num, subject in enumerate(subjects):
        subject_dir = f"SUBJECTS/{subject}"
        try:
            df_result = pd.read_csv(f"{subject_dir}/ANSWER/calc_{times}_{times}.csv", index_col=0)
        except FileNotFoundError:
            continue

        result_dict[f"S{subject_num + 1}"]["前後誤知覚率"] = df_result.at["Average", "FBC_rate"]
        result_dict[f"S{subject_num + 1}"]["平均定位誤差"] = df_result.at["Average", "Average_LE"]
        result_dict[f"S{subject_num + 1}"]["標本標準偏差"] = df_result.at["Average", "SSD"]

    df = pd.DataFrame(result_dict)
    df = df.T
    df.to_csv(sys.stdout, sep="\t")


if __name__ == "__main__":
    fire.Fire(show_calced_result)
