forked from ccraddock/msit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMSIT_SummaryStatisticsPlot.py
More file actions
127 lines (109 loc) · 3.43 KB
/
MSIT_SummaryStatisticsPlot.py
File metadata and controls
127 lines (109 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import os
import pandas as pd
import matplotlib.pyplot as plt
INPUT_CSV = "msit_stats.csv"
OUTPUT_PNG = "msit_stats_plots.png"
def main():
if not os.path.exists(INPUT_CSV):
raise FileNotFoundError(
f"Could not find {INPUT_CSV}. Run parse_msit.py first."
)
df = pd.read_csv(INPUT_CSV)
if "Unnamed: 0" in df.columns:
df = df.drop(columns=["Unnamed: 0"])
required_columns = [
"id",
"congruent_correct",
"congruent_rt_mean",
"congruent_rt_var",
"incongruent_correct",
"incongruent_rt_mean",
"incongruent_rt_var",
]
missing = [col for col in required_columns if col not in df.columns]
if missing:
raise ValueError(f"Missing required columns in {INPUT_CSV}: {missing}")
df = df.sort_values("id").reset_index(drop=True)
x = range(len(df))
labels = df["id"]
fig, axes = plt.subplots(2, 2, figsize=(14, 10))
fig.suptitle("MSIT Summary Statistics", fontsize=16)
# Accuracy
axes[0, 0].bar(
[i - 0.2 for i in x],
df["congruent_correct"],
width=0.4,
label="Congruent",
color="steelblue",
)
axes[0, 0].bar(
[i + 0.2 for i in x],
df["incongruent_correct"],
width=0.4,
label="Incongruent",
color="indianred",
)
axes[0, 0].set_title("Accuracy")
axes[0, 0].set_ylabel("Proportion Correct")
axes[0, 0].set_xticks(list(x))
axes[0, 0].set_xticklabels(labels, rotation=45, ha="right")
axes[0, 0].set_ylim(0, 1.05)
axes[0, 0].legend()
axes[0, 0].grid(axis="y", alpha=0.3)
# Mean RT
axes[0, 1].bar(
[i - 0.2 for i in x],
df["congruent_rt_mean"],
width=0.4,
label="Congruent",
color="steelblue",
)
axes[0, 1].bar(
[i + 0.2 for i in x],
df["incongruent_rt_mean"],
width=0.4,
label="Incongruent",
color="indianred",
)
axes[0, 1].set_title("Mean Reaction Time")
axes[0, 1].set_ylabel("Seconds")
axes[0, 1].set_xticks(list(x))
axes[0, 1].set_xticklabels(labels, rotation=45, ha="right")
axes[0, 1].legend()
axes[0, 1].grid(axis="y", alpha=0.3)
# RT Variance
axes[1, 0].bar(
[i - 0.2 for i in x],
df["congruent_rt_var"],
width=0.4,
label="Congruent",
color="steelblue",
)
axes[1, 0].bar(
[i + 0.2 for i in x],
df["incongruent_rt_var"],
width=0.4,
label="Incongruent",
color="indianred",
)
axes[1, 0].set_title("Reaction Time Variance")
axes[1, 0].set_ylabel("Variance (s²)")
axes[1, 0].set_xticks(list(x))
axes[1, 0].set_xticklabels(labels, rotation=45, ha="right")
axes[1, 0].legend()
axes[1, 0].grid(axis="y", alpha=0.3)
# Interference effect: incongruent - congruent mean RT
rt_diff = df["incongruent_rt_mean"] - df["congruent_rt_mean"]
axes[1, 1].bar(x, rt_diff, color="darkslategray")
axes[1, 1].set_title("Interference Effect")
axes[1, 1].set_ylabel("Incongruent RT - Congruent RT (s)")
axes[1, 1].set_xticks(list(x))
axes[1, 1].set_xticklabels(labels, rotation=45, ha="right")
axes[1, 1].axhline(0, color="black", linewidth=1)
axes[1, 1].grid(axis="y", alpha=0.3)
plt.tight_layout(rect=[0, 0, 1, 0.96])
plt.savefig(OUTPUT_PNG, dpi=300, bbox_inches="tight")
plt.show()
print(f"Saved plot to {OUTPUT_PNG}")
if __name__ == "__main__":
main()