From db783969dcf73f287f351795b26640a8666d6a4c Mon Sep 17 00:00:00 2001 From: Thomas de boer Date: Thu, 15 Jul 2021 16:46:51 +0200 Subject: [PATCH] Added error catching during plotting, if some type of gaze event has not been detected at all --- plotters.py | 93 ++++++++++++++++++++++++++++------------------------- 1 file changed, 49 insertions(+), 44 deletions(-) diff --git a/plotters.py b/plotters.py index 0bbf3e6..ddd7966 100644 --- a/plotters.py +++ b/plotters.py @@ -39,50 +39,55 @@ def detection(x, y, t, v, fixations, saccades, pursuits, blinks, trials, trial, def calculation(fixations, saccades, pursuits, blinks, trial, participant): plt.figure(trial + 1, figsize=[25.60, 14.40]) - plt.subplot(4, 4, 1) - histogramreighley(fixations[:, 2]) - plt.title("Fixation duration") - plt.xlabel('Time [s]') - - plt.subplot(4, 4, 5) - histogramreighley(saccades[:, 2]) - plt.title("Saccade duration") - plt.xlabel('Time [s]') - plt.subplot(4, 4, 6) - histogramreighley(saccades[:, 7]) - plt.title("Saccade amplitude") - plt.xlabel('Amplitude [deg]') - plt.subplot(4, 4, 7) - histogramreighley(saccades[:, 8]) - plt.title("Saccade mean velocity") - plt.xlabel('Velocity [deg/s]') - plt.subplot(4, 4, 8) - histogramreighley(saccades[:, 9]) - plt.title("Saccade max velocity") - plt.xlabel('Velocity [deg/s]') - - plt.subplot(4, 4, 9) - histogramreighley(pursuits[:, 2]) - plt.title("Pursuit duration") - plt.xlabel('Time [s]') - plt.subplot(4, 4, 10) - histogramreighley(pursuits[:, 7]) - plt.title("Pursuit amplitude") - plt.xlabel('Amplitude [deg]') - plt.subplot(4, 4, 11) - plt.xlabel('Amplitude [deg]') - histogramreighley(pursuits[:, 8]) - plt.title("Pursuit mean velocity") - plt.xlabel('Velocity [deg/s]') - plt.subplot(4, 4, 12) - histogramreighley(pursuits[:, 9]) - plt.title("Pursuit max velocity") - plt.xlabel('Velocity [deg/s]') - - plt.subplot(4, 4, 13) - histogramreighley(blinks[:, 2]) - plt.title("Blink duration") - plt.xlabel('Time [s]') + + if fixations.any(): + plt.subplot(4, 4, 1) + histogramreighley(fixations[:, 2]) + plt.title("Fixation duration") + plt.xlabel('Time [s]') + + if saccades.any(): + plt.subplot(4, 4, 5) + histogramreighley(saccades[:, 2]) + plt.title("Saccade duration") + plt.xlabel('Time [s]') + plt.subplot(4, 4, 6) + histogramreighley(saccades[:, 7]) + plt.title("Saccade amplitude") + plt.xlabel('Amplitude [deg]') + plt.subplot(4, 4, 7) + histogramreighley(saccades[:, 8]) + plt.title("Saccade mean velocity") + plt.xlabel('Velocity [deg/s]') + plt.subplot(4, 4, 8) + histogramreighley(saccades[:, 9]) + plt.title("Saccade max velocity") + plt.xlabel('Velocity [deg/s]') + + if pursuits.any(): + plt.subplot(4, 4, 9) + histogramreighley(pursuits[:, 2]) + plt.title("Pursuit duration") + plt.xlabel('Time [s]') + plt.subplot(4, 4, 10) + histogramreighley(pursuits[:, 7]) + plt.title("Pursuit amplitude") + plt.xlabel('Amplitude [deg]') + plt.subplot(4, 4, 11) + plt.xlabel('Amplitude [deg]') + histogramreighley(pursuits[:, 8]) + plt.title("Pursuit mean velocity") + plt.xlabel('Velocity [deg/s]') + plt.subplot(4, 4, 12) + histogramreighley(pursuits[:, 9]) + plt.title("Pursuit max velocity") + plt.xlabel('Velocity [deg/s]') + + if blinks.any(): + plt.subplot(4, 4, 13) + histogramreighley(blinks[:, 2]) + plt.title("Blink duration") + plt.xlabel('Time [s]') plt.tight_layout()