-
Notifications
You must be signed in to change notification settings - Fork 0
/
compute_gazedata.m
140 lines (102 loc) · 4.05 KB
/
compute_gazedata.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
%function compute_gazedata
%function compute_gazedata
% Compute trial-by-trial gaze data recorded with a laminar probe (LMA)
%
% Corentin Massot
% Cognition and Sensorimotor Integration Lab, Neeraj J. Gandhi
% University of Pittsburgh
% created 08/09/2017 last modified 08/09/2017
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%set paths
[root_path data_path save_path]=set_paths;
%screen size
scrsz = get(groot,'ScreenSize');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%parameters
%print figures and save data
savefigs=0;
figtype='epsc2';%'png';%'epsc2';
%alignement
%alignlist={'no' 'targ' 'go' 'sacc'};
alignlist={'sacc'};
%window of analysis
%wind=[];%all
%wind=[-100 400];%targ align
wind=[-200 200];%sacc align
%sigma FR
sigma_FR=6;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%get data
datalist=load_data_gandhilab(data_path);
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%analyzing data
dlist=get_dlist;
data=[];
info=[];
for d=dlist(10:end)
%get data and info
clear('data');
info.datafile=datalist{d};
load ([data_path info.datafile]);
display(info.datafile)
%getting channel mapping and discard selected bad channels
[info.chmap info.nchannels info.depths]=get_chmap(data(1).info.electrode{2},[]);
%getting trial type
info.trialtype=data(1).sequence(1);
%getting list of targets
targslist=data(1).offline.targslist;
%targets index
targs_ind=get_targsindex(targslist,info);
%target tuning (after compute_tuning)
info.targ_tuning=data(1).offline.targ_tuning;
%select trials
seltrials=get_seltrials(data,'rpt');
%loop across all alignements
for al=1:numel(alignlist)
info.align=alignlist{al};
%get behavioral data with specific alignement independently of target
[gazepos,events]=get_alldatagaze_align_notarg(data,seltrials,info);
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%loop on trials
info.ntrials=numel(seltrials)
for t=seltrials,
figtrials=figure('Position',[1 100 scrsz(3)-100 scrsz(4)-200]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%display all targets
hdlfig=subplot(1,2,1);hold on;
display_alltargets(targslist,info,hdlfig);
%%
%%%%%%%%%%%%%%%%%%
%gaze data
gazepos_t=gazepos{t};
events_t=events{t};
event_align=get_eventalign(events_t,info.align);
if ~isempty(event_align)
hdlfig1=subplot(1,2,1);hold on;
hdlfig2=subplot(1,2,2);hold on;
%%
%%%%%%%%%%%%%%%%%%
%get new gaze position events
display_gazepos=0;
events_t_new=get_gazepos_events(gazepos_t,events_t,event_align,wind,info,display_gazepos,hdlfig1,hdlfig2);
%plot gaze data
%plot_gazedata(gazepos_t,events_t,event_align,wind,info,hdlfig1,'',hdlfig2,'XY Eye Traces');
%subplot(1,2,1);
%ax=axis;
%axis([ax(1) ax(2) -4 4]);
end
%update data
%WARNING: error: should use lut_trials_targ to ensure right trial number
display('ERROR in SAVING NOT SAVED!')
%display('NOT SAVED!')
%velocity peak
%eval(['data(t).offline.gazepos_events.peak=events_t_new.peak;']);
%pause
close(figtrials)
end
end
%save updated data
update_data(1,0,0,data,data_path,info.datafile,[],[]);
end