isb_mean_min = np.rad2deg(np.mean(all_traj_isb_min, axis=0)) isb_norm_mean_min = np.rad2deg(np.mean(all_traj_isb_norm_min, axis=0)) phadke_mean_min = np.rad2deg(np.mean(all_traj_phadke_min, axis=0)) isb_sd_min = np.rad2deg(np.std(all_traj_isb_min, ddof=1, axis=0)) isb_norm_sd_min = np.rad2deg( np.std(all_traj_isb_norm_min, ddof=1, axis=0)) phadke_sd_min = np.rad2deg(np.std(all_traj_phadke_min, ddof=1, axis=0)) # plot mean +- sd shaded = dict(color=color_map.colors[idx], alpha=0.25) line = dict(color=color_map.colors[idx], marker=markers[idx], markevery=20) if activity == 'SA': shaded['hatch'] = '...' phadke_ln = mean_sd_plot(axs[1, 0], x, phadke_mean_act, phadke_sd_act, shaded, line) isb_ln = mean_sd_plot(axs[2, 0], x, isb_mean_act, isb_sd_act, shaded, line) isb_norm_ln = mean_sd_plot(axs[3, 0], x, isb_mean_norm_act, isb_sd_norm_act, shaded, line) # plot endpoints axs[1, 0].errorbar(max_pos + act_order[activity] * 3, phadke_mean_max, yerr=phadke_sd_max, color=color_map.colors[idx], marker=markers[2], capsize=3) axs[2, 0].errorbar(max_pos + act_order[activity] * 3, isb_mean_max, yerr=isb_sd_max,
isb_mean_max = np.rad2deg(np.mean(all_traj_isb_max, axis=0)) true_mean_max = np.rad2deg(np.mean(all_traj_true_max, axis=0)) isb_norm_mean_max = np.rad2deg(np.mean(all_traj_isb_norm_max, axis=0)) isb_sd_max = np.rad2deg(np.std(all_traj_isb_max, ddof=1, axis=0)) true_sd_max = np.rad2deg(np.std(all_traj_true_max, ddof=1, axis=0)) isb_norm_sd_max = np.rad2deg(np.std(all_traj_isb_norm_max, ddof=1, axis=0)) isb_poe_mean = np.rad2deg(np.mean(all_traj_isb_poe, axis=0)) isb_poe_sd = np.rad2deg(np.std(all_traj_isb_poe, ddof=1, axis=0)) isb_poe_mean_max = np.rad2deg(np.mean(all_traj_isb_poe_max, axis=0)) isb_poe_sd_max = np.rad2deg(np.std(all_traj_isb_poe_max, ddof=1, axis=0)) # plot mean +- sd cur_row = act_row[activity.lower()] true_ln = mean_sd_plot(axs_diff[cur_row], x, true_mean, true_sd, dict(color=color_map.colors[2], alpha=0.25), dict(color=color_map.colors[2], marker=markers[2], markevery=20)) isb_norm_ln = mean_sd_plot(axs_diff[cur_row], x, isb_norm_mean, isb_norm_sd, dict(color=color_map.colors[1], alpha=0.25), dict(color=color_map.colors[1], marker=markers[1], markevery=20)) isb_ln = mean_sd_plot(axs_diff[cur_row], x, isb_mean, isb_sd, dict(color=color_map.colors[0], alpha=0.3), dict(color=color_map.colors[0], marker=markers[0], markevery=20)) # poe_ln = mean_sd_plot(axs_diff[cur_row], x, isb_poe_mean, isb_poe_sd, # dict(color=color_map.colors[3], alpha=0.3), # dict(color=color_map.colors[3], marker=markers[0], markevery=20)) # plot endpoint axs_diff[cur_row].errorbar(x[-1] + (x[-1] - x[0]) * 0.1, true_mean_max, yerr=true_sd_max, color=color_map.colors[2], marker=markers[2], capsize=3) axs_diff[cur_row].errorbar(x[-1] + (x[-1] - x[0]) * 0.14, isb_norm_mean_max, yerr=isb_norm_sd_max,
# means true_mean = np.rad2deg(np.mean(all_traj_true, axis=0)) isb_mean = np.rad2deg(np.mean(all_traj_isb, axis=0)) isb_norm_mean = np.rad2deg(np.mean(all_traj_isb_norm, axis=0)) phadke_mean = np.rad2deg(np.mean(all_traj_phadke, axis=0)) # sds true_sd = np.rad2deg(np.std(all_traj_true, ddof=1, axis=0)) isb_sd = np.rad2deg(np.std(all_traj_isb, ddof=1, axis=0)) isb_norm_sd = np.rad2deg(np.std(all_traj_isb_norm, ddof=1, axis=0)) phadke_sd = np.rad2deg(np.std(all_traj_phadke, ddof=1, axis=0)) # plots mean +- sd phadke_ln = mean_sd_plot( axs[idx_act, 0], x, phadke_mean, phadke_sd, dict(color=color_map.colors[1], alpha=0.2), dict(color=color_map.colors[1], marker=markers[1], markevery=20)) true_left_ln = mean_sd_plot( axs[idx_act, 0], x, true_mean, true_sd, dict(color=color_map.colors[2], alpha=0.2, hatch='...'), dict(color=color_map.colors[2], marker=markers[2], markevery=20)) isb_ln = mean_sd_plot( axs[idx_act, 1], x, isb_mean, isb_sd, dict(color=color_map.colors[0], alpha=0.2), dict(color=color_map.colors[0], marker=markers[0], markevery=20)) isb_norm_ln = mean_sd_plot( axs[idx_act, 1], x, isb_norm_mean, isb_norm_sd, dict(color=color_map.colors[3], alpha=0.2), dict(color=color_map.colors[3], marker=markers[2], markevery=20)) true_right_ln = mean_sd_plot( axs[idx_act, 1], x, true_mean, true_sd,
elev_mean = np.rad2deg(np.nanmean(all_traj_elev, axis=0)) poe_mean = np.rad2deg(np.nanmean(all_traj_poe, axis=0)) axial_mean = np.rad2deg(np.nanmean(all_traj_axial, axis=0)) elev_sd = np.rad2deg(np.nanstd(all_traj_elev, ddof=1, axis=0)) poe_sd = np.rad2deg(np.nanstd(all_traj_poe, ddof=1, axis=0)) axial_sd = np.rad2deg(np.nanstd(all_traj_axial, ddof=1, axis=0)) present_counts = np.count_nonzero(~np.isnan(all_traj_elev), axis=0) print(activity + ': ') print(present_counts) cur_row = act_row[activity.lower()] elev_ln = mean_sd_plot( axs_std_hum[cur_row, 0], ours_ht, elev_mean, elev_sd, dict(color=color_map.colors[0], alpha=0.25), dict(color=color_map.colors[0], marker=markers[0])) poe_ln = mean_sd_plot( axs_std_hum[cur_row, 0], ours_ht, poe_mean, poe_sd, dict(color=color_map.colors[1], alpha=0.25), dict(color=color_map.colors[1], marker=markers[1])) ax_ln = mean_sd_plot( axs_std_hum[cur_row, 1], ours_ht, axial_mean, axial_sd, dict(color=color_map.colors[2], alpha=0.25), dict(color=color_map.colors[2], marker=markers[2])) if idx == 0: leg_patch_ours_std_hum.append(elev_ln[0]) leg_patch_ours_std_hum.append(poe_ln[0])
isb_norm_sd = np.rad2deg(np.std(all_traj_isb_norm, ddof=1, axis=0)) isb_mean_max = np.rad2deg(np.mean(all_traj_isb_max, axis=0)) isb_norm_mean_max = np.rad2deg(np.mean(all_traj_isb_norm_max, axis=0)) phadke_mean_max = np.rad2deg(np.mean(all_traj_phadke_max, axis=0)) true_mean_max = np.rad2deg(np.mean(all_traj_true_max, axis=0)) isb_sd_max = np.rad2deg(np.std(all_traj_isb_max, ddof=1, axis=0)) isb_norm_sd_max = np.rad2deg( np.std(all_traj_isb_norm_max, ddof=1, axis=0)) phadke_sd_max = np.rad2deg(np.std(all_traj_phadke_max, ddof=1, axis=0)) true_sd_max = np.rad2deg(np.std(all_traj_true_max, ddof=1, axis=0)) # plot mean +- sd cur_row = act_row[activity.lower()] true_ln_left = mean_sd_plot( axs_diff[cur_row, 0], x, true_mean, true_sd, dict(color=color_map.colors[2], alpha=0.3, hatch='...'), dict(color=color_map.colors[2], marker=markers[2], markevery=20)) phadke_ln = mean_sd_plot( axs_diff[cur_row, 0], x, phadke_mean, phadke_sd, dict(color=color_map.colors[1], alpha=0.25), dict(color=color_map.colors[1], marker=markers[1], markevery=20)) true_ln_right = mean_sd_plot( axs_diff[cur_row, 1], x, true_mean, true_sd, dict(color=color_map.colors[2], alpha=0.3, hatch='...'), dict(color=color_map.colors[2], marker=markers[2], markevery=20)) isb_ln = mean_sd_plot( axs_diff[cur_row, 1], x, isb_mean, isb_sd, dict(color=color_map.colors[0], alpha=0.25), dict(color=color_map.colors[0], marker=markers[0], markevery=20)) isb_norm_ln = mean_sd_plot(
alpha, two_tailed=True) m_v_f_true = spm1d.stats.ttest2(all_traj_true_m[:, 1:], all_traj_true_f[:, 1:], equal_var=False).inference( alpha, two_tailed=True) # plot mean +- sd shaded_m = dict(color=color_map.colors[0], alpha=0.25) shaded_f = dict(color=color_map.colors[1], alpha=0.25) line_m = dict(color=color_map.colors[0], marker=markers[0], markevery=20) line_f = dict(color=color_map.colors[1], marker=markers[1], markevery=20) m_true_ln = mean_sd_plot(axs_gender[0, 0], x, true_mean_m, true_sd_m, shaded_m, line_m) f_true_ln = mean_sd_plot(axs_gender[0, 0], x, true_mean_f, true_sd_f, shaded_f, line_f) m_isb_ln = mean_sd_plot(axs_gender[1, 0], x, isb_mean_m, isb_sd_m, shaded_m, line_m) f_isb_ln = mean_sd_plot(axs_gender[1, 0], x, isb_mean_f, isb_sd_f, shaded_f, line_f) m_phadke_ln = mean_sd_plot(axs_gender[2, 0], x, phadke_mean_m, phadke_sd_m, shaded_m, line_m) f_phadke_ln = mean_sd_plot(axs_gender[2, 0], x, phadke_mean_f, phadke_sd_f, shaded_f, line_f) # plot spm spm_shaded = dict(color=color_map.colors[2], alpha=0.25) spm_line = dict(color=color_map.colors[2]) true_spm_ln = spm_plot(axs_gender[0, 1], x[1:], m_v_f_true, spm_shaded,
..., np.newaxis] isb_mean_act = np.rad2deg(np.mean(all_traj_isb_act, axis=0)) phadke_mean_act = np.rad2deg(np.mean(all_traj_phadke_act, axis=0)) true_mean_act = np.rad2deg(np.mean(all_traj_true_act, axis=0)) isb_sd_act = np.rad2deg(np.std(all_traj_isb_act, ddof=1, axis=0)) phadke_sd_act = np.rad2deg( np.std(all_traj_phadke_act, ddof=1, axis=0)) true_sd_act = np.rad2deg(np.std(all_traj_true_act, ddof=1, axis=0)) # plot mean +- sd shaded = dict(color=color_map.colors[idx], alpha=0.25) line = dict(color=color_map.colors[idx], marker=markers[idx], markevery=20) true_ln = mean_sd_plot(axs_plane[0, 0], x, true_mean_act, true_sd_act, shaded, line) isb_ln = mean_sd_plot(axs_plane[1, 0], x, isb_mean_act, isb_sd_act, shaded, line) phadke_ln = mean_sd_plot(axs_plane[2, 0], x, phadke_mean_act, phadke_sd_act, shaded, line) mean_lns.append(true_ln[0]) activities.append(activity) # figure title and legend plt.tight_layout(pad=0.25, h_pad=1.5, w_pad=0.5) fig_plane.suptitle(traj + ' Axial Rotation Comparison by Plane', x=0.5, y=0.99, fontweight='bold') plt.subplots_adjust(top=0.93)
elev_mean_gc = np.rad2deg(np.mean(all_traj_elev_gc, axis=0)) poe_mean_gc = np.rad2deg(np.mean(all_traj_poe_gc, axis=0)) axial_mean_gc = np.rad2deg(np.mean(all_traj_axial_gc, axis=0)) elev_sd_gc = np.rad2deg(np.std(all_traj_elev_gc, ddof=1, axis=0)) poe_sd_gc = np.rad2deg(np.std(all_traj_poe_gc, ddof=1, axis=0)) axial_sd_gc = np.rad2deg(np.std(all_traj_axial_gc, ddof=1, axis=0)) present_counts = np.count_nonzero(~np.isnan(all_traj_elev_ac), axis=0) print(activity + ': ') print(present_counts) cur_row = act_row[activity.lower()] elev_ln_ac = mean_sd_plot( axs_std_hum[cur_row, 0], ours_ht, elev_mean_ac, elev_sd_ac, dict(color=color_map.colors[0], alpha=0.25), dict(color=color_map.colors[0], marker=markers[0], ls='--', fillstyle='none')) poe_ln_ac = mean_sd_plot( axs_std_hum[cur_row, 0], ours_ht, poe_mean_ac, poe_sd_ac, dict(color=color_map.colors[1], alpha=0.25), dict(color=color_map.colors[1], marker=markers[1], ls='--', fillstyle='none')) ax_ln_ac = mean_sd_plot( axs_std_hum[cur_row, 1], ours_ht, axial_mean_ac, axial_sd_ac, dict(color=color_map.colors[2], alpha=0.25), dict(color=color_map.colors[2], marker=markers[2],
alpha, two_tailed=True) lt35_v_gt45_true = spm1d.stats.ttest2(all_traj_true_lt35[:, 1:], all_traj_true_gt45[:, 1:], equal_var=False).inference( alpha, two_tailed=True) # plot mean +- sd shaded_lt35 = dict(color=color_map.colors[0], alpha=0.25) shaded_gt45 = dict(color=color_map.colors[1], alpha=0.25) line_lt35 = dict(color=color_map.colors[0], marker=markers[0], markevery=20) line_gt45 = dict(color=color_map.colors[1], marker=markers[1], markevery=20) lt35_true_ln = mean_sd_plot(axs_age[0, 0], x, true_mean_lt35, true_sd_lt35, shaded_lt35, line_lt35) gt45_true_ln = mean_sd_plot(axs_age[0, 0], x, true_mean_gt45, true_sd_gt45, shaded_gt45, line_gt45) lt35_isb_ln = mean_sd_plot(axs_age[1, 0], x, isb_mean_lt35, isb_sd_lt35, shaded_lt35, line_lt35) gt45_isb_ln = mean_sd_plot(axs_age[1, 0], x, isb_mean_gt45, isb_sd_gt45, shaded_gt45, line_gt45) lt35_phadke_ln = mean_sd_plot(axs_age[2, 0], x, phadke_mean_lt35, phadke_sd_lt35, shaded_lt35, line_lt35) gt45_phadke_ln = mean_sd_plot(axs_age[2, 0], x, phadke_mean_gt45, phadke_sd_gt45, shaded_gt45, line_gt45) # plot spm spm_shaded = dict(color=color_map.colors[2], alpha=0.25) spm_line = dict(color=color_map.colors[2]) true_spm_ln = spm_plot(axs_age[0, 1], x[1:], lt35_v_gt45_true,
all_traj_true_axial = np.stack(activity_df['traj_interp'].apply( extract_sub_rot, args=['gh', 'common_coarse_up', 'true_axial_rot', None]), axis=0) all_traj_axial = all_traj_axial - all_traj_axial[:, 0][..., np.newaxis] all_traj_true_axial = all_traj_true_axial - all_traj_true_axial[:, 0][ ..., np.newaxis] axial_mean = np.rad2deg(np.nanmean(all_traj_axial, axis=0)) true_axial_mean = np.rad2deg(np.nanmean(all_traj_true_axial, axis=0)) axial_sd = np.rad2deg(np.nanstd(all_traj_axial, ddof=1, axis=0)) true_axial_sd = np.rad2deg( np.nanstd(all_traj_true_axial, ddof=1, axis=0)) ax_ln = mean_sd_plot( axs_axial[0, 0], ours_ht, axial_mean, axial_sd, dict(color=color_map.colors[idx], alpha=0.25), dict(color=color_map.colors[idx], marker=markers[idx])) true_ax_ln = mean_sd_plot( axs_axial[0, 1], ours_ht, true_axial_mean, true_axial_sd, dict(color=color_map.colors[idx], alpha=0.25), dict(color=color_map.colors[idx], marker=markers[idx], ls='--', fillstyle='none')) leg_patch_ours_axial.append(ax_ln[0]) leg_patch_ours_axial.append(true_ax_ln[0]) present_counts = np.count_nonzero(~np.isnan(all_traj_axial), axis=0) print(activity + ': ')
all_traj_phadke_up[:, 1:], all_traj_phadke_down[:, 1:]).inference(alpha, two_tailed=True) up_v_down_true = spm1d.stats.ttest_paired( all_traj_true_up[:, 1:], all_traj_true_down[:, 1:]).inference(alpha, two_tailed=True) # plot mean +- sd shaded_up = dict(color=color_map.colors[0], alpha=0.25) shaded_down = dict(color=color_map.colors[1], alpha=0.25) line_up = dict(color=color_map.colors[0], marker=markers[0], markevery=20) line_down = dict(color=color_map.colors[1], marker=markers[1], markevery=20) up_true_ln = mean_sd_plot(axs_updown[0, 0], x, true_mean_up, true_sd_up, shaded_up, line_up) down_true_ln = mean_sd_plot(axs_updown[0, 0], x, true_mean_down, true_sd_down, shaded_down, line_down) up_isb_ln = mean_sd_plot(axs_updown[1, 0], x, isb_mean_up, isb_sd_up, shaded_up, line_up) down_isb_ln = mean_sd_plot(axs_updown[1, 0], x, isb_mean_down, isb_sd_down, shaded_down, line_down) up_phadke_ln = mean_sd_plot(axs_updown[2, 0], x, phadke_mean_up, phadke_sd_up, shaded_up, line_up) down_phadke_ln = mean_sd_plot(axs_updown[2, 0], x, phadke_mean_down, phadke_sd_down, shaded_down, line_down) # plot spm spm_shaded = dict(color=color_map.colors[2], alpha=0.25) spm_line = dict(color=color_map.colors[2]) true_spm_ln = spm_plot(axs_updown[0, 1], x[1:], up_v_down_true,
extract_sub_rot_norm, args=['gh', 'common_fine_up', 'true_axial_rot', None, 'up']), axis=0) all_traj_true_aa = np.stack(act_df_aa['traj_interp'].apply( extract_sub_rot_norm, args=['gh', 'common_fine_up', 'true_axial_rot', None, 'up']), axis=0) # means and standard deviations true_mean_gc = np.rad2deg(np.mean(all_traj_true_gc, axis=0)) true_mean_ac = np.rad2deg(np.mean(all_traj_true_ac, axis=0)) true_mean_aa = np.rad2deg(np.mean(all_traj_true_aa, axis=0)) true_sd_gc = np.rad2deg(np.std(all_traj_true_gc, ddof=1, axis=0)) true_sd_ac = np.rad2deg(np.std(all_traj_true_ac, ddof=1, axis=0)) true_sd_aa = np.rad2deg(np.std(all_traj_true_aa, ddof=1, axis=0)) # plot mean +- sd cur_row = act_row[act_gc.lower()] true_ln_gc = mean_sd_plot(axs_diff[cur_row], x, true_mean_gc, true_sd_gc, dict(color=color_map.colors[0], alpha=0.3), dict(color=color_map.colors[0], marker=markers[0], markevery=20)) true_ln_ac = mean_sd_plot(axs_diff[cur_row], x, true_mean_ac, true_sd_ac, dict(color=color_map.colors[1], alpha=0.3), dict(color=color_map.colors[1], marker=markers[1], markevery=20)) true_ln_aa = mean_sd_plot(axs_diff[cur_row], x, true_mean_aa, true_sd_aa, dict(color=color_map.colors[2], alpha=0.3), dict(color=color_map.colors[2], marker=markers[2], markevery=20)) if idx == 0: leg_mean.append(true_ln_gc[0]) leg_mean.append(true_ln_ac[0]) leg_mean.append(true_ln_aa[0]) # figure title and legend plt.tight_layout(pad=0.5, h_pad=1.5, w_pad=0.5)