// calculate medians and save results public void finish() { /* calculate medians */ int[] reactTimesCorrect = new int[totalCorrect]; int[] reactTimesIncorrect = new int[totalCompleted - totalCorrect]; int rtcIndex = 0, rtiIndex = 0; for (int i = 0; i < totalCompleted; i++) { if (trials[i].correct) { reactTimesCorrect[rtcIndex++] = trials[i].reactTime; } else { reactTimesIncorrect[rtiIndex++] = trials[i].reactTime; } } this.mrtCorrect = CogTest.findMedian(ref reactTimesCorrect); this.mrtIncorrect = CogTest.findMedian(ref reactTimesIncorrect); saveResultsFile(); }