def subject_summary(dm): """ desc: Plots the mean difference in pupil size between dark and bright trials for each participant as a bar plot. The time window is indicated by the PEAKWIN constant. This data is also written to a .csv file. arguments: dm: type: DataMatrix """ x = np.arange(len(dm.subject_nr.unique)) sm = DataMatrix(length=len(dm.subject_nr.unique)) sm.subject_nr = 0 sm.effect_win = FloatColumn sm.effect_win_se = FloatColumn sm.effect_full = FloatColumn sm.effect_full_se = FloatColumn for i, s in enumerate(dm.subject_nr.unique): _dm = dm.subject_nr == s sm.subject_nr[i] = s sm.effect_win[i], sm.effect_win_se[i] = effect_se(_dm, PEAKWIN[0], PEAKWIN[1]) sm.effect_full[i], sm.effect_full_se[i] = effect_se(_dm) sm = operations.sort(sm, by=sm.effect_win) plot.new(size=(4, 3)) plt.axhline(0, color="black") plt.plot(sm.effect_win, "o-", color=green[-1]) plt.errorbar(x, sm.effect_win, yerr=sm.effect_win_se, linestyle="", color=green[-1], capsize=0) plt.xlim(-1, 30) plt.ylabel("Pupil-size difference (normalized)") plt.xlabel("Participant") plt.xticks([]) plot.save("subject_summary") io.writetxt(sm, "%s/subject_summary.csv" % OUTPUT_FOLDER)