Skip to content
GitLab
Menu
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
ed02ecab
Commit
ed02ecab
authored
May 28, 2021
by
mposthuma
Browse files
Still doesnt save exp file, experimental conditions are also not completely correct yet...
parent
b108bc2a
Changes
1
Show whitespace changes
Inline
Side-by-side
experiment_file_main.m
View file @
ed02ecab
function
pb_vGenExp_VisFlash
(
varargin
)
%% Initialization
%% Initialization
% Clear, empty, default imputs
% Clear, empty
pb_clean
;
pb_clean
;
disp
(
'>> GENERATING VC EXPERIMENT <<'
);
disp
(
'>> GENERATING VC EXPERIMENT <<'
);
disp
(
' ...'
)
disp
(
' ...'
)
cfn
=
0
;
cfn
=
0
;
% Get Filename
st
=
dbstack
;
sname
=
st
.
name
;
ind
=
strfind
(
sname
,
'_'
);
if
isempty
(
ind
);
ind
=
0
;
end
fn
=
sname
(
max
(
ind
)
+
1
:
end
);
showexp
=
pb_keyval
(
'showexp'
,
varargin
,
true
);
expfile
=
pb_keyval
(
'fname'
,
varargin
,[
fn
'.exp'
]);
datdir
=
pb_keyval
(
'datdir'
,
varargin
,
'DEFAULT'
);
cdir
=
pb_keyval
(
'cdir'
,
varargin
,
userpath
);
cd
(
cdir
);
%% Desired azimuth and elevation
% Define hemisphere
%% Desired azimuth and elevation
%Select target ranges
% Define hemisphere
maxAbsAz
=
35
;
maxAbsEl
=
30
;
% Select target ranges
maxAbsAz
=
45
;
maxAbsEl
=
35
;
% Possible targets
% Possible targets
dAz
=
-
4
5
:
05
:
4
5
;
dAz
=
-
3
5
:
05
:
3
5
;
dEl
=
-
3
5
:
10
:
3
5
;
dEl
=
-
3
0
:
10
:
3
0
;
[
dAz
,
dEl
]
=
meshgrid
(
dAz
,
dEl
);
[
dAz
,
dEl
]
=
meshgrid
(
dAz
,
dEl
);
dAz
=
dAz
(:);
dAz
=
dAz
(:);
dEl
=
dEl
(:);
dEl
=
dEl
(:);
...
@@ -43,73 +30,44 @@
...
@@ -43,73 +30,44 @@
dEl
=
dEl
(
sel
);
dEl
=
dEl
(
sel
);
nloc
=
numel
(
dAz
);
nloc
=
numel
(
dAz
);
%% Select target positions used in experiment
%% Select target positions used in experiment
% Get targets.
% Get targets.
targetl
=
length
(
dAz
);
targetl
=
length
(
dAz
);
targetInd
=
randperm
(
targetl
);
targetInd
=
randperm
(
targetl
);
dAz
=
dAz
(
sort
(
targetInd
(
1
:
targetl
)));
dAz
=
dAz
(
sort
(
targetInd
(
1
:
targetl
)));
dEl
=
dEl
(
sort
(
targetInd
(
1
:
targetl
)));
dEl
=
dEl
(
sort
(
targetInd
(
1
:
targetl
)));
%% Actual azimuth and elevation
%% Stimulus Condition
% The actual speaker positions are not perfectly aligned with 5 deg
cfg
=
pb_vLookup
;
% sphere positions
channel
=
cfg
.
interpolant
(
dAz
',dEl'
);
X
=
cfg
.
lookup
(
channel
+
1
,
4
);
Y
=
cfg
.
lookup
(
channel
+
1
,
5
);
%% Graphics
if
showexp
cfn
=
pb_newfig
(
cfn
);
hold
on
;
plot
(
dAz
,
dEl
,
'o'
)
hold
on
plot
(
X
,
Y
,
'x'
)
axis
([
-
60
60
-
60
60
]);
axis
square
set
(
gca
,
'TickDir'
,
'out'
);
xlabel
(
'Azimuth (deg)'
);
ylabel
(
'Elevation (deg)'
);
pb_nicegraph
;
end
%% Stimulus Condition
% FIXATION LED
% FIXATION LED
fixled
.
bool
=
false
;
%
do you want a
fixation light
?
fixled
.
bool
=
false
;
%
no
fixation light
fixled
.
x
=
0
;
fixled
.
x
=
0
;
fixled
.
y
=
0
;
fixled
.
y
=
0
;
fixled
.
dur
=
1000
;
fixled
.
dur
=
1000
;
% 1, 2, 4, 16 ms (?)
fixled
.
pause
=
1000
;
fixled
.
pause
=
1000
;
modality
=
2
;
% 2=VISUAL
modality
=
2
;
% 2=VISUAL
int
=
[
50
];
% w/ [i1, i2, i3...]
int
=
[
20
25
30
35
40
45
50
];
% w/ [i1, i2, i3...]
dur
=
2.
^
(
0
:
7
)
*
0.5
;
% stim duration in ms 2.^(0:7)*.5
dur
=
16
;
% stim duration in ms 2.^(0:7)*.5
col
=
[
1
];
% w/ [R,G]
col
=
[
1
];
% w/ [R,G]
[
X
,
~
,
~
]
=
ndgrid
(
X
,
0
,
col
,
int
,
dur
);
[
Y
,
~
,
col
,
int
,
dur
]
=
ndgrid
(
Y
,
0
,
col
,
int
,
dur
);
X
=
X
(:);
Y
=
Y
(:);
int
=
int
(:);
int
=
int
(:);
col
=
col
(:);
col
=
col
(:);
dur
=
dur
(:);
dur
=
dur
(:);
%% Number and size
%% Number and size
Sz
=
size
(
X
);
N
=
Sz
(
1
);
% number of trials
maxtrialdur
=
fixled
.
bool
*
(
fixled
.
dur
+
fixled
.
pause
)
+
max
(
dur
);
N
=
48
;
% number of trials = 48 per block
maxtrialdur
=
max
(
dur
);
maxtrialdur
=
ceil
(
maxtrialdur
/
500
)/
2
;
maxtrialdur
=
ceil
(
maxtrialdur
/
500
)/
2
;
%% Vestibular blocks
%% Vestibular blocks
blockdur
=
15
0
;
% block duration in seconds
blockdur
=
20
0
;
% block duration in seconds
bdureff
=
blockdur
-
(
8
*
pi
);
% start & stop
bdureff
=
blockdur
-
(
8
*
pi
);
% start & stop
trialsinblock
=
bdureff
/
(
maxtrialdur
+
1
);
% trials per block
trialsinblock
=
bdureff
/
(
maxtrialdur
+
1
);
% trials per block
totaltime
=
ceil
(
N
*
(
maxtrialdur
+
1
))
+
8
*
pi
;
totaltime
=
ceil
(
N
*
(
maxtrialdur
+
1
))
+
8
*
pi
;
...
@@ -118,31 +76,14 @@
...
@@ -118,31 +76,14 @@
nblockreps
=
N
/
trialsinblock
;
nblockreps
=
N
/
trialsinblock
;
block
.
Horizontal
=
struct
(
'Amplitude'
,
0
,
'Signal'
,
1
,
'Duration'
,
blockdur
,
'Frequency'
,
.
16
);
block
.
Horizontal
=
struct
(
'Amplitude'
,
0
,
'Signal'
,
1
,
'Duration'
,
blockdur
,
'Frequency'
,
.
16
);
block
.
Vertical
=
struct
(
'Amplitude'
,
70
,
'Signal'
,
2
,
'Duration'
,
blockdur
,
'Frequency'
,
.
16
);
block
.
Vertical
=
struct
(
'Amplitude'
,
70
,
'Signal'
,
2
,
'Duration'
,
blockdur
,
'Frequency'
,
1
/(
2
*
pi
));
writeexp
(
expfile
,
datdir
,
X
,
Y
,
int
,
dur
,
block
,
fixled
);
% see below, these are helper functions to write an exp-file line by line / stimulus by stimulus
%% Show the exp-file in Wordpad
% for PCs
if
showexp
if
ispc
dos
([
'"C:\Program Files\Windows NT\Accessories\wordpad.exe" '
expfile
' &'
]);
elseif
ismac
system
([
'open -a TextWrangler '
cd
filesep
expfile
]);
end
end
function
writeexp
(
expfile
,
datdir
,
theta
,
phi
,
int
,
dur
,
block
,
fixled
)
end
function
writeexp
(
expfile
,
datdir
,
theta
,
phi
,
int
,
dur
,
block
,
fixled
)
% Save known trial-configurations in exp-file
% Save known trial-configurations in exp-file
%
% WRITEEXP WRITEEXP(FNAME,DATDIR,THETA,PHI,ID,LEDON)
%
% WRITEEXP(FNAME,THETA,PHI,ID,LEDON)
%
% Write exp-file with file-name FNAME.
expfile
=
'Expfile'
;
expfile
=
fcheckext
(
expfile
,
'.exp'
);
% check whether the extension exp is included
expfile
=
fcheckext
(
expfile
,
'.exp'
);
% check whether the extension exp is included
fid
=
fopen
(
expfile
,
'wt+'
);
% this is the way to write date to a new file
fid
=
fopen
(
expfile
,
'wt+'
);
% this is the way to write date to a new file
...
@@ -203,4 +144,5 @@ function writeexp(expfile,datdir,theta,phi,int,dur,block,fixled)
...
@@ -203,4 +144,5 @@ function writeexp(expfile,datdir,theta,phi,int,dur,block,fixled)
trlIdx
=
trlIdx
+
1
;
trlIdx
=
trlIdx
+
1
;
end
end
fclose
(
fid
);
fclose
(
fid
);
end
end
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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