Skip to content

Commit 5cf643d

Browse files
committed
final fixes
1 parent e34f5db commit 5cf643d

File tree

5 files changed

+79
-66
lines changed

5 files changed

+79
-66
lines changed

initEnv.m

Lines changed: 53 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,86 @@
1-
%
1+
%
22
% 1 - Check if version requirements
3-
% are satisfied and the packages are
3+
% are satisfied and the packages are
44
% are installed/loaded:
5-
% Octave > 4
6-
% - image
7-
% - optim
8-
% - struct
9-
% - statistics
5+
% Octave > 4
6+
% - image
7+
% - optim
8+
% - struct
9+
% - statistics
1010
%
11-
% MATLAB > R2017a
11+
% MATLAB > R2017a
1212
%
1313
% 2 - Add project to the O/M path
1414

1515
function initEnv
16-
16+
1717
octaveVersion = '4.0.3';
1818
matlabVersion = '9.2.0';
1919

20-
if isOctave
20+
if isOctave
2121

22-
% Exit if min version is not satisfied
23-
if ~compare_versions(OCTAVE_VERSION,octaveVersion,'>=')
24-
error('Minimum required Octave version: %s', octaveVersion);
25-
end
22+
% Exit if min version is not satisfied
23+
if ~compare_versions(OCTAVE_VERSION, octaveVersion, '>=')
24+
error('Minimum required Octave version: %s', octaveVersion);
25+
end
2626

27-
installlist = {'statistics'};
28-
for ii=1:length(installlist)
29-
try
30-
% Try loading Octave packages
31-
disp(['loading ' installlist{ii}])
32-
pkg('load',installlist{ii})
33-
34-
catch
35-
errorcount = 1;
36-
while errorcount % Attempt twice in case installation fails
37-
try
38-
pkg('install','-forge',installlist{ii})
39-
pkg('load',installlist{ii})
40-
errorcount = 0;
41-
catch err
42-
errorcount = errorcount+1;
43-
if errorcount>2
44-
error(err.message)
27+
installlist = {'statistics'};
28+
for ii = 1:length(installlist)
29+
try
30+
% Try loading Octave packages
31+
disp(['loading ' installlist{ii}]);
32+
pkg('load', installlist{ii});
33+
34+
catch
35+
errorcount = 1;
36+
while errorcount % Attempt twice in case installation fails
37+
try
38+
pkg('install', '-forge', installlist{ii});
39+
pkg('load', installlist{ii});
40+
errorcount = 0;
41+
catch err
42+
errorcount = errorcount + 1;
43+
if errorcount > 2
44+
error(err.message);
45+
end
4546
end
4647
end
4748
end
4849
end
49-
end
50-
5150

51+
else % MATLAB ----------------------------
5252

53-
else % MATLAB ----------------------------
54-
55-
if verLessThan('matlab', matlabVersion)
56-
error('Sorry, minimum required version is R2017b. :(');
57-
end
53+
if verLessThan('matlab', matlabVersion)
54+
error('Sorry, minimum required version is R2017b. :(');
55+
end
5856

59-
end
57+
end
6058

61-
% If external dir is empty throw an exception
62-
% and ask user to update submodules.
63-
if numel(dir('lib')) <= 2 % Means that the external is empty
64-
error(['Git submodules are not cloned! \n' ...
65-
'try this in your terminal: \n ...'
66-
'git submodule update --recursive ']);
67-
else
68-
addDependencies();
69-
end
59+
% If external dir is empty throw an exception
60+
% and ask user to update submodules.
61+
if numel(dir('lib')) <= 2 % Means that the external is empty
62+
error(['Git submodules are not cloned! \n' ...
63+
'try this in your terminal: \n ...'
64+
'git submodule update --recursive ']);
65+
else
66+
addDependencies();
67+
end
7068

71-
disp('Correct matlab/octave verions and added to the path!');
69+
disp('Correct matlab/octave verions and added to the path!');
7270

7371
end
7472

7573
%%
7674
%% Return: true if the environment is Octave.
7775
%%
7876
function retval = isOctave
79-
persistent cacheval; % speeds up repeated calls
77+
persistent cacheval % speeds up repeated calls
8078

81-
if isempty (cacheval)
82-
cacheval = (exist ("OCTAVE_VERSION", "builtin") > 0);
83-
end
79+
if isempty (cacheval)
80+
cacheval = (exist ("OCTAVE_VERSION", "builtin") > 0);
81+
end
8482

85-
retval = cacheval;
83+
retval = cacheval;
8684
end
8785

8886
function addDependencies()

setParameters.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
cfg.testingDevice = 'pc';
2626
cfg.eyeTracker = false;
27+
cfg.initAudio = false;
2728

2829
[cfg, expParameters] = setMonitor(cfg, expParameters);
2930

@@ -86,7 +87,9 @@
8687

8788
function [cfg, expParameters] = setKeyboards(cfg, expParameters)
8889
cfg.keyboard.escapeKey = 'ESCAPE';
89-
expParameters.responseKey = {'space'};
90+
cfg.keyboard.responseKey = {'space'};
91+
cfg.keyboard.keyboard = [];
92+
cfg.keyboard.responseBox = [];
9093

9194
if strcmpi(cfg.testingDevice, 'mri')
9295
cfg.keyboard.keyboard = [];
@@ -101,6 +104,9 @@
101104

102105
expParameters.bids.MRI.RepetitionTime = 2;
103106

107+
expParameters.bids.MRI.Instructions = 'Detect the RED fixation cross';
108+
expParameters.bids.MRI.TaskDescription = [];
109+
104110
end
105111

106112
function [cfg, expParameters] = setMonitor(cfg, expParameters)

subfun/doDotMo.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@
117117
% NaN out-of-circle dots
118118
% We use Pythagore's theorem to figure out which dots are out of the
119119
% circle
120-
outCircle = sqrt(xy_pix(1, :).^2 + xy_pix(2, :).^2) + dotSizePix / 2 > (diamAperturePix / 2);
120+
outCircle = sqrt(xy_pix(1, :).^2 + xy_pix(2, :).^2) + ...
121+
dotSizePix / 2 > (diamAperturePix / 2);
121122
xy_pix(:, outCircle) = NaN;
122123

123124
%% PTB draws the dots stimulation

subfun/expDesign.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
function [expParameters] = expDesign(expParameters, displayFigs)
22
% Creates the sequence of blocks and the events in them
33
%
4-
% The conditions are consecutive static and motion blocks (Gives better results than randomised).
4+
% The conditions are consecutive static and motion blocks
5+
% Gives better results than randomised.
56
%
67
% It can be run as a stand alone without inputs to display a visual example of possible design.
78
%
@@ -63,7 +64,7 @@
6364
maxNumFixTargPerBlock = expParameters.maxNumFixationTargetPerBlock;
6465

6566
if mod(numEventsPerBlock, length(motionDirections)) ~= 0
66-
warning('the number of events per block is not a multiple of the number of motion/static diection');
67+
warning('Number of events/block not a multiple of number of motion/static direction');
6768
end
6869

6970
%% Adapt some variables according to input
@@ -151,7 +152,8 @@
151152
Ind = zeros(length(expParameters.designBlockNames), length(uniqueNames)) ;
152153

153154
for i = 1:length(uniqueNames)
154-
CondInd(:, i) = find(strcmp(expParameters.designBlockNames, uniqueNames{i})) ; %#ok<*AGROW>
155+
CondInd(:, i) = find( ...
156+
strcmp(expParameters.designBlockNames, uniqueNames{i})) ; %#ok<*AGROW>
155157
Ind(CondInd(:, i), i) = 1 ;
156158
end
157159

visualLocTanslational.m

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
[cfg, expParameters] = createFilename(cfg, expParameters);
2626

2727
disp(expParameters);
28+
disp(cfg);
2829

2930
% Prepare for fixation Cross
3031
cfg.xCoords = [-expParameters.fixCrossDimPix expParameters.fixCrossDimPix 0 0] + ...
@@ -58,15 +59,15 @@
5859
logFile = saveEventsFile('open', expParameters, logFile);
5960

6061
% Wait for space key to be pressed
61-
pressSpaceForme();
62+
pressSpaceForMe();
6263

6364
% prepare the KbQueue to collect responses
6465
getResponse('init', cfg.keyboard.responseBox, cfg);
6566
getResponse('start', cfg.keyboard.responseBox);
6667

6768
% Show instructions
6869

69-
DrawFormattedText(cfg.win, expParameters.TaskInstruction, ...
70+
DrawFormattedText(cfg.win, expParameters.taskInstruction, ...
7071
'center', 'center', cfg.textColor);
7172
Screen('Flip', cfg.win);
7273

@@ -115,22 +116,25 @@
115116
thisEvent.fileID = logFile.fileID;
116117
thisEvent.extraColumns = logFile.extraColumns;
117118

119+
disp(1)
118120
saveEventsFile('save', expParameters, thisEvent);
119-
121+
disp(2)
122+
120123
clear thisEvent;
121124

122125
% collect the responses and appends to the event structure for
123126
% saving in the tsv file
124127
responseEvents = getResponse('check', cfg.keyboard.responseBox, cfg, getOnlyPress);
125128

126-
if ~isempty(responseEvents(1).onset)
129+
if isfield(responseEvents(1), 'onset') && ~isempty(responseEvents(1).onset)
127130

128131
responseEvents.fileID = logFile.fileID;
129132

130133
for iResp = 1:size(responseEvents, 1)
131134
responseEvents(iResp).onset = ...
132135
responseEvents(iResp).onset - cfg.experimentStart;
133-
responseEvents(iResp).target = expParameters.designFixationTargets(iBlock, iEvent);
136+
responseEvents(iResp).target = ...
137+
expParameters.designFixationTargets(iBlock, iEvent);
134138
responseEvents(iResp).event = iEvent;
135139
responseEvents(iResp).block = iBlock;
136140
end
@@ -165,7 +169,9 @@
165169
eyeTracker('Shutdown', cfg, expParameters);
166170

167171
% save the whole workspace
168-
matFile = fullfile(expParameters.outputDir, strrep(expParameters.fileName.events, 'tsv', 'mat'));
172+
matFile = fullfile( ...
173+
expParameters.outputDir, ...
174+
strrep(expParameters.fileName.events, 'tsv', 'mat'));
169175
if IsOctave
170176
save(matFile, '-mat7-binary');
171177
else

0 commit comments

Comments
 (0)