|
1 | 1 | %% Auditory hMT localizer using translational motion in four directions |
2 | 2 | % (up- down- left and right-ward) |
3 | 3 |
|
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; |
7 | 12 |
|
8 | 13 | % Clear all the previous stuff |
9 | 14 | % clc; clear; |
|
12 | 17 | clear Screen; |
13 | 18 | end |
14 | 19 |
|
15 | | -getOnlyPress = 1; |
16 | | - |
17 | | -more off; |
18 | | - |
19 | 20 | % make sure we got access to all the required functions and inputs |
20 | 21 | initEnv(); |
21 | 22 |
|
| 23 | +% set and load all the parameters to run the experiment |
22 | 24 | cfg = setParameters; |
23 | 25 | cfg = userInputs(cfg); |
24 | 26 | cfg = createFilename(cfg); |
|
28 | 30 | % Safety loop: close the screen if code crashes |
29 | 31 | try |
30 | 32 |
|
31 | | - % % % REFACTOR THIS FUNCTION |
32 | | - [cfg] = loadAudioFiles(cfg); |
33 | | - |
34 | 33 | %% Init the experiment |
35 | 34 | [cfg] = initPTB(cfg); |
36 | 35 |
|
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 % % % |
40 | 41 |
|
41 | 42 | [el] = eyeTracker('Calibration', cfg); |
42 | 43 |
|
43 | | - % % % REFACTOR THIS FUNCTION |
| 44 | + % % % REFACTOR THIS FUNCTION % % % |
| 45 | + |
44 | 46 | [cfg] = expDesign(cfg); |
45 | 47 |
|
| 48 | + % % % REFACTOR THIS FUNCTION % % % |
| 49 | + |
46 | 50 | % 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); |
49 | 53 |
|
50 | | - % disp(cfg); |
| 54 | + disp(cfg); |
51 | 55 |
|
| 56 | + % Show experiment instruction |
52 | 57 | standByScreen(cfg); |
53 | 58 |
|
54 | 59 | % prepare the KbQueue to collect responses |
|
79 | 84 | checkAbort(cfg, cfg.keyboard.keyboard); |
80 | 85 |
|
81 | 86 | % 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 % % % |
86 | 93 |
|
87 | 94 | % 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 % % % |
89 | 98 |
|
90 | 99 | thisEvent.event = iEvent; |
91 | 100 | thisEvent.block = iBlock; |
| 101 | + thisEvent.keyName = 'n/a'; |
92 | 102 | thisEvent.duration = duration; |
93 | 103 | thisEvent.onset = onset - cfg.experimentStart; |
94 | 104 |
|
95 | 105 | % Save the events txt logfile |
96 | 106 | % we save event by event so we clear this variable every loop |
97 | 107 | thisEvent.fileID = logFile.fileID; |
| 108 | + thisEvent.extraColumns = logFile.extraColumns; |
98 | 109 |
|
99 | | - saveEventsFile('save', cfg, thisEvent, ... |
100 | | - 'direction', 'speed', 'target', 'event', 'block'); |
| 110 | + saveEventsFile('save', cfg, thisEvent); |
101 | 111 |
|
102 | 112 | clear thisEvent; |
103 | 113 |
|
|
106 | 116 | responseEvents = getResponse('check', cfg.keyboard.responseBox, cfg, ... |
107 | 117 | getOnlyPress); |
108 | 118 |
|
109 | | - triggerString = ['trigger']; |
| 119 | + triggerString = ['trigger_' cfg.design.blockNames{iBlock}]; |
110 | 120 | saveResponsesAndTriggers(responseEvents, cfg, logFile, triggerString); |
111 | 121 |
|
112 | 122 | % wait for the inter-stimulus interval |
|
118 | 128 |
|
119 | 129 | WaitSecs(cfg.timing.IBI); |
120 | 130 |
|
| 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 | + |
121 | 138 | end |
122 | 139 |
|
123 | 140 | % End of the run for the BOLD to go down |
124 | 141 | WaitSecs(cfg.timing.endDelay); |
125 | 142 |
|
| 143 | + cfg = getExperimentEnd(cfg); |
| 144 | + |
126 | 145 | % Close the logfiles |
127 | 146 | saveEventsFile('close', cfg, logFile); |
128 | 147 |
|
129 | 148 | getResponse('stop', cfg.keyboard.responseBox); |
130 | 149 | getResponse('release', cfg.keyboard.responseBox); |
131 | 150 |
|
132 | | - totalExperimentTime = GetSecs - cfg.experimentStart; |
133 | | - |
134 | 151 | eyeTracker('Shutdown', cfg); |
135 | 152 |
|
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); |
143 | 156 |
|
144 | 157 | cleanUp(); |
145 | 158 |
|
|
0 commit comments