ht_ln_gt45 = mean_sd_plot( axs[cur_row, 0], x, ht_mean_gt45, ht_sd_gt45, dict(color=color_map.colors[1], alpha=0.25), dict(color=color_map.colors[1], marker=markers[0], markevery=20)) st_ln_gt45 = mean_sd_plot( axs[cur_row, 1], x, st_mean_gt45, st_sd_gt45, dict(color=color_map.colors[1], alpha=0.25), dict(color=color_map.colors[1], marker=markers[1], markevery=20)) gh_ln_gt45 = mean_sd_plot( axs[cur_row, 2], x, gh_mean_gt45, gh_sd_gt45, dict(color=color_map.colors[1], alpha=0.25), dict(color=color_map.colors[1], marker=markers[2], markevery=20)) # plot SPM ht_x_sig = sig_filter(ht_lt35_vs_gt35, x) st_x_sig = sig_filter(st_lt35_vs_gt35, x) gh_x_sig = sig_filter(gh_lt35_vs_gt35, x) axs[cur_row, 0].plot(ht_x_sig, np.repeat(ax_limits[cur_row][1], ht_x_sig.size), color='k', lw=2) axs[cur_row, 1].plot(st_x_sig, np.repeat(ax_limits[cur_row][1], st_x_sig.size), color='k', lw=2) axs[cur_row, 2].plot(gh_x_sig, np.repeat(ax_limits[cur_row][1], gh_x_sig.size), color='k', lw=2)
ht_ln_m = mean_sd_plot( axs[cur_row, 0], x, ht_mean_m, ht_sd_m, dict(color=color_map.colors[1], alpha=0.25), dict(color=color_map.colors[1], marker=markers[0], markevery=20)) st_ln_m = mean_sd_plot( axs[cur_row, 1], x, st_mean_m, st_sd_m, dict(color=color_map.colors[1], alpha=0.25), dict(color=color_map.colors[1], marker=markers[1], markevery=20)) gh_ln_m = mean_sd_plot( axs[cur_row, 2], x, gh_mean_m, gh_sd_m, dict(color=color_map.colors[1], alpha=0.25), dict(color=color_map.colors[1], marker=markers[2], markevery=20)) # plot SPM ht_x_sig = sig_filter(ht_f_vs_m, x) st_x_sig = sig_filter(st_f_vs_m, x) gh_x_sig = sig_filter(gh_f_vs_m, x) axs[cur_row, 0].plot(ht_x_sig, np.repeat(ax_limits[cur_row][1], ht_x_sig.size), color='k', lw=2) axs[cur_row, 1].plot(st_x_sig, np.repeat(ax_limits[cur_row][1], st_x_sig.size), color='k', lw=2) axs[cur_row, 2].plot(gh_x_sig, np.repeat(ax_limits[cur_row][1], gh_x_sig.size), color='k', lw=2)
color=color_map.colors[0], marker=markers[0], capsize=3) axs_elev[cur_row].errorbar(max_pos, st_gt45_max_mean, yerr=st_gt45_max_sd, color=color_map.colors[1], marker=markers[1], capsize=3) # spm lt35_vs_gt45 = spm_test(traj_st_lt35, traj_st_gt45).inference(alpha, two_tailed=True, **infer_params) x_sig = sig_filter(lt35_vs_gt45, x_elev) axs_elev[cur_row].plot(x_sig, np.repeat(spm_y[activity.lower()], x_sig.size), color='k') print(activity) print(extract_sig(lt35_vs_gt45, x_elev)) if idx == 0: leg_elev_mean.append(st_lt35_ln[0]) leg_elev_mean.append(st_gt45_ln[0]) for idx_act, (activity, activity_df) in enumerate( db_er_endpts.groupby('Activity', observed=True)): lt35_df = activity_df[activity_df['age_group'] == '<35'] gt45_df = activity_df[activity_df['age_group'] == '>45']
two_tailed=True, **infer_params) # plot mean +- sd cur_row = act_row[activity.lower()] old_shr_ln = mean_sd_plot( axs[cur_row], x, old_shr_mean, old_shr_sd, dict(color=color_map.colors[0], alpha=0.25), dict(color=color_map.colors[0], marker=markers[0], markevery=20)) new_shr_ln = mean_sd_plot( axs[cur_row], x, new_shr_mean, new_shr_sd, dict(color=color_map.colors[1], alpha=0.25), dict(color=color_map.colors[1], marker=markers[0], markevery=20)) # plot spm x_sig = sig_filter(spm_res, x) axs[cur_row].plot(x_sig, np.repeat(12, x_sig.size), color='k', lw=2) if idx == 0: leg_mean.append(old_shr_ln[0]) leg_mean.append(new_shr_ln[0]) # figure title and legend plt.tight_layout(pad=0.25, h_pad=1.5, w_pad=0.5) fig.suptitle('SHR Comparison', x=0.47, y=0.99, fontweight='bold') plt.subplots_adjust(top=0.93) leg_left = fig.legend(leg_mean[:2], ['Euler SHR', 'Contrib SHR'], loc='upper left', bbox_to_anchor=(0, 1), ncol=1, handlelength=1.5,
ht_lt35_vs_gt45 = spm_test(traj_ht_lt35[:, 1:], traj_ht_gt45[:, 1:]).inference(alpha, two_tailed=True, **infer_params) st_lt35_vs_gt45 = spm_test(traj_st_lt35[:, 1:], traj_st_gt45[:, 1:]).inference(alpha, two_tailed=True, **infer_params) gh_lt35_vs_gt45 = spm_test(traj_gh_lt35[:, 1:], traj_gh_gt45[:, 1:]).inference(alpha, two_tailed=True, **infer_params) ht_x_sig = sig_filter(ht_lt35_vs_gt45, x[1:]) st_x_sig = sig_filter(st_lt35_vs_gt45, x[1:]) gh_x_sig = sig_filter(gh_lt35_vs_gt45, x[1:]) axs[idx_act, 0].plot(ht_x_sig, np.repeat(5, ht_x_sig.size), color='k', lw=2) axs[idx_act, 1].plot(st_x_sig, np.repeat(5, st_x_sig.size), color='k', lw=2) axs[idx_act, 2].plot(gh_x_sig, np.repeat(5, gh_x_sig.size), color='k', lw=2)
dict(color=color_map.colors[2], alpha=0.25), dict(color=color_map.colors[2], marker=markers[2], markevery=20)) axs_elev[cur_row].errorbar(max_pos, gh_max_mean, yerr=gh_max_sd, color=color_map.colors[0], marker=markers[0], capsize=3) axs_elev[cur_row].errorbar(max_pos + 3, st_max_mean, yerr=st_max_sd, color=color_map.colors[1], marker=markers[1], capsize=3) axs_elev[cur_row].errorbar(max_pos - 3, ht_max_mean, yerr=ht_max_sd, color=color_map.colors[2], marker=markers[2], capsize=3) # spm if activity.lower() == 'fe': st_vs_gh = spm_test(traj_st - traj_gh, 0).inference(alpha, two_tailed=True, **infer_params) else: st_vs_gh = spm_test(-(traj_st - traj_gh), 0).inference(alpha, two_tailed=True, **infer_params) x_sig = sig_filter(st_vs_gh, x_elev) axs_elev[cur_row].plot(x_sig, np.repeat(spm_y[activity.lower()], x_sig.size), color='k') print('Activity: {}'.format(activity)) print(extract_sig(st_vs_gh, x_elev)) print('P-values: ') print(output_spm_p(st_vs_gh)) print('HT Max: {:.2f}'.format(np.abs(ht_max_mean))) print('ST Max: {:.2f}'.format(np.abs(st_max_mean))) print('GH Max: {:.2f}'.format(np.abs(gh_max_mean))) print('Percentage: {:.2f}'.format(st_max_mean / ht_max_mean * 100)) if idx == 0: leg_elev_mean.append(ht_ln[0]) leg_elev_mean.append(st_ln[0]) leg_elev_mean.append(gh_ln[0])
dict(color=color_map.colors[1], marker=markers[1], markevery=20)) st_contrib_ln_gt45 = mean_sd_plot( axs_st[cur_row, 1], x, st_contrib_mean_gt45, st_contrib_sd_gt45, dict(color=color_map.colors[3], alpha=0.25), dict(color=color_map.colors[3], marker=markers[3], markevery=20)) gh_euler_ln_gt45 = mean_sd_plot( axs_gh[cur_row, 0], x, gh_euler_mean_gt45, gh_euler_sd_gt45, dict(color=color_map.colors[1], alpha=0.25), dict(color=color_map.colors[1], marker=markers[1], markevery=20)) gh_contrib_ln_gt45 = mean_sd_plot( axs_gh[cur_row, 1], x, gh_contrib_mean_gt45, gh_contrib_sd_gt45, dict(color=color_map.colors[3], alpha=0.25), dict(color=color_map.colors[3], marker=markers[3], markevery=20)) # plot spm st_euler_x_sig = sig_filter(st_euler_spm, x) st_contrib_x_sig = sig_filter(st_contrib_spm, x) gh_euler_x_sig = sig_filter(gh_euler_spm, x) gh_contrib_x_sig = sig_filter(gh_contrib_spm, x) axs_st[cur_row, 0].plot(st_euler_x_sig, np.repeat(st_lims[cur_row][1], st_euler_x_sig.size), color='k', lw=2) axs_st[cur_row, 1].plot(st_contrib_x_sig, np.repeat(st_lims[cur_row][1], st_euler_x_sig.size), color='k', lw=2) axs_gh[cur_row, 0].plot(gh_euler_x_sig, np.repeat(gh_lims[cur_row][1],
axs[cur_row, 1].errorbar(max_pos - 3, gh_euler_max_mean, yerr=gh_euler_max_sd, color=color_map.colors[0], marker=markers[0], capsize=3) axs[cur_row, 1].errorbar(max_pos, gh_contrib_max_mean, yerr=gh_contrib_max_sd, color=color_map.colors[1], marker=markers[1], capsize=3) # plot spm st_x_sig = sig_filter(st_spm, x) gh_x_sig = sig_filter(gh_spm, x) axs[cur_row, 0].plot(st_x_sig, np.repeat(2, st_x_sig.size), color='k', lw=2) axs[cur_row, 1].plot(gh_x_sig, np.repeat(0, gh_x_sig.size), color='k', lw=2) print(activity) print('Mean Diff at Max ST: {:.2f}'.format(st_contrib_max_mean - st_euler_max_mean)) print('Mean Diff at Max GH: {:.2f}'.format(gh_contrib_max_mean - gh_euler_max_mean)) print('ST HT Elevation angles')
# plot at max axs[cur_row].errorbar(max_pos, ht_euler_add_max_mean, yerr=ht_euler_add_max_sd, color=color_map.colors[0], marker=markers[0], capsize=3) axs[cur_row].errorbar(max_pos - 3, ht_contrib_max_mean, yerr=ht_contrib_max_sd, color=color_map.colors[1], marker=markers[1], capsize=3) # plot spm x_sig_euler_add = sig_filter(ht_euler_diff_vs_euler_add, x) # x_sig_contribs = sig_filter(ht_euler_diff_vs_contribs, x) axs[cur_row].plot(x_sig_euler_add, np.repeat(spm_y[cur_row], x_sig_euler_add.size), color=color_map.colors[0], lw=2) # axs[cur_row].plot(x_sig_contribs, np.repeat(spm_y[cur_row] - 1, x_sig_contribs.size), # color=color_map.colors[1], lw=2) # print info print(activity) print('Euler Diff at Max: {:.2f}'.format(ht_euler_add_max_mean)) print('Contrib Diff at Max: {:.2f}'.format(ht_contrib_max_mean)) print('HT Elevation significance:') print(extract_sig(ht_euler_diff_vs_euler_add, x)) print(output_spm_p(ht_euler_diff_vs_euler_add))
dict(color=color_map.colors[0], marker=markers[0], markevery=20)) old_shr_ln_gt45 = mean_sd_plot( axs[cur_row, 0], x, old_shr_mean_gt45, old_shr_sd_gt45, dict(color=color_map.colors[1], alpha=0.25), dict(color=color_map.colors[1], marker=markers[1], markevery=20)) new_shr_ln_lt35 = mean_sd_plot( axs[cur_row, 1], x, new_shr_mean_lt35, new_shr_sd_lt35, dict(color=color_map.colors[0], alpha=0.25), dict(color=color_map.colors[0], marker=markers[0], markevery=20)) new_shr_ln_gt45 = mean_sd_plot( axs[cur_row, 1], x, new_shr_mean_gt45, new_shr_sd_gt45, dict(color=color_map.colors[1], alpha=0.25), dict(color=color_map.colors[1], marker=markers[1], markevery=20)) # plot spm x_old_sig = sig_filter(spm_old, x) x_new_sig = sig_filter(spm_new, x) axs[cur_row, 0].plot(x_old_sig, np.repeat(12, x_old_sig.size), color='k', lw=2) axs[cur_row, 1].plot(x_new_sig, np.repeat(12, x_new_sig.size), color='k', lw=2) if idx == 0: leg_mean.append(old_shr_ln_lt35[0]) leg_mean.append(old_shr_ln_gt45[0]) leg_mean.append(new_shr_ln_lt35[0]) leg_mean.append(new_shr_ln_gt45[0])
'BP Min: {:.2f}, 25: {:.2f}, Median: {:.2f}, 75: {:.2f}, Max: {:.2f}' .format(*retrieve_bp_stats(bp))) print('BP Deg Median: {:.2f}, 25: {:.2f}, 75: {:.2f}, Max: {:.2f}'. format(np.median(st_end_deg), *np.quantile(st_end_deg, [0.25, 0.75]), np.max(st_end_deg))) print('GH Mean Deg: {:.2f} and Percent: {:.2f}'.format( np.mean(gh_end_deg), np.mean(gh_percent))) print('ST Mean Deg: {:.2f} and Percent: {:.2f}'.format( np.mean(st_end_deg), np.mean(st_percent))) st_vs_ht = spm_test(traj_st[:, 40:] / traj_ht[:, 40:], 0.10).inference(alpha, two_tailed=True, **infer_params) x_gh_sig = sig_filter(st_vs_ht, x_er[40:]) axs_er[idx_act].plot(x_gh_sig, np.repeat(5, x_gh_sig.size), color='k') print(extract_sig(st_vs_ht, x_er[40:])) print('P-values: ') print(output_spm_p(st_vs_ht)) # add stats test text axs_elev[0].text(25, 10, 'GH ~ HT', ha='left', fontsize=10, fontweight='bold') axs_elev[0].text(107, 10, 'ST ~ HT',
cur_row = act_row[activity.lower()] st_m_ln = mean_sd_plot(axs_elev[cur_row], x_elev, st_m_mean, st_m_sd, dict(color=color_map.colors[0], alpha=0.25), dict(color=color_map.colors[0], marker=markers[0], markevery=20)) st_f_ln = mean_sd_plot(axs_elev[cur_row], x_elev, st_f_mean, st_f_sd, dict(color=color_map.colors[1], alpha=0.25), dict(color=color_map.colors[1], marker=markers[1], markevery=20)) axs_elev[cur_row].errorbar(max_pos, st_m_max_mean, yerr=st_m_max_sd, color=color_map.colors[0], marker=markers[0], capsize=3) axs_elev[cur_row].errorbar(max_pos, st_f_max_mean, yerr=st_f_max_sd, color=color_map.colors[1], marker=markers[1], capsize=3) # spm m_vs_f = spm_test(traj_st_m, traj_st_f).inference(alpha, two_tailed=True, **infer_params) x_sig = sig_filter(m_vs_f, x_elev) axs_elev[cur_row].plot(x_sig, np.repeat(spm_y[activity.lower()], x_sig.size), color='k') print(activity) print(extract_sig(m_vs_f, x_elev)) if idx == 0: leg_elev_mean.append(st_m_ln[0]) leg_elev_mean.append(st_f_ln[0]) for idx_act, (activity, activity_df) in enumerate(db_er_endpts.groupby('Activity', observed=True)): m_df = activity_df[activity_df['Gender'] == 'M'] f_df = activity_df[activity_df['Gender'] == 'F'] traj_st_m = np.stack(m_df['st_contribs_interp'], axis=0)[:, :, 2] traj_st_f = np.stack(f_df['st_contribs_interp'], axis=0)[:, :, 2]
**infer_params) latmed_vs_tilt = spm_test(traj_st_x - traj_st_z, 0).inference(alpha, two_tailed=True, **infer_params) else: latmed_vs_repro = spm_test(-(traj_st_x - traj_st_y), 0).inference(alpha, two_tailed=True, **infer_params) latmed_vs_tilt = spm_test(-(traj_st_x - traj_st_z), 0).inference(alpha, two_tailed=True, **infer_params) x_sig_repro = sig_filter(latmed_vs_repro, x_elev) x_sig_tilt = sig_filter(latmed_vs_tilt, x_elev) axs_elev[cur_row].plot(x_sig_repro, np.repeat(spm_y[activity.lower()], x_sig_repro.size), '-', color='k') axs_elev[cur_row].plot(x_sig_tilt, np.repeat(spm_y[activity.lower()] - 3, x_sig_tilt.size), '-', color='k') print('Activity: {}'.format(activity)) print('Repro Sig') print(extract_sig(latmed_vs_repro, x_elev))
dict(color=color_map.colors[0], marker=markers[0], markevery=20)) st_m_ln = mean_sd_plot(axs[idx_act, 1], x, st_m_mean, st_m_sd, dict(color=color_map.colors[1], alpha=0.2), dict(color=color_map.colors[1], marker=markers[1], markevery=20)) gh_f_ln = mean_sd_plot(axs[idx_act, 2], x, gh_f_mean, gh_f_sd, dict(color=color_map.colors[0], alpha=0.2), dict(color=color_map.colors[0], marker=markers[0], markevery=20)) gh_m_ln = mean_sd_plot(axs[idx_act, 2], x, gh_m_mean, gh_m_sd, dict(color=color_map.colors[1], alpha=0.2), dict(color=color_map.colors[1], marker=markers[1], markevery=20)) ht_f_vs_m = spm_test(traj_ht_f[:, 1:], traj_ht_m[:, 1:]).inference(alpha, two_tailed=True, **infer_params) st_f_vs_m = spm_test(traj_st_f[:, 1:], traj_st_m[:, 1:]).inference(alpha, two_tailed=True, **infer_params) gh_f_vs_m = spm_test(traj_gh_f[:, 1:], traj_gh_m[:, 1:]).inference(alpha, two_tailed=True, **infer_params) ht_x_sig = sig_filter(ht_f_vs_m, x[1:]) st_x_sig = sig_filter(st_f_vs_m, x[1:]) gh_x_sig = sig_filter(gh_f_vs_m, x[1:]) axs[idx_act, 0].plot(ht_x_sig, np.repeat(5, ht_x_sig.size), color='k', lw=2) axs[idx_act, 1].plot(st_x_sig, np.repeat(5, st_x_sig.size), color='k', lw=2) axs[idx_act, 2].plot(gh_x_sig, np.repeat(5, gh_x_sig.size), color='k', lw=2) if idx_act == 0: # legend lines mean_lns.append(ht_f_ln[0]) mean_lns.append(ht_m_ln[0]) mean_lns.append(st_f_ln[0]) mean_lns.append(st_m_ln[0]) mean_lns.append(gh_f_ln[0]) mean_lns.append(gh_m_ln[0])
repro_ln_lt35 = mean_sd_plot(axs[cur_row, 0], x, repro_mean_lt35, repro_sd_lt35, dict(color=color_map.colors[0], alpha=0.25), dict(color=color_map.colors[0], marker=markers[0], markevery=20)) poe_ln_lt35 = mean_sd_plot(axs[cur_row, 1], x, poe_mean_lt35, poe_sd_lt35, dict(color=color_map.colors[0], alpha=0.25), dict(color=color_map.colors[0], marker=markers[2], markevery=20)) repro_ln_gt45 = mean_sd_plot(axs[cur_row, 0], x, repro_mean_gt45, repro_sd_gt45, dict(color=color_map.colors[1], alpha=0.25), dict(color=color_map.colors[1], marker=markers[0], markevery=20)) poe_ln_gt45 = mean_sd_plot(axs[cur_row, 1], x, poe_mean_gt45, poe_sd_gt45, dict(color=color_map.colors[1], alpha=0.25), dict(color=color_map.colors[1], marker=markers[2], markevery=20)) # plot SPM repro_x_sig = sig_filter(repro_lt35_vs_gt35, x) poe_x_sig = sig_filter(poe_lt35_vs_gt35, x) axs[cur_row, 0].plot(repro_x_sig, np.repeat(ax_limits[0][1], repro_x_sig.size), color='k', lw=2) axs[cur_row, 1].plot(poe_x_sig, np.repeat(ax_limits[1][1], poe_x_sig.size), color='k', lw=2) if act_idx == 0: leg_mean.append(repro_ln_lt35[0]) leg_mean.append(repro_ln_gt45[0]) leg_mean.append(poe_ln_lt35[0]) leg_mean.append(poe_ln_gt45[0]) # figure title and legend plt.figure(fig.number) plt.tight_layout(pad=0.25, h_pad=1.5, w_pad=0) fig.suptitle('ST ReProtraction and GH PoE Comparison by Age Group', x=0.5, y=0.99, fontweight='bold') plt.subplots_adjust(top=0.93)