Skip to content

Commit

Permalink
List of ttest pairs
Browse files Browse the repository at this point in the history
  • Loading branch information
bazilinskyy committed Dec 31, 2024
1 parent fe6fdcf commit 6ae21fb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
6 changes: 3 additions & 3 deletions trust/analysis/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2142,12 +2142,12 @@ def plot_kp_slider_videos(self, df, y: list, y_legend=None, x=None, events=None,
for signals in ttest_signals:
# smoothen signal
if self.smoothen_signal:
signal_1 = self.smoothen_filter(ttest_signals['signal_1'])
signal_2 = self.smoothen_filter(ttest_signals['signal_2'])
signal_1 = self.smoothen_filter(signals['signal_1'])
signal_2 = self.smoothen_filter(signals['signal_2'])
# receive significance values
significance = self.ttest(signal_1=signal_1,
signal_2=signal_2,
paired=ttest_signals['paired'])
paired=signals['paired'])
# add to the plot
# todo: @Shadab, plot those stars here based on significance
# todo: @Shadab, adjust the ylim with yaxis_kp_range
Expand Down
39 changes: 27 additions & 12 deletions trust/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,25 +201,40 @@
'start': start,
'end': end,
'annotation': vert_line_annotations[x]})
# prepare signals to compare with ttest
# prepare pairs of signals to compare with ttest
ttest_signals = [] # list of dictionaries
# todo: @Shadab, create list of things to compare using ttest here
# 0 and 1 = within (paired): https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.ttest_rel.html
# 0 and 1 = within (paired): https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.ttest_rel.html # noqa: E501
# 0 and 2 = between: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.ttest_ind.html
# 0 and 3 = between
# 1 and 2 = between
# 2 and 3 = within
# 1 and 3 = between
print(df)
print(ids)
for stim in ids[1:]:
values = row['kp'] # keypress data
print(stim, df[ids[0]], df[stim])
# assume that df[ids[0]] is always the baseline to compare against
ttest_signals.append({'signal_1': df[ids[0]]['kp'],
'signal_2': df[stim]['kp'],
'paired': True})
print(ttest_signals)
# todo: @Shadab, we should find some clever way to understand which once should be between and which
# one within. Code below could then be used
# for stim in ids[1:]:
# # assume that df[ids[0]] is always the baseline to compare against
# ttest_signals.append({'signal_1': df.loc['video_' + str(ids[0])]['kp'],
# 'signal_2': df.loc['video_' + str(stim)]['kp'],
# 'paired': True})
ttest_signals = [{'signal_1': df.loc['video_' + str(ids[0])]['kp'], # 0 and 1 = within
'signal_2': df.loc['video_' + str(ids[1])]['kp'],
'paired': True},
{'signal_1': df.loc['video_' + str(ids[0])]['kp'], # 0 and 2 = between
'signal_2': df.loc['video_' + str(ids[2])]['kp'],
'paired': False},
{'signal_1': df.loc['video_' + str(ids[0])]['kp'], # 0 and 3 = between
'signal_2': df.loc['video_' + str(ids[3])]['kp'],
'paired': False},
{'signal_1': df.loc['video_' + str(ids[1])]['kp'], # 1 and 2 = between
'signal_2': df.loc['video_' + str(ids[2])]['kp'],
'paired': False},
{'signal_1': df.loc['video_' + str(ids[2])]['kp'], # 2 and 3 = within
'signal_2': df.loc['video_' + str(ids[3])]['kp'],
'paired': True},
{'signal_1': df.loc['video_' + str(ids[1])]['kp'], # 1 and 3 = between
'signal_2': df.loc['video_' + str(ids[3])]['kp'],
'paired': False}]
# plot keypress data and slider questions
analysis.plot_kp_slider_videos(df,
y=['comfort', 'safety', 'expectation'],
Expand Down

0 comments on commit 6ae21fb

Please sign in to comment.