Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.chdir("/Users/Documents//Analyse/Eye movements/Python - Eye Analyse")
- directory = '/Users/Documents/Analyse/Eye movements/R - Filtering Data/Filtered_data/Filtered_data_test'
- for files in glob.glob(os.path.join(directory,"*.csv")):
- #Downloas csv, plot
- df = pd.read_csv(files, parse_dates = True)
- #Plot raw data
- plt.plot(df['eye_x'],df['eye_y'], 'ro', c="red")
- plt.ylim([0,1080])
- plt.xlim([0,1920])
- #Fixation analysis
- from detectors import fixation_detection
- fixations_data = fixation_detection(df['eye_x'],df['eye_y'], df['time'],maxdist=25, mindur=100)
- Efix_data = fixations_data[1]
- numb_fixations = len(Efix_data) #number of fixations
- fixation_start = [i[0] for i in Efix_data]
- fixation_stop = [i[1] for i in Efix_data]
- fixation = {'start' : fixation_start, 'stop': fixation_stop}
- fixation_frame = pd.DataFrame(data=fixation)
- fixation_frame['difference'] = fixation_frame['stop'] - fixation_frame['start']
- mean_fixation_time = fixation_frame['difference'].mean() #mean fixation time
- final = {'number_fixations' : [numb_fixations], 'mean_fixation_time': [mean_fixation_time]}
- final_frame = pd.DataFrame(data=final)
- #write everything in one document
- final_frame.to_csv("/Users/Documents/Analyse/Eye movements/final_data.csv")
Add Comment
Please, Sign In to add comment