Skip to content

Commit fee86f3

Browse files
Merge pull request #9 from marcobarilari/marco_update-main-script
update the main script and other subfun to the elder brother (visual loc) state of the art
2 parents 4f5c910 + 91b7725 commit fee86f3

File tree

2 files changed

+62
-49
lines changed

2 files changed

+62
-49
lines changed

audioLocTranslational.m

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
%% Auditory hMT localizer using translational motion in four directions
22
% (up- down- left and right-ward)
33

4-
% Original Script Written by Sam Weiller to localize MT+/V5
5-
% adapted by M.Rezk to localize MT/MST (Huk,2002)
6-
% re-adapted by MarcoB and RemiG 2020
4+
% by Mohamed Rezk 2018
5+
% adapted by MarcoB and RemiG 2020
6+
7+
%%
8+
9+
getOnlyPress = 1;
10+
11+
more off;
712

813
% Clear all the previous stuff
914
% clc; clear;
@@ -12,13 +17,10 @@
1217
clear Screen;
1318
end
1419

15-
getOnlyPress = 1;
16-
17-
more off;
18-
1920
% make sure we got access to all the required functions and inputs
2021
initEnv();
2122

23+
% set and load all the parameters to run the experiment
2224
cfg = setParameters;
2325
cfg = userInputs(cfg);
2426
cfg = createFilename(cfg);
@@ -28,27 +30,30 @@
2830
% Safety loop: close the screen if code crashes
2931
try
3032

31-
% % % REFACTOR THIS FUNCTION
32-
[cfg] = loadAudioFiles(cfg);
33-
3433
%% Init the experiment
3534
[cfg] = initPTB(cfg);
3635

37-
% % Convert some values from degrees to pixels
38-
% cfg = deg2Pix('diameterAperture', cfg, cfg);
39-
% expParameters = deg2Pix('dotSize', expParameters, cfg);
36+
% % % REFACTOR THIS FUNCTION % % %
37+
38+
[cfg] = loadAudioFiles(cfg);
39+
40+
% % % REFACTOR THIS FUNCTION % % %
4041

4142
[el] = eyeTracker('Calibration', cfg);
4243

43-
% % % REFACTOR THIS FUNCTION
44+
% % % REFACTOR THIS FUNCTION % % %
45+
4446
[cfg] = expDesign(cfg);
4547

48+
% % % REFACTOR THIS FUNCTION % % %
49+
4650
% Prepare for the output logfiles with all
47-
logFile = saveEventsFile('open', cfg, [], ...
48-
'direction', 'speed', 'target', 'event', 'block');
51+
logFile.extraColumns = cfg.extraColumns;
52+
logFile = saveEventsFile('open', cfg, logFile);
4953

50-
% disp(cfg);
54+
disp(cfg);
5155

56+
% Show experiment instruction
5257
standByScreen(cfg);
5358

5459
% prepare the KbQueue to collect responses
@@ -79,25 +84,30 @@
7984
checkAbort(cfg, cfg.keyboard.keyboard);
8085

8186
% set direction, speed of that event and if it is a target
82-
thisEvent.trial_type = 'dummy';
83-
thisEvent.direction = cfg.designDirections(iBlock, iEvent);
84-
thisEvent.speed = cfg.designSpeeds(iBlock, iEvent);
85-
thisEvent.target = cfg.designFixationTargets(iBlock, iEvent);
87+
thisEvent.trial_type = cfg.design.blockNames{iBlock};
88+
thisEvent.direction = cfg.design.directions(iBlock, iEvent);
89+
% thisEvent.speed = cfg.design.speeds(iBlock, iEvent);
90+
thisEvent.target = cfg.design.fixationTargets(iBlock, iEvent);
91+
92+
% % % REFACTOR THIS FUNCTION % % %
8693

8794
% play the sounds and collect onset and duration of the event
88-
[onset, duration] = doAudMot(cfg, thisEvent, cfg.audio.pahandle);
95+
[onset, duration] = doAudMot(cfg, thisEvent);
96+
97+
% % % REFACTOR THIS FUNCTION % % %
8998

9099
thisEvent.event = iEvent;
91100
thisEvent.block = iBlock;
101+
thisEvent.keyName = 'n/a';
92102
thisEvent.duration = duration;
93103
thisEvent.onset = onset - cfg.experimentStart;
94104

95105
% Save the events txt logfile
96106
% we save event by event so we clear this variable every loop
97107
thisEvent.fileID = logFile.fileID;
108+
thisEvent.extraColumns = logFile.extraColumns;
98109

99-
saveEventsFile('save', cfg, thisEvent, ...
100-
'direction', 'speed', 'target', 'event', 'block');
110+
saveEventsFile('save', cfg, thisEvent);
101111

102112
clear thisEvent;
103113

@@ -106,7 +116,7 @@
106116
responseEvents = getResponse('check', cfg.keyboard.responseBox, cfg, ...
107117
getOnlyPress);
108118

109-
triggerString = ['trigger'];
119+
triggerString = ['trigger_' cfg.design.blockNames{iBlock}];
110120
saveResponsesAndTriggers(responseEvents, cfg, logFile, triggerString);
111121

112122
% wait for the inter-stimulus interval
@@ -118,28 +128,31 @@
118128

119129
WaitSecs(cfg.timing.IBI);
120130

131+
% trigger monitoring
132+
triggerEvents = getResponse('check', cfg.keyboard.responseBox, cfg, ...
133+
getOnlyPress);
134+
135+
triggerString = 'trigger_baseline';
136+
saveResponsesAndTriggers(triggerEvents, cfg, logFile, triggerString);
137+
121138
end
122139

123140
% End of the run for the BOLD to go down
124141
WaitSecs(cfg.timing.endDelay);
125142

143+
cfg = getExperimentEnd(cfg);
144+
126145
% Close the logfiles
127146
saveEventsFile('close', cfg, logFile);
128147

129148
getResponse('stop', cfg.keyboard.responseBox);
130149
getResponse('release', cfg.keyboard.responseBox);
131150

132-
totalExperimentTime = GetSecs - cfg.experimentStart;
133-
134151
eyeTracker('Shutdown', cfg);
135152

136-
% save the whole workspace
137-
matFile = fullfile(cfg.dir.output, strrep(cfg.fileName.events, 'tsv', 'mat'));
138-
if IsOctave
139-
save(matFile, '-mat7-binary');
140-
else
141-
save(matFile, '-v7.3');
142-
end
153+
createBoldJson(cfg, cfg);
154+
155+
farewellScreen(cfg);
143156

144157
cleanUp();
145158

subfun/expDesign.m

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222
% matrix of the design
2323
%
2424
% Output:
25-
% - ExpParameters.designBlockNames = cell array (nr_blocks, 1) with the
25+
% - ExpParameters.design.blockNames = cell array (nr_blocks, 1) with the
2626
% name for each block
2727
%
28-
% - ExpParameters.designDirections = array (nr_blocks, nbEventsPerBlock)
28+
% - ExpParameters.design.directions = array (nr_blocks, nbEventsPerBlock)
2929
% with the direction to present in a given block
3030
% - 0 90 180 270 indicate the angle
3131
% - -1 indicates static
3232
%
3333
%
34-
% - ExpParameters.designFixationTargets = array (nr_blocks, nbEventsPerBlock)
34+
% - ExpParameters.design.fixationTargets = array (nr_blocks, nbEventsPerBlock)
3535
% showing for each event if it should be accompanied by a target
3636
%
3737

@@ -48,8 +48,8 @@
4848

4949
% Set variables here for a dummy test of this function
5050
if nargin < 1 || isempty(cfg)
51-
cfg.design.names = {'static', 'motion'};
52-
cfg.design.nbRepetitions = 4;
51+
cfg.design.names = {'static', 'motion'};
52+
cfg.design.nbRepetitions = 4;
5353
cfg.design.nbEventsPerBlock = 12;
5454
cfg.target.maxNbPerBlock = 2;
5555
end
@@ -93,14 +93,14 @@
9393

9494
%% Give the blocks the names with condition
9595

96-
cfg.designBlockNames = cell(nrBlocks, 1);
97-
cfg.designDirections = zeros(nrBlocks, nbEventsPerBlock);
98-
cfg.designFixationTargets = zeros(nrBlocks, nbEventsPerBlock);
96+
cfg.design.blockNames = cell(nrBlocks, 1);
97+
cfg.design.directions = zeros(nrBlocks, nbEventsPerBlock);
98+
cfg.design.fixationTargets = zeros(nrBlocks, nbEventsPerBlock);
9999

100100
for iMotionBlock = 1:nbRepetitions
101101

102-
cfg.designDirections(motionIndex(iMotionBlock), :) = Shuffle(motionDirections);
103-
cfg.designDirections(staticIndex(iMotionBlock), :) = Shuffle(staticDirections);
102+
cfg.design.directions(motionIndex(iMotionBlock), :) = Shuffle(motionDirections);
103+
cfg.design.directions(staticIndex(iMotionBlock), :) = Shuffle(staticDirections);
104104

105105
end
106106

@@ -113,7 +113,7 @@
113113
case 'motion'
114114
thisBlockName = {'motion'};
115115
end
116-
cfg.designBlockNames(iBlock) = thisBlockName;
116+
cfg.design.blockNames(iBlock) = thisBlockName;
117117

118118
% set target
119119
% if there are 2 targets per block we make sure that they are at least
@@ -141,19 +141,19 @@
141141

142142
end
143143

144-
cfg.designFixationTargets(iBlock, chosenTarget) = 1;
144+
cfg.design.fixationTargets(iBlock, chosenTarget) = 1;
145145

146146
end
147147

148148
%% Visualize the design matrix
149149
if displayFigs
150150

151-
uniqueNames = unique(cfg.designBlockNames) ;
151+
uniqueNames = unique(cfg.design.blockNames) ;
152152

153-
Ind = zeros(length(cfg.designBlockNames), length(uniqueNames)) ;
153+
Ind = zeros(length(cfg.design.blockNames), length(uniqueNames)) ;
154154

155155
for i = 1:length(uniqueNames)
156-
CondInd(:, i) = find(strcmp(cfg.designBlockNames, uniqueNames{i})) ; %#ok<*AGROW>
156+
CondInd(:, i) = find(strcmp(cfg.design.blockNames, uniqueNames{i})) ; %#ok<*AGROW>
157157
Ind(CondInd(:, i), i) = 1 ;
158158
end
159159

0 commit comments

Comments
 (0)