Commit 62cd3eae authored by mposthuma's avatar mposthuma
Browse files

Made plots of epoched test data azimuth and elevation

Added startup.mat for uni computer
Made target response plots for saccades with different conditions
parent aed7b9f5
%plot epoched Azimuth data together in 1 plot.
AzEye = Data.epoch.AzEyeEpoched(1:360);
AzGaze = Data.epoch.AzGazeEpoched(1:360);
AzChair = Data.epoch.AzChairEpoched(1:360);
AzHead = Data.epoch.AzHeadEpoched(1:360);
TargetAz = Data.stimuli.azimuth(1:1);
t = 1/120:1/120:3;
cfn = pb_newfig(cfn);
hold on
axis square
plot(t, AzEye);
plot(t, AzGaze);
plot(t, AzChair);
plot(t, AzHead);
plot(t(1), TargetAz,'o');
x = [0 0.23 0.23 0];
y = [-10 -10 50 50];
patch(x, y, 'red');
title('Example Epoched Saccade Azimuth');
legend('AzEye', 'AzGaze', 'AzChair', 'AzHead', 'TargetAz', 'ReactionTime');
xlabel('Time(s)');
ylabel('Response($^{\circ}$)');
pb_nicegraph;
%%
%plot epoched Elevation data together in 1 plot.(2nd trial epoch)
ElEye = Data.epoch.ElEyeEpoched(361:720);
ElGaze = Data.epoch.ElGazeEpoched(361:720);
ElChair = Data.epoch.ElChairEpoched(361:720);
ElHead = Data.epoch.ElHeadEpoched(361:720);
TargetEl = Data.stimuli.elevation(1:2);
t = 1/120:1/120:3;
cfn = pb_newfig(cfn);
hold on
axis square
plot(t, ElEye);
plot(t, ElGaze);
plot(t, ElChair);
plot(t, ElHead);
plot(t(1), TargetEl,'o');
x = [0 0.2 0.2 0];
y = [-5 -5 35 35];
patch(x, y, 'red');
title('Example Epoched Saccade Elevation');
legend('ElEye', 'ElGaze', 'ElChair', 'ElHead', 'TargetEl', 'ReactionTime');
xlabel('Time(s)');
ylabel('Response($^{\circ}$)');
pb_nicegraph;
\ No newline at end of file
addpath(genpath('U:\Documents\BIOLOGIE\STAGE\MATLAB'));
init_biofysica
pb_setlatex
%% Initialize
%Clean everything
cfn = pb_clean('cd','U:\Documents\BIOLOGIE\STAGE\MATLAB\Data\test experiment');
%load epoched data
l = dir('epoched_data*.mat');
for iL = 1:length(l)
load(l(iL).name);
end
%pa_sac2mat; in command window
%load saccades
l = dir(['sacdet' filesep 'sacdet*.mat']);
load(['sacdet' filesep l(1).name]);
%% Extract data
%pb_vExtractPar.m
%get epoched gaze data traces
azimuth = Data.epoch.AzGazeEpoched;
elevation = Data.epoch.ElGazeEpoched;
% Run over saccades
for iS = 1:length(Sac)
trial_idx = Sac(iS,1);
%Get timings
start_trial_idx = (trial_idx-1)*360+1;
stimOn_idx = start_trial_idx;
sacOn_idx = Sac(iS,3) + start_trial_idx-1;
sacOff_idx = Sac(iS,4) + start_trial_idx-1;
%Super sac
SS(iS,1:4) = Sac(iS,1:4); %trial/saccade nr/sacc on sample/sac off sample
SS(iS,5) = 1/120*1000*Sac(iS,3); %saccade of reaction time RT
SS(iS,6) = 1/120*1000*(Sac(iS,4)-Sac(iS,3)); %duration
SS(iS,7) = azimuth(sacOn_idx); %Azimuth onset
SS(iS,8) = elevation(sacOn_idx); %Elevation onset
SS(iS,9) = azimuth(sacOff_idx); %Azimuth offset
SS(iS,10) = elevation(sacOff_idx); %Elevation offset
SS(iS,11) = SS(iS,9)-SS(iS,7); %Azimuth Saccade amplitude
SS(iS,12) = SS(iS,10)-SS(iS,8); %Elevation Saccade amplitude
SS(iS,13) = Data.stimuli.azimuth(SS(iS,1)); %Target azimuth
SS(iS,14) = Data.stimuli.elevation(SS(iS,1)); %Target elevation
SS(iS,15) = max(abs(diff(sqrt(azimuth(sacOn_idx:sacOff_idx).^2+elevation(sacOn_idx:sacOff_idx).^2))*120)); %max velocity
SS(iS,16) = sqrt(SS(iS,11)^2+SS(iS,12)^2); %R
end
%%
%criteria
sel_first = SS(:,2)==1; %only first saccade
sel_timing = SS(:,5)>80 & SS(:,5)<400; %between 80-400 ms
sel_SS = sel_first & sel_timing; %combine all
nSS = SS(sel_SS,:);
n_sacc = sum(sel_SS);
c_title= {'Azimuth','Elevation'};
col = pb_selectcolor(2,2);
cfn = pb_newfig(cfn);
for iS = 1:2
%get data
target = nSS(:,12+iS);
response = nSS(:,10+iS);
%graph
subplot(1,2,iS);
hold on;
axis square;
title(c_title{iS});
h(iS) = plot(target,response,'o');
hr(iS) = pb_regplot(target,response,'data',false);
xlabel('Target ($^{\circ}$)');
ylabel('Response ($^{\circ}$)');
xlim([-50 50]);
ylim([-50 50]);
pb_dline;
end
pb_nicegraph;
%color
for iH = length(h)
h(iH).Color = col(iH,:);
hr(iH).Color = col(iH,:);
end
%% Main Sequence vs amplitude
cfn = pb_newfig(cfn);
sgtitle('Main Sequence')
%Peak velocity
velocity = SS(:,15);
amplitude = abs(SS(:,16));
subplot(1,2,1);
hold on;
axis square
h(iS) = plot(amplitude,velocity,'o');
xlabel('Amplitude');
ylabel('Peak Velocity');
xlim([0 50])
ylim([0 800])
%Duration
duration = SS(:,6);
amplitude = abs(SS(:,16));
subplot(1,2,2);
hold on;
axis square
h(iS) = plot(amplitude,duration,'o');
xlabel('Amplitude');
ylabel('Duration');
xlim([0 50])
ylim([0 300])
pb_nicegraph;
pb_selectcolor
%criteria
%neem tweede saccade mee als 0.5 zo groot van eerste
%binnen 100 ms vallen van de eerste
%gaze shift- van begin naar eindpunt
%%
subplot(1,2,1);
hold on;
axis square;
title('Azimuth');
h(iS) = plot(target,response,'o');
hr(iS) = pb_regplot(target,response,'data',false);
xlabel('Target ($^{\circ}$)');
ylabel('Response ($^{\circ}$)');
xlim([-50 50]);
ylim([-50 50]);
pb_dline;
%% Clean
trial_idx = SS(:,1);
trial_idxU = unique(trial_idx);
trial_len = length(trial_idxU);
% Trials
for iT = 1:trial_len % run over all different trials
current_trial = trial_idxU(iT); % what is the current trial
sel_trial = trial_idx == current_trial; % select saccades within current trial
nr_saccades = sum(sel_trial); % number of saccades in current trial
% clear saccades
saccades = [];
total_sac = 0;
saccades = SS(sel_trial,:); % select relevant saccades in current trial
% Saccades azimuth (11, saccade amplitude)
% saccade RT (5)
for iS = 1:nr_saccades % run over all saccades in a trial
some_condintion = true;
% condition 1: RT >100 ms
if saccades(iS,5) < 100; some_condintion = false; end % tijd
% condition 2: RT < 400 ms
if saccades(iS,5) > 400; some_condintion = false; end % tijd
% condition 3: S(-1) AMP > S(0) AMP
if iS >= 2
last_sacc = abs(saccades(iS-1,11));
curr_sacc = abs(saccades(iS,11));
if curr_sacc>last_sacc; some_condintion = false; end % first saccade needs to be the largest
end
current_saccade_amplitude_az = saccades(iS,11); % azimuth
current_saccade_amplitude_el = saccades(iS,12); %elevation
if some_condintion
total_sac_az = total_sac + current_saccade_amplitude_az;
total_sac_el = total_sac + current_saccade_amplitude_el;
end
SSS(iT,1) = total_sac_az; % response azimuth
SSS(iT,2) = saccades(iS,13); % target azimuth
SSS(iT,3) = total_sac_el; % response elevation
SSS(iT,4) = saccades(iS,14); % target elevation
end
end
SSS = SSS(SSS(:,1)~=0,:);
cfn = pb_newfig(cfn);
subplot(1,2,1)
hold on
h = plot(SSS(:,2),SSS(:,1),'o');
hr = pb_regplot(SSS(:,2),SSS(:,1),'data',false);
pb_dline
axis square
title('Azimuth')
xlabel('Target ($^{\circ}$)');
ylabel('Response ($^{\circ}$)');
xlim([-50 50]);
ylim([-50 50]);
subplot(1,2,2)
h = plot(SSS(:,4),SSS(:,3),'o');
hr = pb_regplot(SSS(:,4),SSS(:,3),'data',false);
pb_dline
axis square
title('Elevation')
xlabel('Target ($^{\circ}$)');
ylabel('Response ($^{\circ}$)');
xlim([-50 50]);
ylim([-50 50]);
pb_nicegraph;
%color
for iH = length(h)
h(iH).Color = col(iH,:);
hr(iH).Color = col(iH,:);
end
%%
%plot epoched Azimuth data together in 1 plot.
AzEye = Data.epoch.AzEyeEpoched(1:360);
AzGaze = Data.epoch.AzGazeEpoched(1:360);
AzChair = Data.epoch.AzChairEpoched(1:360);
AzHead = Data.epoch.AzHeadEpoched(1:360);
TargetAz = Data.stimuli.azimuth(1:1);
t = 1/120:1/120:3;
cfn = pb_newfig(cfn);
hold on
axis square
plot(t, AzEye);
plot(t, AzGaze);
plot(t, AzChair);
plot(t, AzHead);
plot(t(1), TargetAz,'o');
x = [0 0.23 0.23 0];
y = [-10 -10 50 50];
patch(x, y, 'red');
title('Example Epoched Saccade Azimuth');
legend('AzEye', 'AzGaze', 'AzChair', 'AzHead', 'TargetAz', 'ReactionTime');
xlabel('Time(s)');
ylabel('Response($^{\circ}$)');
pb_nicegraph;
%%
%plot epoched Elevation data together in 1 plot.(2nd trial epoch)
ElEye = Data.epoch.ElEyeEpoched(361:720);
ElGaze = Data.epoch.ElGazeEpoched(361:720);
ElChair = Data.epoch.ElChairEpoched(361:720);
ElHead = Data.epoch.ElHeadEpoched(361:720);
TargetEl = Data.stimuli.elevation(1:2);
t = 1/120:1/120:3;
cfn = pb_newfig(cfn);
hold on
axis square
plot(t, ElEye);
plot(t, ElGaze);
plot(t, ElChair);
plot(t, ElHead);
plot(t(1), TargetEl,'o');
x = [0 0.2 0.2 0];
y = [-5 -5 35 35];
patch(x, y, 'red');
title('Example Epoched Saccade Elevation');
legend('ElEye', 'ElGaze', 'ElChair', 'ElHead', 'TargetEl', 'ReactionTime');
xlabel('Time(s)');
ylabel('Response($^{\circ}$)');
pb_nicegraph;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment