|
|
| import pandas as pd
|
| import pandas as pd
|
|
|
| data = pd.read_csv("D:\\NN\\Data\\Study1AllUsers\\Cleaned_TrialResultsFull.csv")
|
|
|
|
|
| grouped_data = data.groupby(['ParticipantID']).agg({
|
| 'AngularDistanceHMD': 'mean',
|
| 'AngularDistanceHand': 'mean',
|
| 'AngularDistanceLeye': 'mean'
|
| }).reset_index()
|
|
|
| print(grouped_data)
|
|
|
| output_path = 'D:\\NN\\Data\\Study1AllUsers\\ModalityAnalyse.csv'
|
| grouped_data.to_csv(output_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| import pandas as pd
|
| import numpy as np
|
| from statsmodels.stats.correlation_tools import cov_nearest
|
| from scipy.stats import chi2
|
|
|
|
|
|
|
| data = pd.read_csv("D:\\NN\\Data\\Study1AllUsers\\Cleaned_TrialResultsFull.csv")
|
|
|
|
|
|
|
|
|
|
|
| columns = ['ParticipantID', 'BlockID', 'TrialID', 'MovementTime','AngularDistanceHMD','AngularDistanceHand','AngularDistanceLeye', 'Depth', 'Theta', 'Width','Position']
|
|
|
| data= data[columns]
|
|
|
| grouped_data = data.groupby(['ParticipantID', 'Depth', 'Theta', 'Width','Position']).agg({
|
| 'AngularDistanceLeye': 'mean'
|
| }).reset_index()
|
|
|
|
|
| grouped_data['Condition'] = grouped_data['Depth'].astype(str) + '_' + grouped_data['Theta'].astype(str) + '_' + grouped_data['Width'].astype(str)+ '_' + grouped_data['Position'].astype(str)
|
|
|
|
|
| wide_data = grouped_data.pivot_table(index='ParticipantID',
|
| columns='Condition',
|
| values=['AngularDistanceLeye'])
|
|
|
| wide_data.columns = ['_'.join(col).strip() for col in wide_data.columns.values]
|
|
|
|
|
| print(wide_data.head())
|
| output_path = 'D:\\NN\\Data\\Study1AllUsers\\EyeDistance.csv'
|
| wide_data.to_csv(output_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| import pandas as pd
|
|
|
| import pandas as pd
|
| from statsmodels.stats.anova import AnovaRM
|
| import statsmodels.api as sm
|
|
|
|
|
| data = pd.read_csv("D:\\NN\\Data\\Study1AllUsers\\Cleaned_TrialResultsFull.csv")
|
|
|
| data['Depth'] = data['Depth'].astype(str)
|
| data['Theta'] = data['Theta'].astype(str)
|
| data['Width'] = data['Width'].astype(str)
|
|
|
|
|
| filtered_data = data[~data['ParticipantID'].isin([3, 6, 15, 19, 18, 20, 22])]
|
|
|
| filtered_aggregated_data = filtered_data.groupby(['ParticipantID', 'Depth', 'Theta', 'Width']).mean().reset_index()
|
| print(filtered_aggregated_data)
|
|
|
|
|
| rm_anova_results = AnovaRM(filtered_aggregated_data, 'MovementTime', 'ParticipantID',
|
| within=['Depth', 'Theta', 'Width'])
|
|
|
|
|
| print(rm_anova_results.summary())
|
|
|
|
|
| anova_table = rm_anova_results.anova_table
|
| anova_table['eta_squared'] = (anova_table['F Value'] * anova_table['Num DF']) / \
|
| (anova_table['F Value'] * anova_table['Num DF'] + anova_table['Den DF'])
|
|
|
|
|
| print(anova_table[['F Value', 'Pr > F', 'eta_squared']])
|
|
|
|
|
| from statsmodels.stats.multicomp import pairwise_tukeyhsd
|
|
|
|
|
| tukey_data = filtered_aggregated_data[['Theta', 'Width', 'MovementTime']]
|
|
|
|
|
| tukey_result_theta = pairwise_tukeyhsd(endog=tukey_data['MovementTime'], groups=tukey_data['Theta'], alpha=0.05)
|
|
|
| tukey_result_width = pairwise_tukeyhsd(endog=tukey_data['MovementTime'], groups=tukey_data['Width'], alpha=0.05)
|
|
|
| tukey_result_theta.summary(), tukey_result_width.summary()
|
|
|
|
|
| print(tukey_result_theta.summary())
|
| print(tukey_result_width.summary())
|
|
|
| for width_level in filtered_aggregated_data['Width'].unique():
|
| subset = filtered_aggregated_data[filtered_aggregated_data['Width'] == width_level]
|
| print(f'Tukey HSD for Width {width_level}:')
|
| print(pairwise_tukeyhsd(subset['MovementTime'], subset['Theta'], alpha=0.05).summary())
|
|
|
|
|
| for theta_level in filtered_aggregated_data['Theta'].unique():
|
| subset = filtered_aggregated_data[filtered_aggregated_data['Theta'] == theta_level]
|
| print(f'Tukey HSD for Theta {theta_level}:')
|
| print(pairwise_tukeyhsd(subset['MovementTime'], subset['Width'], alpha=0.05).summary())
|
|
|
|
|
|
|
| import pandas as pd
|
| from statsmodels.stats.anova import AnovaRM
|
|
|
| data = pd.read_csv("D:\\NN\\Data\\Study1AllUsers\\TrialResultsFull.csv")
|
|
|
| data['Depth'] = data['Depth'].astype(str)
|
| data['Theta'] = data['Theta'].astype(str)
|
| data['Width'] = data['Width'].astype(str)
|
|
|
| filtered_data = data[~data['ParticipantID'].isin([3, 6, 15, 19, 18, 20, 22])]
|
| filtered_aggregated_data = filtered_data.groupby(['ParticipantID', 'Depth', 'Theta', 'Width', 'Position']).mean().reset_index()
|
| print(filtered_aggregated_data)
|
|
|
| rm_anova_results = AnovaRM(filtered_aggregated_data, 'AngularDistanceHand', 'ParticipantID', within=['Depth', 'Theta', 'Width', 'Position']).fit()
|
| print(rm_anova_results.summary())
|
| anova_table = rm_anova_results.anova_table
|
| anova_table['eta_squared'] = (anova_table['F Value'] * anova_table['Num DF']) / \
|
| (anova_table['F Value'] * anova_table['Num DF'] + anova_table['Den DF'])
|
| print(anova_table[['F Value', 'Pr > F', 'eta_squared']]) |