Skip to content

Commit 8854a3a

Browse files
committed
update the main script to its elder brother visual localizer
1 parent 4f5b577 commit 8854a3a

File tree

1 file changed

+47
-34
lines changed

1 file changed

+47
-34
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

0 commit comments

Comments
 (0)