From 03a1e271a21f201100f0f6c6cdf46f97348efed2 Mon Sep 17 00:00:00 2001 From: valosekj Date: Thu, 29 Feb 2024 11:25:25 -0500 Subject: [PATCH] Compute mean and standard deviation of metrics across all subjects --- compute_metrics/compute_metrics_reloaded.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/compute_metrics/compute_metrics_reloaded.py b/compute_metrics/compute_metrics_reloaded.py index 94c5713..7a6d6df 100644 --- a/compute_metrics/compute_metrics_reloaded.py +++ b/compute_metrics/compute_metrics_reloaded.py @@ -223,6 +223,15 @@ def main(): df.to_csv(fname_output_csv, index=False) print(f'Saved metrics to {fname_output_csv}.') + # Compute mean and standard deviation of metrics across all subjects + df_mean = (df.drop(columns=['reference', 'prediction', 'EmptyRef', 'EmptyPred']).groupby('label'). + agg(['mean', 'std']).reset_index()) + + # save as CSV + fname_output_csv_mean = os.path.abspath(args.output.replace('.csv', '_mean.csv')) + df_mean.to_csv(fname_output_csv_mean, index=False) + print(f'Saved mean and standard deviation of metrics across all subjects to {fname_output_csv_mean}.') + if __name__ == '__main__': main()