From 1ec222b7fb902a68b8755e2ed2c7f52628cb7fb7 Mon Sep 17 00:00:00 2001 From: Thomas de Boer Date: Mon, 12 Jul 2021 12:47:34 +0200 Subject: [PATCH] Removed spelling mistake --- Readme.md | 10 +++++----- main.py | 28 ++++++++++++++-------------- plotters.py | 12 ++++++------ readers.py | 18 +++++++++--------- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Readme.md b/Readme.md index 010e002..bd3d06f 100644 --- a/Readme.md +++ b/Readme.md @@ -42,8 +42,8 @@ Both methods produce a .csv with eye-tracking data, which VarjoGazeDetector can Only Varjo Base recording produces a video capture automatically. When Varjo Base is used, the detections are matched with the time of the video. -The tool is set up to assume a folder structure based on research participants with a certain number of trails each. -Make sure the folder structure is participant/trail as follows, if you would like to use the tool as is. Both recording methods can be mixed. +The tool is set up to assume a folder structure based on research participants with a certain number of trials each. +Make sure the folder structure is participant/trial as follows, if you would like to use the tool as is. Both recording methods can be mixed. data_folder/ 1/ @@ -64,7 +64,7 @@ Make sure the folder structure is participant/trail as follows, if you would lik 2/ varjo_gaze_output_XX-XX-XXXX.csv -The detection results are saved in a 'detection' folder in each trail folder. +The detection results are saved in a 'detection' folder in each trial folder. Detection and their measures are saved as fixations.csv, saccades.csv, persuits.csv and blinks.csv # How to use @@ -82,11 +82,11 @@ savefig = False # whether or not the plot figures are saved after de debugdetection = False # show runtime info about the detection in the console printresults = True # show results of the detection in the console ``` -Also in main.py you have to give the path to the data folder, and specify the participants and trails +Also in main.py you have to give the path to the data folder, and specify the participants and trials ```python datapath = 'C:/path_to_data' # put the full path to your data here participants = 2 # number of participants -trails = 2 # trails per participant +trials = 2 # trials per participant filename = 'varjo_gaze_output' # looks for files with this string in the name ``` diff --git a/main.py b/main.py index a51d21d..4ac9e13 100644 --- a/main.py +++ b/main.py @@ -17,22 +17,22 @@ # Import csv files -------------------------------------------------------------------------------------------------- datapath = os.getcwd() + "/testdata/" # put the full path to your data here participants = 2 # number of participants -trails = 2 # trails per participant +trials = 2 # trials per participant filename = 'varjo_gaze_output' # looks for files with this string in the name for participant in range(1, participants + 1): print(), print(), print('Analyisis results for participant {}'.format(participant)) #start plot - fig, axs = plt.subplots(trails, figsize=[25.60, 7.20*trails]) - fig.suptitle('Detection per trail for participant {}'.format(participant)) + fig, axs = plt.subplots(trials, figsize=[25.60, 7.20*trials]) + fig.suptitle('Detection per trial for participant {}'.format(participant)) - for trail in range(1, trails + 1): - trailpath = datapath + '{}/{}/'.format(participant,trail) + for trial in range(1, trials + 1): + trialpath = datapath + '{}/{}/'.format(participant,trial) - print(), print('Trail ' + str(trail)) - gazedata = readers.Gaze(datapath, participant, trail, filename) - pupildata = readers.Pupil(datapath, participant, trail, filename) - focusdata = readers.Focus(datapath, participant, trail, filename) + print(), print('Trial ' + str(trial)) + gazedata = readers.Gaze(datapath, participant, trial, filename) + pupildata = readers.Pupil(datapath, participant, trial, filename) + focusdata = readers.Focus(datapath, participant, trial, filename) # classify gaze events ---------------------------------------------------------------------------------------------- classifiedgazedata = run_detection.DetectGazeEvents(gazedata, debugdetection) @@ -54,7 +54,7 @@ # Saving gaze event data --------------------------------------------------------------------------------------------- if savedata: - outputpath = trailpath + 'detection' + outputpath = trialpath + 'detection' Path(outputpath).mkdir(parents=True, exist_ok=True) # save detections per even type with their measures functions.save_events(Fixations, 'fixations.csv', outputpath) @@ -62,14 +62,14 @@ functions.save_events(Persuits, 'persuits.csv', outputpath) functions.save_events(Blinks, 'blinks.csv', outputpath) # add gaze_event classification column to raw data and save copy - csvdata = readers.file_reader(datapath, participant, trail, filename) + csvdata = readers.file_reader(datapath, participant, trial, filename) csvdata["gaze_event"] = classifiedgazedata['data']['EYE_MOVEMENT_TYPE'] csvdata.to_csv(outputpath + "/classified_data.csv") # Plotting and saving------------------------------------------------------------------------------------------------ - plotters.detection(x, y, t, v, Fixations, Saccades, Persuits, Blinks, trails, trail, axs) - plotters.calculation(Fixations, Saccades, Persuits, Blinks, trail, participant) - outputpath = trailpath + "calculation-p{}-t{}.png".format(participant, trail, participant, trail) + plotters.detection(x, y, t, v, Fixations, Saccades, Persuits, Blinks, trials, trial, axs) + plotters.calculation(Fixations, Saccades, Persuits, Blinks, trial, participant) + outputpath = trialpath + "calculation-p{}-t{}.png".format(participant, trial, participant, trial) if savefig: plt.savefig(outputpath, bbox_inches='tight') plt.figure(1) diff --git a/plotters.py b/plotters.py index 1cc3726..de05317 100644 --- a/plotters.py +++ b/plotters.py @@ -7,12 +7,12 @@ Functions for helping with plotting of various figures and data """ -def detection(x, y, t, v, fixations, saccades, persuits, blinks, trails, trail, axs): - if trails > 1: - axs1 = axs[trail - 1] +def detection(x, y, t, v, fixations, saccades, persuits, blinks, trials, trial, axs): + if trials > 1: + axs1 = axs[trial - 1] else: axs1 = axs - axs1.set_title('Trail ' + str(trail)) + axs1.set_title('Trial ' + str(trial)) axs1.set_xlabel('Time [s]') axs1.plot(t, v, 'silver', label="Velocity") @@ -37,8 +37,8 @@ def detection(x, y, t, v, fixations, saccades, persuits, blinks, trails, trail, axs1.legend(loc='upper left') axs2.legend(loc='upper right') -def calculation(fixations, saccades, persuits, blinks, trail, participant): - plt.figure(trail + 1, figsize=[25.60, 14.40]) +def calculation(fixations, saccades, persuits, blinks, trial, participant): + plt.figure(trial + 1, figsize=[25.60, 14.40]) plt.subplot(4, 4, 1) histogramreighley(fixations[:, 2]) plt.title("Fixation duration") diff --git a/readers.py b/readers.py index d4538d0..3bd0aa8 100644 --- a/readers.py +++ b/readers.py @@ -5,9 +5,9 @@ import numpy as np -def file_reader(path, participant, trail, filename): +def file_reader(path, participant, trial, filename): # read data file - path = path + str(participant) + "/" + str(trail) + "/" + path = path + str(participant) + "/" + str(trial) + "/" file = [i for i in os.listdir(path) if os.path.isfile(os.path.join(path, i)) and \ filename in i] @@ -15,10 +15,10 @@ def file_reader(path, participant, trail, filename): return csvdata -def Gaze(path, participant, trail, filename): +def Gaze(path, participant, trial, filename): - gazeData = file_reader(path, participant, trail, filename) - fname = "P" + str(participant) + "_T" + str(trail) + gazeData = file_reader(path, participant, trial, filename) + fname = "P" + str(participant) + "_T" + str(trial) # Raw Gaze data s = np.array(gazeData['status']) @@ -44,18 +44,18 @@ def Gaze(path, participant, trail, filename): return gaze_points -def Pupil(path, participant, trail, filename): +def Pupil(path, participant, trial, filename): - gazeData = file_reader(path, participant, trail, filename) + gazeData = file_reader(path, participant, trial, filename) left = np.array(gazeData['left_pupil_size']) right = np.array(gazeData['right_pupil_size']) return left, right -def Focus(path, participant, trail, filename): +def Focus(path, participant, trial, filename): - gazeData = file_reader(path, participant, trail, filename) + gazeData = file_reader(path, participant, trial, filename) focus = np.array(gazeData['focus_distance']) return focus