Skip to content

Commit 09177f6

Browse files
authored
Merge pull request #9 from Remi-Gau/remi-use_submodule
make the switch to use submodules
2 parents 267aaff + 7dfa413 commit 09177f6

14 files changed

+594
-830
lines changed

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "lib/CPP_PTB"]
2+
path = lib/CPP_PTB
3+
url = https://github.com/cpp-lln-lab/CPP_PTB.git
4+
[submodule "lib/CPP_BIDS"]
5+
path = lib/CPP_BIDS
6+
url = https://github.com/cpp-lln-lab/CPP_BIDS.git

audioLocTranslational.m

Lines changed: 90 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -5,207 +5,147 @@
55
% adapted by M.Rezk to localize MT/MST (Huk,2002)
66
% re-adapted by MarcoB and RemiG 2020
77

8-
%%
9-
108
% Clear all the previous stuff
119
% clc; clear;
1210
if ~ismac
13-
close all;
14-
clear Screen;
11+
close all;
12+
clear Screen;
1513
end
1614

17-
% make sure we got access to all the required functions and inputs
18-
addpath(genpath(fullfile(pwd, 'subfun')))
19-
20-
[expParameters, cfg] = setParameters;
15+
getOnlyPress = 1;
2116

22-
% set and load all the parameters to run the experiment
23-
expParameters = userInputs(cfg, expParameters);
17+
more off;
2418

25-
expParameters = createFilename(cfg, expParameters);
19+
% make sure we got access to all the required functions and inputs
20+
initEnv();
2621

27-
expParameters %#ok<NOPTS>
22+
cfg = setParameters;
23+
cfg = userInputs(cfg);
24+
cfg = createFilename(cfg);
2825

2926
%% Experiment
3027

3128
% Safety loop: close the screen if code crashes
3229
try
33-
30+
31+
% % % REFACTOR THIS FUNCTION
32+
[cfg] = loadAudioFiles(cfg);
33+
3434
%% Init the experiment
3535
[cfg] = initPTB(cfg);
36-
36+
3737
% % Convert some values from degrees to pixels
3838
% cfg = deg2Pix('diameterAperture', cfg, cfg);
3939
% expParameters = deg2Pix('dotSize', expParameters, cfg);
40-
41-
42-
[el] = eyeTracker('Calibration', cfg, expParameters);
43-
40+
41+
[el] = eyeTracker('Calibration', cfg);
42+
4443
% % % REFACTOR THIS FUNCTION
45-
[expParameters] = expDesign(expParameters);
46-
% % %
47-
44+
[cfg] = expDesign(cfg);
45+
4846
% Prepare for the output logfiles with all
49-
logFile = saveEventsFile('open', expParameters, [], ...
47+
logFile = saveEventsFile('open', cfg, [], ...
5048
'direction', 'speed', 'target', 'event', 'block');
51-
52-
logFile
53-
54-
% % % REFACTOR THIS FUNCTION
55-
[expParameters] = loadAudioFiles(cfg, expParameters);
56-
phandle = PsychPortAudio('Open',[],[],1,expParameters.freq,2);
57-
% % %
58-
59-
% Prepare for fixation Cross
60-
if expParameters.Task1
61-
62-
cfg.xCoords = [-expParameters.fixCrossDimPix expParameters.fixCrossDimPix 0 0] ...
63-
+ expParameters.xDisplacementFixCross;
64-
65-
cfg.yCoords = [0 0 -expParameters.fixCrossDimPix expParameters.fixCrossDimPix] ...
66-
+ expParameters.yDisplacementFixCross;
67-
68-
cfg.allCoords = [cfg.xCoords; cfg.yCoords];
69-
70-
end
71-
72-
% Wait for space key to be pressed
73-
pressSpace4me
74-
49+
50+
% disp(cfg);
51+
52+
standByScreen(cfg);
53+
7554
% prepare the KbQueue to collect responses
76-
getResponse('init', cfg, expParameters, 1);
77-
getResponse('start', cfg, expParameters, 1);
78-
79-
% Show instructions
80-
if expParameters.Task1
81-
DrawFormattedText(cfg.win,expParameters.TaskInstruction,...
82-
'center', 'center', cfg.textColor);
83-
Screen('Flip', cfg.win);
84-
end
85-
55+
getResponse('init', cfg.keyboard.responseBox, cfg);
56+
8657
% Wait for Trigger from Scanner
87-
wait4Trigger(cfg)
88-
89-
% Show the fixation cross
90-
if expParameters.Task1
91-
drawFixationCross(cfg, expParameters, expParameters.fixationCrossColor)
92-
Screen('Flip',cfg.win);
93-
end
94-
58+
waitForTrigger(cfg);
59+
9560
%% Experiment Start
96-
cfg.experimentStart = GetSecs;
97-
98-
WaitSecs(expParameters.onsetDelay);
99-
61+
cfg = getExperimentStart(cfg);
62+
63+
getResponse('start', cfg.keyboard.responseBox);
64+
65+
WaitSecs(cfg.onsetDelay);
66+
10067
%% For Each Block
101-
102-
stopEverything = 0;
103-
104-
for iBlock = 1:expParameters.numBlocks
105-
106-
if stopEverything
107-
break;
108-
end
109-
110-
fprintf('\n - Running Block %.0f \n',iBlock)
111-
112-
eyeTracker('StartRecording', cfg, expParameters);
113-
68+
69+
for iBlock = 1:cfg.numBlocks
70+
71+
fprintf('\n - Running Block %.0f \n', iBlock);
72+
73+
eyeTracker('StartRecording', cfg);
74+
11475
% For each event in the block
115-
for iEvent = 1:expParameters.numEventsPerBlock
116-
117-
76+
for iEvent = 1:cfg.numEventsPerBlock
77+
11878
% Check for experiment abortion from operator
119-
[keyIsDown, ~, keyCode] = KbCheck(cfg.keyboard);
120-
if keyIsDown && keyCode(KbName(cfg.escapeKey))
121-
stopEverything = 1;
122-
warning('OK let us get out of here')
123-
break;
124-
end
125-
126-
79+
checkAbort(cfg, cfg.keyboard.keyboard);
80+
12781
% set direction, speed of that event and if it is a target
12882
thisEvent.trial_type = 'dummy';
129-
thisEvent.direction = expParameters.designDirections(iBlock,iEvent);
130-
thisEvent.speed = expParameters.designSpeeds(iBlock,iEvent);
131-
thisEvent.target = expParameters.designFixationTargets(iBlock,iEvent);
132-
83+
thisEvent.direction = cfg.designDirections(iBlock, iEvent);
84+
thisEvent.speed = cfg.designSpeeds(iBlock, iEvent);
85+
thisEvent.target = cfg.designFixationTargets(iBlock, iEvent);
86+
13387
% play the sounds and collect onset and duration of the event
134-
[onset, duration] = doAudMot(cfg, expParameters, thisEvent, phandle);
135-
88+
[onset, duration] = doAudMot(cfg, thisEvent, cfg.audio.pahandle);
89+
13690
thisEvent.event = iEvent;
13791
thisEvent.block = iBlock;
13892
thisEvent.duration = duration;
13993
thisEvent.onset = onset - cfg.experimentStart;
140-
94+
14195
% Save the events txt logfile
14296
% we save event by event so we clear this variable every loop
14397
thisEvent.fileID = logFile.fileID;
144-
145-
saveEventsFile('save', expParameters, thisEvent, ...
98+
99+
saveEventsFile('save', cfg, thisEvent, ...
146100
'direction', 'speed', 'target', 'event', 'block');
147-
148-
clear thisEvent
149-
150-
101+
102+
clear thisEvent;
103+
151104
% collect the responses and appends to the event structure for
152105
% saving in the tsv file
153-
responseEvents = getResponse('check', cfg, expParameters);
154-
155-
if ~isempty(responseEvents(1).onset)
156-
157-
responseEvents.fileID = logFile.fileID;
158-
159-
for iResp = 1:size(responseEvents, 1)
160-
responseEvents(iResp).onset = ...
161-
responseEvents(iResp).onset - cfg.experimentStart;
162-
responseEvents(iResp).target = expParameters.designFixationTargets(iBlock,iEvent);
163-
responseEvents(iResp).event = iEvent;
164-
responseEvents(iResp).block = iBlock;
165-
end
166-
167-
saveEventsFile('save', expParameters, responseEvents, ...
168-
'direction', 'speed', 'target', 'event', 'block');
169-
end
170-
106+
responseEvents = getResponse('check', cfg.keyboard.responseBox, cfg, ...
107+
getOnlyPress);
108+
109+
triggerString = ['trigger'];
110+
saveResponsesAndTriggers(responseEvents, cfg, logFile, triggerString);
111+
171112
% wait for the inter-stimulus interval
172-
WaitSecs(expParameters.ISI);
173-
174-
getResponse('flush', cfg, expParameters);
175-
113+
WaitSecs(cfg.ISI);
114+
176115
end
177-
178-
eyeTracker('StopRecordings', cfg, expParameters);
179-
180-
WaitSecs(expParameters.IBI);
181-
116+
117+
eyeTracker('StopRecordings', cfg);
118+
119+
WaitSecs(cfg.IBI);
120+
182121
end
183-
122+
184123
% End of the run for the BOLD to go down
185-
WaitSecs(expParameters.endDelay);
186-
124+
WaitSecs(cfg.endDelay);
125+
187126
% Close the logfiles
188-
saveEventsFile('close', expParameters, logFile);
189-
190-
getResponse('stop', cfg, expParameters, 1);
191-
192-
totalExperimentTime = GetSecs-cfg.experimentStart;
193-
194-
eyeTracker('Shutdown', cfg, expParameters);
195-
127+
saveEventsFile('close', cfg, logFile);
128+
129+
getResponse('stop', cfg.keyboard.responseBox);
130+
getResponse('release', cfg.keyboard.responseBox);
131+
132+
totalExperimentTime = GetSecs - cfg.experimentStart;
133+
134+
eyeTracker('Shutdown', cfg);
135+
196136
% save the whole workspace
197-
matFile = fullfile(expParameters.outputDir, strrep(expParameters.fileName.events,'tsv', 'mat'));
137+
matFile = fullfile(cfg.dir.output, strrep(cfg.fileName.events, 'tsv', 'mat'));
198138
if IsOctave
199139
save(matFile, '-mat7-binary');
200140
else
201141
save(matFile, '-v7.3');
202142
end
203-
204-
cleanUp()
205-
143+
144+
cleanUp();
145+
206146
catch
207-
208-
cleanUp()
147+
148+
cleanUp();
209149
psychrethrow(psychlasterror);
210-
150+
211151
end

getDependencies.m

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
function getDependencies(action)
22

3-
if nargin<1
4-
action = '';
5-
end
3+
if nargin < 1
4+
action = '';
5+
end
66

7-
switch action
8-
case 'update'
9-
% install dependencies
10-
mpm install -i mpm-requirements.txt -f -c audio_motion_localizer
11-
end
7+
switch action
8+
case 'update'
9+
% install dependencies
10+
mpm install -i mpm-requirements.txt -f -c audio_motion_localizer;
11+
end
1212

13-
% adds them to the path
14-
mpm_folder = fileparts(which('mpm'));
15-
addpath(genpath(fullfile(mpm_folder, 'mpm-packages', 'mpm-collections', 'audio_motion_localizer')));
13+
% adds them to the path
14+
mpm_folder = fileparts(which('mpm'));
15+
addpath(genpath(fullfile(mpm_folder, 'mpm-packages', 'mpm-collections', 'audio_motion_localizer')));
1616

1717
end

0 commit comments

Comments
 (0)