Skip to content

Commit

Permalink
Removed spelling mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomahawkuru committed Jul 12, 2021
1 parent dc167bd commit 1ec222b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
10 changes: 5 additions & 5 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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
Expand All @@ -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
```

Expand Down
28 changes: 14 additions & 14 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -54,22 +54,22 @@

# 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)
functions.save_events(Saccades, 'saccades.csv', outputpath)
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)
Expand Down
12 changes: 6 additions & 6 deletions plotters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
18 changes: 9 additions & 9 deletions readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
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]

csvdata = pandas.read_csv(path + file[0], delimiter=',')

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'])
Expand All @@ -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

0 comments on commit 1ec222b

Please sign in to comment.