1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- function example_eye_data(filename, n)
- %EXAMPLE_EYE_DATA plots eye-movement data.
- %
- % EXAMPLE_EYE_DATA(filename, n) plots the x-position, y-position, right and
- % left pupil size for the first n time steps (1 time step = 1000micro secs)
- % for the file specified by filename. It also prints the correlation
- % between right and left pupil size across the entire recording.
- % This function only works for files that end in "-eye.h5", e.g.
- % amm-MSTm-sun-085-01+01-eye.h5
- %
- % INPUT:
- % filename: string; name of a .h5 file from the data folder,
- % e.g., 'amm-MSTm-sun-090-01+01-eye.h5'
- % n: number of time steps (default is 100)
- %
- % Benedict Wild (bwild(at)dpz.eu), 2021
- if nargin < 2
- n = 100;
- end
- % set parameters for plotting
- set(0, 'DefaultLineLineWidth', 2)
- set(0,'defaultAxesFontSize', 20)
- % read in h5 file
- param2read = {'/event_value', '/event_time'};
- file_info = h5info(filename, '/event_value'); % Matlab function
- events2read = {file_info.Datasets.Name};
- [event_value, event_time] = h5_extract(filename, param2read, events2read); % custom function
- % savety precaution in case user enters n that is too big
- n = min(n, length(event_value.EYE_x_dva));
- % Plot
- xx = event_time.EYE_x_dva(1:n)-event_time.EYE_x_dva(1);
- figure('Color',[1,1,1],'Position',[0, 0, 500, 1200]);
- subplot(411);
- plot(xx,event_value.EYE_x_dva(1:n));
- title('X position');
- subplot(412);
- plot(xx,event_value.EYE_y_dva(1:n));
- title('Y position');
- subplot(413);
- plot(xx,event_value.EYE_pupilSizeRight_raw(1:n));
- title('Pupil Size Right');
- subplot(414);
- plot(xx,event_value.EYE_pupilSizeLeft_raw(1:n));
- title('Pupil Size Left');
- xlabel('Time [micro seconds]');
- % correlation
- fprintf("Correlation between right and left pupil size: %.2f\n", corr(double(event_value.EYE_pupilSizeLeft_raw)',double(event_value.EYE_pupilSizeRight_raw)'));
|