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
Jesse Heckman
pbtoolbox
Commits
ef4069ac
Commit
ef4069ac
authored
Sep 17, 2018
by
Jesse Heckman
Browse files
automated sphere analyses prep & vPrime update
parent
e93c0f44
Changes
8
Hide whitespace changes
Inline
Side-by-side
setups/spherePrime/pb_prepSac.m
0 → 100644
View file @
ef4069ac
function
pb_prepSac
()
% PB_PREPSAC()
%
% PB_PREPSAC() ...
%
% See also ...
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
cdir
=
'/Users/jjheckman/Documents/Data/PhD/Setups/Sphere/introduction/'
;
[
fn
,
path
]
=
pb_getfile
(
'dir'
,
cdir
,
'ext'
,
'*.*'
,
'title'
,
'Select an experimentfile'
);
[
ext
,
~
]
=
pb_fext
(
fn
);
cd
(
path
);
%% Get variables
experimenter
=
pb_delreadstr
(
fn
,
'delimiter'
,
'-'
,
'n'
,
1
);
participant
=
pb_delreadstr
(
fn
,
'delimiter'
,
'-'
,
'n'
,
2
);
year
=
pb_delreadstr
(
fn
,
'delimiter'
,
'-'
,
'n'
,
3
);
month
=
pb_delreadstr
(
fn
,
'delimiter'
,
'-'
,
'n'
,
4
);
day
=
pb_delreadstr
(
fn
,
'delimiter'
,
'-'
,
'n'
,
5
);
prefix
=
[
experimenter
'-'
participant
'-'
year
'-'
month
'-'
day
'-'
];
%%
n
=
pb_spheretrial2complete
();
for
iBlock
=
1
:
n
f_tmp
=
[
prefix
num2str
(
iBlock
-
1
,
'%04d'
)
ext
];
disp
(
f_tmp
)
sphere2hoopdat
(
f_tmp
);
sphere2hoopcsv
(
f_tmp
);
end
pa_calibrate
();
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
setups/spherePrime/pb_spheretrial2complete.m
0 → 100644
View file @
ef4069ac
function
nblocks
=
pb_spheretrial2complete
(
dname
)
% SPHERETRIAL2COMPLETE
%
% Combine the SPHERE trial files to one file
%
% See also SPHEREMAT2HOOPCSV, SPHEREMAT2HOOPDAT
%% Initialization
if
nargin
<
1
% fname = [];
%dir;
d
=
what
;
dname
=
d
.
path
;
end
cd
(
dname
);
d
=
dir
(
'*.sphere'
);
%% find unique blocks
f
=
char
(
d
.
name
);
f
=
f
(:,
1
:
end
-
12
);
ublocks
=
unique
(
f
,
'rows'
);
%% Load date per block
nblocks
=
size
(
ublocks
,
1
);
for
blockIdx
=
1
:
nblocks
fname
=
ublocks
(
blockIdx
,:);
d
=
dir
([
fname
'*.sphere'
]);
D
=
[];
T
=
[];
for
fIdx
=
1
:
numel
(
d
)
%disp(['Loading ' d(fIdx).name]);
load
(
d
(
fIdx
)
.
name
,
'-mat'
);
D
=
[
D
data
];
%#ok<AGROW>
if
exist
(
'dur'
,
'var'
)
trialsingle
.
duration
=
dur
;
end
T
=
[
T
trialsingle
];
%#ok<AGROW>
end
data
=
D
;
trial
=
T
;
%#ok<NASGU>
fname
=
fcheckext
(
fname
,
'sphere'
);
fname
=
fullfile
(
dname
,
fname
);
save
(
fname
,
'data'
,
'trial'
,
'cfg'
);
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
setups/vestibular chair/vPrime/pb_vPrimeGUI.fig
View file @
ef4069ac
No preview for this file type
setups/vestibular chair/vPrime/pb_vPrimeGUI.m
View file @
ef4069ac
...
...
@@ -22,7 +22,7 @@ function varargout = pb_vPrimeGUI(varargin)
% Edit the above text to modify the response to help pb_vPrimeGUI
% Last Modified by GUIDE v2.5 1
0
-Sep-2018 1
1:28:27
% Last Modified by GUIDE v2.5 1
7
-Sep-2018 1
2:27:46
% Begin initialization code - DO NOT EDIT
gui_Singleton
=
1
;
...
...
@@ -58,9 +58,9 @@ function pb_vPrimeGUI_OpeningFcn(hObject, eventdata, handles, varargin)
% Update handles structure
guidata
(
hObject
,
handles
);
set
(
handles
.
editLoad
,
'string'
,
cd
);
if
isunix
;
cd
(
'/Users/jjheckman/Documents/Data'
);
end
cd
(
datapath
);
set
(
handles
.
editLoad
,
'string'
,
cd
);
% UIWAIT makes pb_vPrimeGUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
...
...
@@ -87,6 +87,15 @@ function popExperimenter_Callback(hObject, eventdata, handles)
% Hints: contents = cellstr(get(hObject,'String')) returns popExperimenter contents as cell array
% contents{get(hObject,'Value')} returns selected item from popExperimenter
path
=
get
(
handles
.
editLoad
,
'string'
);
if
isempty
(
pb_fext
(
path
))
path
=
datapath
;
contents
=
get
(
handles
.
popExperimenter
,
'string'
);
user
=
contents
{
get
(
handles
.
popExperimenter
,
'Value'
)};
newpath
=
datapath
([
path
filesep
user
]);
set
(
handles
.
editLoad
,
'string'
,
newpath
);
end
end
% --- Executes during object creation, after setting all properties.
...
...
@@ -145,8 +154,12 @@ function buttonRun_Callback(hObject, eventdata, handles)
Exp
.
expfile
=
get
(
handles
.
editLoad
,
'string'
);
Exp
.
recording
=
get
(
handles
.
editRec
,
'string'
);
disp
([
'Experimenter: '
Exp
.
experimenter
newline
'Expfile: '
Exp
.
expfile
newline
'Subject ID: '
Exp
.
SID
newline
'Recording: '
Exp
.
recording
newline
]);
% Sets parameters & run exp
Exp
=
mkDat
(
Exp
,
handles
);
disp
([
'Experimenter: '
Exp
.
experimenter
newline
...
'Expfile: '
Exp
.
expfile
newline
...
'Subject ID: '
Exp
.
SID
newline
...
'Recording: '
Exp
.
recording
newline
]);
pb_vRunExp
(
Exp
,
handles
);
end
end
...
...
@@ -166,9 +179,12 @@ function buttonLoad_Callback(hObject, eventdata, handles)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
editTxt
=
get
(
handles
.
editLoad
,
'string'
);
[
ext
,
~
]
=
pb_fext
(
editTxt
);
if
isempty
(
ext
);
cdir
=
editTxt
;
else
;
fol
=
dir
(
editTxt
);
cdir
=
fol
.
folder
;
end
path
=
get
(
handles
.
editLoad
,
'string'
);
path
=
datapath
(
path
);
set
(
handles
.
editLoad
,
'string'
,
path
);
[
ext
,
~
]
=
pb_fext
(
path
);
if
isempty
(
ext
);
cdir
=
path
;
else
;
fol
=
dir
(
path
);
cdir
=
fol
.
folder
;
end
[
fn
,
path
]
=
pb_getfile
(
'dir'
,
cdir
,
'ext'
,
'*.exp'
,
'title'
,
'Load exp-file..'
);
if
fn
~=
0
...
...
@@ -223,3 +239,41 @@ function editRec_CreateFcn(hObject, eventdata, handles)
set
(
hObject
,
'BackgroundColor'
,
'white'
);
end
end
function
exp
=
mkDat
(
exp
,
handles
)
% Creates directory and sets parameters for data storage
datname
=
[
exp
.
experimenter
'-'
exp
.
SID
'-'
datestr
(
now
,
'yy-mm-dd'
)];
%% <-- SET PATH FOR WINDOWS DATADIR
path
=
[
datapath
filesep
exp
.
experimenter
filesep
'Recordings'
filesep
datname
];
if
~
exist
(
path
,
'dir'
);
mkdir
(
path
);
cd
(
path
);
mkdir
(
'trial'
);
end
path
=
[
path
filesep
'trial'
];
exp
.
dir
=
path
;
cd
(
path
);
fname
=
[
datname
'-'
exp
.
recording
'-0001.vc'
];
while
exist
(
fname
,
'file'
)
% Check for existing recordings
quest
=
'Recording already exists. How to proceed?'
;
answer
=
questdlg
(
quest
,
'Choices'
,
'Overwrite'
,
'Increment'
,
'Stop'
,
'Stop'
);
switch
answer
case
'Overwrite'
break
;
case
'Increment'
exp
.
recording
=
num2str
(
str2double
(
exp
.
recording
)
+
1
,
'%04d'
);
set
(
handles
.
editRec
,
'string'
,
exp
.
recording
);
case
'Stop'
error
(
'Run stopped.'
);
end
fname
=
[
datname
'-'
num2str
(
exp
.
recording
,
'%04d'
)
'-0001.vc'
];
end
end
function
path
=
datapath
(
path
)
if
nargin
==
0
;
path
=
[];
end
if
isempty
(
path
)
||
~
exist
(
path
)
if
isunix
path
=
'/Users/jjheckman/Documents/Data/PhD/Experiment/VC'
;
else
path
=
'C:/VC/DATA'
;
end
end
end
setups/vestibular chair/vPrime/trial/experiment/pb_vClearTrial.m
0 → 100644
View file @
ef4069ac
function
pb_vClearTrial
(
cnt
,
blck
,
trl
)
% PB_VCLEARTRIAL()
%
% PB_VCLEARTRIAL() ...
%
% See also ...
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
disp
([
newline
'<strong>New Trial started...</strong> '
...
newline
' Trial: '
num2str
(
cnt
)
' (B'
num2str
(
blck
)
'T'
num2str
(
trl
)
')'
]);
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
setups/vestibular chair/vPrime/trial/experiment/pb_vRecordData.m
0 → 100644
View file @
ef4069ac
function
pb_vRecordData
(
exp
,
trial
)
% PB_VRECORDDATA()
%
% PB_VRECORDDATA() ...
%
% See also ...
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
cd
(
exp
.
dir
)
day
=
datestr
(
now
,
'yy-mm-dd'
);
trial
=
num2str
(
trial
,
'%04d'
);
fname
=
[
exp
.
experimenter
'-'
...
exp
.
SID
'-'
...
day
'-'
...
exp
.
recording
'-'
...
trial
'.vc'
];
fid
=
fopen
(
fname
,
'wt'
);
fprintf
(
fid
,
'test\n'
);
fclose
(
fid
);
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
setups/vestibular chair/vPrime/trial/experiment/pb_vRunVC.m
View file @
ef4069ac
...
...
@@ -7,9 +7,6 @@ function Dat = pb_vRunVC(signal)
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
dur
=
10
;
vSignal
=
pb_vCreateSignal
(
1
,
signal
(
1
)
.
duration
,
10
,
1
,
signal
(
1
)
.
type
);
hSignal
=
pb_vCreateSignal
(
1
,
signal
(
2
)
.
duration
,
10
,
1
,
signal
(
2
)
.
type
);
...
...
@@ -17,7 +14,6 @@ function Dat = pb_vRunVC(signal)
Dat
.
v
.
t
=
(
0
:
1
:
length
(
Dat
.
v
.
x
)
-
1
)/
10
;
Dat
.
h
.
x
=
hSignal
.
x
.*
signal
(
2
)
.
amplitude
;
Dat
.
h
.
t
=
(
0
:
1
:
length
(
Dat
.
h
.
x
)
-
1
)/
10
;
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
...
...
setups/vestibular chair/vPrime/trial/pb_vRunExp.m
View file @
ef4069ac
...
...
@@ -20,11 +20,15 @@ function pb_vRunExp(expinfo,h)
tDat
(
nTotTrials
)
=
struct
;
set
(
h
.
buttonClose
,
'Enable'
,
'off'
)
% avoid closing GUI during executing run function
set
(
h
.
buttonRun
,
'Enable'
,
'off'
);
set
(
h
.
buttonLoad
,
'Enable'
,
'off'
)
set
(
h
.
buttonRun
,
'Enable'
,
'off'
)
set
(
h
.
buttonLoad
,
'Enable'
,
'off'
)
h
.
signals
;
cla
;
%% BODY
% Iterate experiment
pause
(
2
);
for
iBlock
=
1
:
nblocks
% Runs blocks of trials with a vestibular condition
nTrials
=
length
(
block
(
iBlock
)
.
trial
);
...
...
@@ -38,7 +42,10 @@ function pb_vRunExp(expinfo,h)
bDat
(
iBlock
)
.
signal
=
pb_vRunVC
(
signal
);
% Plot signals
h
.
signals
;
cla
;
hold
on
;
col
=
pb_selectcolor
(
2
,
2
);
h
.
signals
;
cla
;
hold
on
;
h
.
signals
.
YLim
=
[
-
50
50
];
col
=
pb_selectcolor
(
2
,
2
);
plot
(
bDat
(
iBlock
)
.
signal
.
v
.
t
,
bDat
(
iBlock
)
.
signal
.
v
.
x
,
'Color'
,
col
(
1
,:));
plot
(
bDat
(
iBlock
)
.
signal
.
h
.
t
,
bDat
(
iBlock
)
.
signal
.
h
.
x
,
'Color'
,
col
(
2
,:));
...
...
@@ -47,17 +54,19 @@ function pb_vRunExp(expinfo,h)
cnt
=
cnt
+
1
;
updateTrial
(
h
,
iTrial
,
cnt
,
nTotTrials
,
tDat
);
%
pb_vClearTrial();
%
pb_vRecordData();
pb_vClearTrial
(
cnt
,
iBlock
,
iTrial
);
pb_vRecordData
(
expinfo
,
cnt
);
%pb_vRunTrial(experiment(iTrial));
%pb_vFeedbackGUI();
pause
(
.
1
);
pause
(
1
);
end
pause
(
2
)
end
%% CHECK OUT
% store data
disp
([
newline
newline
'Experiment finished!'
])
set
(
h
.
buttonClose
,
'Enable'
,
'on'
);
set
(
h
.
buttonRun
,
'Enable'
,
'on'
);
set
(
h
.
buttonLoad
,
'Enable'
,
'on'
);
...
...
@@ -69,7 +78,7 @@ function updateBlock(h, iBlock, signal)
bn
=
pb_sentenceCase
(
num2str
(
iBlock
,
'%03d'
));
% count block
set
(
h
.
Bn
,
'string'
,
bn
);
vs
=
[
'V = '
pb_sentenceCase
(
signal
(
1
)
.
type
)
...
% VC stim
vs
=
[
'V = '
pb_sentenceCase
(
signal
(
1
)
.
type
)
...
% VC stim
', H = '
pb_sentenceCase
(
signal
(
2
)
.
type
)];
set
(
h
.
Vs
,
'string'
,
vs
);
end
...
...
@@ -77,9 +86,9 @@ end
function
updateTrial
(
h
,
iTrial
,
cnt
,
nTotTrials
,
Dat
)
% Updates the trial information to the GUI
h
.
figure1
.
Name
=
[
'vPrime - '
num2str
(
cnt
)
'/'
num2str
(
nTotTrials
)
' Trials'
];
% counting title
h
.
figure1
.
Name
=
[
'vPrime - '
num2str
(
cnt
)
'/'
num2str
(
nTotTrials
)
' Trials'
];
% counting title
tn
=
num2str
(
iTrial
,
'%03d'
);
% blocktrial
tn
=
num2str
(
iTrial
,
'%03d'
);
% blocktrial
set
(
h
.
Tn
,
'string'
,
tn
)
end
...
...
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