This repository has been archived by the owner on Apr 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LFP_ocular_trials_fun.m
70 lines (54 loc) · 2.77 KB
/
LFP_ocular_trials_fun.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
function trl = LFP_ocular_trials_fun(cfg)
% This function define the trials of the experiment. It is used by the
% ft_definetrial FieldTrip function and must return an array of at least three
% columns and N lines, N being the number of trials. The columns are :
% C1 : Begin of trial (unit : sample),
% C2 : End of trial (idem),
% C3 : offset (idem).
%
% This function needs, in the structure cfg :
%
% trialtype : % 'event' or 'saccade' centered trials.
% cod ; next : trials are around the event "cod" followed by "next" or around the
% saccade in such context. A negative value (for "next", or "next" and "cod"),
% allow to not care of the event of the trials, but "cod" must be valid
% if trialtype = 'event'.
%
% trialdef.presac ; trialdef.postsac : Time window in which to search
% for saccades around the event.
% trialdef.prestim ; trialdef.poststim : Time window of a trial around
% an event/saccade.
% saccadobserved : For event-centered trials, 'yes' keeps only the trials
% in which a saccade is observed, 'no' removes them and
% 'all' keep all the trials.
% isolatesaccades ; gauchesaccade ; droitesaccade : Get rid of the saccades
% having a neighboor saccade beginning in
% the window [gauchesaccade ; droitesaccade],
% if isolatesaccades = 'yes'. Else,
% isolatesaccades = 'no'.
%
% fsample : sampling rate of the lfp data AND the eye data.
% event : structure containing timestamp and data (i.e. event cods) (vectors)
% eye : structure with data.eye_x, data.eye_Y (note the uppercase) and
% saccades_timeStamp, a two columns matrix with the beginning and end
% of each saccade (in (s)).
%
% Last edited : 23/08/2016
% Charles Gaydon
%% Get relevant informations of all the saccades :
% [beg_t,end_t,offset,time, time_fin] in (s)
trl_ocular = SUB_simple_ocular_trials(cfg);
%% Get cods and timestamp of event of all the full task cycles exept the
% 10 first cycles which are removed : [event timestamp] in (s)
trl_event = SUB_event_transform(cfg,10);
%% Define the trials around saccade or event
if strcmp(cfg.trialtype,'event')
trl = SUB_cod_centered_trials(cfg,trl_ocular,trl_event);
elseif strcmp(cfg.trialtype,'saccade')
trl = SUB_ocular_centered_trials(cfg,trl_ocular,trl_event);
end
%% Visualisation of gaze (heatmap and xy plot) for the whole trials
SUB_ocular_analysis(cfg, trl,trl_ocular)
%% output : transform in the good unit, which is "sample".
trl = fix(trl(:,1:3).*cfg.fsample);
end