Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marc Posthuma
Bachelor Stage
Commits
7c9e5aaf
Commit
7c9e5aaf
authored
May 11, 2021
by
mposthuma
Browse files
Merge branch 'master' of
https://gitlab.science.ru.nl/mposthuma/bachelor-stage
parents
f0434ab2
0b53a423
Changes
4
Hide whitespace changes
Inline
Side-by-side
Target_response_plot_test_experiment.m
0 → 100644
View file @
7c9e5aaf
%% Initialize
% Clean everythimg
cfn
=
pb_clean
(
'cd'
,
'U:\Documents\BIOLOGIE\STAGE\MATLAB\Data\test experiment'
);
% clean everything, and change directory
% load epoched data
l
=
dir
(
'epoched_data_*.mat'
);
for
iL
=
1
:
length
(
l
)
load
(
l
(
iL
)
.
name
);
end
%pa_sac2mat to save sac to mat file
% load saccades
l
=
dir
([
'sacdet'
filesep
'sacdet*.mat'
]);
load
([
'sacdet'
filesep
l
(
1
)
.
name
]);
%% Extract data
% 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
);
% RT
SS
(
iS
,
6
)
=
1
/
120
*
1000
*
(
Sac
(
iS
,
4
)
-
Sac
(
iS
,
3
));
% Duration
SS
(
iS
,
7
)
=
azimuth
(
sacOn_idx
);
% Azimuth onset position
SS
(
iS
,
8
)
=
elevation
(
sacOn_idx
);
% Elevation onset position
SS
(
iS
,
9
)
=
azimuth
(
sacOff_idx
);
% Azimuth offset position
SS
(
iS
,
10
)
=
elevation
(
sacOff_idx
);
% Elevation offset position
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
))));
% Max velocity
SS
(
iS
,
16
)
=
sqrt
(
SS
(
iS
,
11
)
^
2
+
SS
(
iS
,
12
)
^
2
);
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 selections
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
);
resp
=
nSS
(:,
10
+
iS
);
% graph
subplot
(
1
,
2
,
iS
);
hold
on
;
axis
square
;
title
(
c_title
{
iS
});
h
(
iS
)
=
plot
(
target
,
resp
,
'o'
);
hr
(
iS
)
=
pb_regplot
(
target
,
resp
,
'data'
,
false
);
xlabel
(
'Target ($^{\circ}$)'
);
ylabel
(
'Response ($^{\circ}$)'
)
xlim
([
-
50
50
]);
ylim
([
-
50
50
]);
pb_dline
;
end
pb_nicegraph
;
% color
for
iH
=
1
:
length
(
h
)
h
(
iH
)
.
Color
=
col
(
iH
,:);
hr
(
iH
)
.
Color
=
col
(
iH
,:);
end
%% Main Sequence plots
% amplitude = length of saccade = pythagoras of azimuth + elevation
cfn
=
pb_newfig
(
cfn
);
sgtitle
(
'Main Sequence'
)
iS
1
:
2
velocity
=
SS
(:,
15
);
amplitude
=
abs
(
SS
(:,
16
));
subplot
(
1
,
2
,
iS
);
hold
on
;
axis
square
h
(
iS
)
=
plot
(
amplitude
,
velocity
,
'o'
);
xlabel
(
'Amplitude'
);
ylabel
(
'Peak velocity'
);
startup.m
View file @
7c9e5aaf
addpath(genpath('C:\Users\marc_\OneDrive\Documents\Studie\STAGE\MATLAB Code'));
init_biofysica
pb_setlatex
test_experiment.m
View file @
7c9e5aaf
cfn
=
pb_clean
(
'cd'
,
'C:\Users\marc_\OneDrive\Documents\Studie\STAGE\MATLAB Code\Data\Recordings\test experiment'
);
%% Raw data conversion + Save preprocessed Data
cfn
=
pb_clean
(
'cd'
,
'U:\Documents\BIOLOGIE\STAGE\MATLAB\Data\test experiment'
);
l
=
dir
(
'converted_data*.mat'
);
if
isempty
(
l
)
...
...
@@ -83,7 +84,7 @@ for i = 1:3:10
i
end
%%
%%
Epoch data
fs
=
120
;
duration
=
3
;
...
...
@@ -158,55 +159,3 @@ end
fn
=
strrep
(
'preprocessed_data_JJH-0001-21-04-15-0001.mat'
,
'preprocessed'
,
'epoched'
);
save
(
fn
,
'Data'
);
%%
if
~
exist
(
'sacdet'
,
'dir'
)
mkdir
(
'sacdet'
)
end
cfn
=
pb_clean
(
'cd'
,
'C:\Users\marc_\OneDrive\Documents\Studie\STAGE\MATLAB Code\Data\Recordings\test experiment'
);
path
=
pb_getdir
(
'cdir'
,
cd
);
cd
(
path
)
% Load data
l
=
dir
(
'epoched*.mat'
);
if
isempty
(
l
);
return
;
end
fn
=
l
(
1
)
.
name
;
load
(
fn
);
% Switch to sacdet folder
path
=
[
path
filesep
'sacdet'
];
cd
(
path
)
%% Run sacdet over epoched data
% Read converted data file, preprocess all blocks, and store data
l
=
dir
(
'*.sac'
);
if
~
isempty
(
l
);
return
;
end
%% Make hv & csv and run sacdet
Dlen
=
length
(
Data
.
epoch
);
fs
=
120
;
duration
=
3
;
samples
=
duration
*
fs
;
for
iB
=
1
:
Dlen
% Saving calibrated data
fname
=
fcheckext
([
'sacdet_'
fn
(
14
:
end
-
5
)
'_block_'
num2str
(
iB
)
'_azel'
]
,
'.hv'
);
fid
=
fopen
([
path
filesep
fname
],
'w'
,
'l'
);
AZEL
=
[
Data
.
epoch
(
iB
)
.
AzGazeEpoched
;
Data
.
epoch
(
iB
)
.
ElGazeEpoched
];
fwrite
(
fid
,
AZEL
,
'float'
);
fclose
(
fid
);
fn_csv
=
[
path
filesep
fname
];
VC2csv
(
fn_csv
,
fs
,
samples
,
1
:
length
(
Data
.
epoch
(
iB
)
.
AzGazeEpoched
)/
samples
);
if
~
isfile
(
fn_csv
(
1
:
end
-
3
))
==
1
pa_sacdet
;
pause
;
end
end
\ No newline at end of file
test_experiment_sacdet.m
0 → 100644
View file @
7c9e5aaf
%% pb_vSacDet.m
cfn
=
pb_clean
(
'cd'
,
'U:\Documents\BIOLOGIE\STAGE\MATLAB\Data\test experiment'
);
path
=
pb_getdir
(
'cdir'
,
cd
);
cd
(
path
)
l
=
dir
(
'epoched*.mat'
);
if
isempty
(
1
);
return
;
end
fn
=
l
(
1
)
.
name
;
n
load
(
fn
);
if
~
exist
(
'sacdet'
,
'dir'
)
mkdir
(
'sacdet'
)
end
path
=
[
path
filesep
'sacdet'
];
cd
(
path
)
%%
Dlen
=
length
(
Data
.
epoch
);
fs
=
120
;
duration
=
3
;
samples
=
duration
*
fs
;
for
iB
=
1
:
Dlen
fname
=
fcheckext
([
'sacdet_'
fn
(
14
:
end
-
5
)
'_block_'
num2str
(
iB
)
'_azel'
]
,
'.hv'
);
fid
=
fopen
([
path
filesep
fname
],
'w'
,
'l'
);
AZEL
=
[
Data
.
epoch
(
iB
)
.
AzGazeEpoched
;
Data
.
epoch
(
iB
)
.
ElGazeEpoched
];
fwrite
(
fid
,
AZEL
,
'float'
);
fclose
(
fid
);
fn_csv
=
[
path
filesep
fname
];
VC2csv
(
fn_csv
,
fs
,
samples
,
1
:
length
(
Data
.
epoch
(
iB
)
.
AzGazeEpoched
)/
samples
);
if
~
isfile
(
fn_csv
(
1
:
end
-
3
))
==
1
pa_sacdet
;
pause
;
end
end
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment