Skip to content

Commit 4f5c910

Browse files
Merge pull request #7 from marcobarilari/marco_cleaning-setParam
move and rename some vars in `setParameters` and update the README
2 parents 292e16c + b8ee8f8 commit 4f5c910

File tree

4 files changed

+90
-92
lines changed

4 files changed

+90
-92
lines changed

README.md

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,27 @@ For instructions see the following links:
88

99
| Requirements | Used version |
1010
|----------------------------------------------------------|--------------|
11-
| [CPP_BIDS](https://github.com/cpp-lln-lab/CPP_BIDS) | ? |
12-
| [CPP_PTB](https://github.com/cpp-lln-lab/CPP_PTB) | ? |
1311
| [PsychToolBox](http://psychtoolbox.org/) | >=3.0.14 |
14-
| [Matlab](https://www.mathworks.com/products/matlab.html) | >=2017 |
12+
| [Matlab](https://www.mathworks.com/products/matlab.html) | >=2017b |
1513
| or [octave](https://www.gnu.org/software/octave/) | >=4.? |
1614

17-
## Installing dependencies
15+
## Installation
1816

19-
All the dependencies needed to run this are listed in the [mpm-requirements.txt file](.mpm-requirements.txt). If those functions are not in the matlab path the scripts in this repository will not work.
17+
The CPP_BIDS and CPP_PTB dependencies are already set up as submodule to this repository.
18+
You can install it all with git by doing.
2019

21-
If you are using the [matlab package manager](https://github.com/mobeets/mpm), you can simply download the appropriate version of those dependencies and add them to your path by running the `getDependencies` function.
22-
23-
```matlab
24-
getDependencies('update')
20+
```bash
21+
git clone --recurse-submodules https://github.com/cpp-lln-lab/localizer_auditory_motion.git
2522
```
2623

27-
If you already have the appropriate version but just want to add them to the matlab path, then run.
28-
29-
```matlab
30-
getDependencies()
31-
```
3224
## Structure and function details
3325

3426

35-
### visualLocTranslational
27+
### audioLocTranslational
3628

37-
Running this script will play blocks of motion static sounds. Motion blocks will play sounds moving in one of four directions (up-, down-, left-, and right-ward)
29+
Running this script will play blocks of motion/static sounds. Motion blocks will play sounds moving in one of four directions (up-, down-, left-, and right-ward)
3830

39-
By default it is run in `Debug mode` meaning that it does not run care about subjID, run n., fMRI triggers, Eye Tracker, etc..
31+
By default it is run in `Debug mode` meaning that it does not care about subjID, run n., fMRI triggers, Eye Tracker, etc..
4032

4133
Any details of the experiment can be changed in `setParameters.m` (e.g., experiment mode, motion stimuli details, exp. design, etc.)
4234

@@ -45,12 +37,13 @@ Any details of the experiment can be changed in `setParameters.m` (e.g., experim
4537
`setParameters.m` is the core engine of the experiment. It contains the following tweakable sections:
4638

4739
- Debug mode setting
48-
- MRI settings
4940
- Engine parameters:
41+
- Devices parameters
5042
- Monitor parameters
51-
- Monitor parameters for PsychToolBox
52-
- Keyboards
43+
- Keyboard parameters
44+
- MRI parameters
5345
- Experiment Design
46+
- Timing
5447
- Auditory Stimulation
5548
- Task(s)
5649
- Instructions

audioLocTranslational.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262

6363
getResponse('start', cfg.keyboard.responseBox);
6464

65-
WaitSecs(cfg.onsetDelay);
65+
WaitSecs(cfg.timing.onsetDelay);
6666

6767
%% For Each Block
6868

@@ -110,18 +110,18 @@
110110
saveResponsesAndTriggers(responseEvents, cfg, logFile, triggerString);
111111

112112
% wait for the inter-stimulus interval
113-
WaitSecs(cfg.ISI);
113+
WaitSecs(cfg.timing.ISI);
114114

115115
end
116116

117117
eyeTracker('StopRecordings', cfg);
118118

119-
WaitSecs(cfg.IBI);
119+
WaitSecs(cfg.timing.IBI);
120120

121121
end
122122

123123
% End of the run for the BOLD to go down
124-
WaitSecs(cfg.endDelay);
124+
WaitSecs(cfg.timing.endDelay);
125125

126126
% Close the logfiles
127127
saveEventsFile('close', cfg, logFile);

setParameters.m

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,38 @@
3232
% MRI settings
3333
cfg = setMRI(cfg);
3434

35-
cfg.audio.channels = 2;
36-
3735
%% Experiment Design
38-
cfg.names = {'static', 'motion'};
39-
cfg.possibleDirections = [-1 1]; % 1 motion , -1 static
40-
cfg.numBlocks = size(cfg.possibleDirections, 2);
41-
cfg.numRepetitions = 1; % AT THE MOMENT IT IS NOT SET IN THE MAIN SCRIPT
36+
37+
cfg.design.names = {'static', 'motion'};
38+
cfg.design.possibleDirections = [-1 1]; % 1 motion , -1 static %NOT IN USE AT THE MOMENT
39+
cfg.design.nbBlocks = size(cfg.design.names, 2); % TO CHECK
40+
cfg.design.nbRepetitions = 1; % AT THE MOMENT IT IS NOT SET IN THE MAIN SCRIPT
41+
cfg.design.nbEventsPerBlock = 12;
4242

4343
%% Timing
44-
cfg.IBI = 0; % 8;
45-
cfg.ISI = 0.1; % Time between events in secs
46-
cfg.onsetDelay = 1; % Number of seconds before the motion stimuli are presented
47-
cfg.endDelay = 1; % Number of seconds after the end all the stimuli before ending the run
44+
45+
% FOR 7T: if you want to create localizers on the fly, the following must be
46+
% multiples of the scanneryour sequence TR
47+
%
48+
% IBI
49+
% block length = (cfg.eventDuration + cfg.ISI) * cfg.design.nbEventsPerBlock
50+
51+
% Time between blocs in secs
52+
cfg.timing.IBI = 1.8 * 3; % 8;
53+
% Time between events in secs
54+
cfg.timing.ISI = 0.1;
55+
% Number of seconds before the motion stimuli are presented
56+
cfg.timing.onsetDelay = .1;
57+
% Number of seconds after the end all the stimuli before ending the run
58+
cfg.timing.endDelay = .1;
4859

4960
%% Auditory Stimulation
5061

51-
% expParameters.experimentType = 'Gratings'; %Dots/Gratings % Visual modality is in RDKs %NOT USED IN THE MAIN SCIPT
52-
cfg.speedEvent = 8; % speed in visual angles
53-
cfg.numEventsPerBlock = 12; % Number of events per block (should not be changed)
54-
cfg.eventDuration = 10;
62+
cfg.audio.channels = 2;
5563

56-
%% Task
64+
%% Task(s)
5765

58-
cfg.task.name = 'visual localizer';
66+
cfg.task.name = 'auditory localizer';
5967

6068
% Instruction
6169
cfg.task.instruction = '1-Detect the RED fixation cross\n \n\n';
@@ -76,6 +84,26 @@
7684

7785
end
7886

87+
function cfg = setMonitor(cfg)
88+
89+
% Monitor parameters for PTB
90+
cfg.color.white = [255 255 255];
91+
cfg.color.black = [0 0 0];
92+
cfg.color.red = [255 0 0];
93+
cfg.color.grey = mean([cfg.color.black; cfg.color.white]);
94+
cfg.color.background = cfg.color.black;
95+
cfg.text.color = cfg.color.white;
96+
97+
% Monitor parameters
98+
cfg.screen.monitorWidth = 50; % in cm
99+
cfg.screen.monitorDistance = 40; % distance from the screen in cm
100+
101+
if strcmpi(cfg.testingDevice, 'mri')
102+
cfg.screen.monitorWidth = 50;
103+
cfg.screen.monitorDistance = 40;
104+
end
105+
end
106+
79107
function cfg = setKeyboards(cfg)
80108
cfg.keyboard.escapeKey = 'ESCAPE';
81109
cfg.keyboard.responseKey = {'space', 't'};
@@ -99,23 +127,3 @@
99127
cfg.bids.MRI.TaskDescription = [];
100128

101129
end
102-
103-
function cfg = setMonitor(cfg)
104-
105-
% Monitor parameters for PTB
106-
cfg.color.white = [255 255 255];
107-
cfg.color.black = [0 0 0];
108-
cfg.color.red = [255 0 0];
109-
cfg.color.grey = mean([cfg.color.black; cfg.color.white]);
110-
cfg.color.background = cfg.color.black;
111-
cfg.text.color = cfg.color.white;
112-
113-
% Monitor parameters
114-
cfg.screen.monitorWidth = 50; % in cm
115-
cfg.screen.monitorDistance = 40; % distance from the screen in cm
116-
117-
if strcmpi(cfg.testingDevice, 'mri')
118-
cfg.screen.monitorWidth = 50;
119-
cfg.screen.monitorDistance = 40;
120-
end
121-
end

subfun/expDesign.m

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
function [cfg] = expDesign(cfg, 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 (Gives better results
5+
% than randomised).
56
%
67
% It can be run as a stand alone without inputs to display a visual example of possible design.
78
%
@@ -24,14 +25,13 @@
2425
% - ExpParameters.designBlockNames = cell array (nr_blocks, 1) with the
2526
% name for each block
2627
%
27-
% - ExpParameters.designDirections = array (nr_blocks, numEventsPerBlock)
28+
% - ExpParameters.designDirections = array (nr_blocks, nbEventsPerBlock)
2829
% with the direction to present in a given block
2930
% - 0 90 180 270 indicate the angle
3031
% - -1 indicates static
3132
%
32-
% - ExpParameters.designSpeeds = array (nr_blocks, numEventsPerBlock) * speedEvent
3333
%
34-
% - ExpParameters.designFixationTargets = array (nr_blocks, numEventsPerBlock)
34+
% - ExpParameters.designFixationTargets = array (nr_blocks, nbEventsPerBlock)
3535
% showing for each event if it should be accompanied by a target
3636
%
3737

@@ -48,11 +48,10 @@
4848

4949
% Set variables here for a dummy test of this function
5050
if nargin < 1 || isempty(cfg)
51-
cfg.names = {'static', 'motion'};
52-
cfg.numRepetitions = 4;
53-
cfg.speedEvent = 4;
54-
cfg.numEventsPerBlock = 12;
55-
cfg.maxNumFixationTargetPerBlock = 2;
51+
cfg.design.names = {'static', 'motion'};
52+
cfg.design.nbRepetitions = 4;
53+
cfg.design.nbEventsPerBlock = 12;
54+
cfg.target.maxNbPerBlock = 2;
5655
end
5756

5857
% Set to 1 for a visualtion of the trials design order
@@ -61,46 +60,44 @@
6160
end
6261

6362
% Get the parameters
64-
names = cfg.names;
65-
numRepetitions = cfg.numRepetitions;
66-
speedEvent = cfg.speedEvent;
67-
numEventsPerBlock = cfg.numEventsPerBlock;
68-
maxNumFixTargPerBlock = cfg.target.maxNbPerBlock;
69-
70-
if mod(numEventsPerBlock, length(motionDirections)) ~= 0
71-
warning('the number of events per block is not a multiple of the number of motion/static diection');
63+
names = cfg.design.names;
64+
nbRepetitions = cfg.design.nbRepetitions;
65+
nbEventsPerBlock = cfg.design.nbEventsPerBlock;
66+
maxNbFixTargPerBlock = cfg.target.maxNbPerBlock;
67+
68+
if mod(nbEventsPerBlock, length(motionDirections)) ~= 0
69+
warning('the n. of events per block is not a multiple of experimental conditions');
7270
end
7371

7472
%% Adapt some variables according to input
7573

7674
% Set directions for static and motion condition
77-
motionDirections = repmat(motionDirections, 1, numEventsPerBlock / length(motionDirections));
78-
staticDirections = repmat(staticDirections, 1, numEventsPerBlock / length(staticDirections));
75+
motionDirections = repmat(motionDirections, 1, nbEventsPerBlock / length(motionDirections));
76+
staticDirections = repmat(staticDirections, 1, nbEventsPerBlock / length(staticDirections));
7977

8078
% Assign the conditions
81-
condition = repmat(names, 1, numRepetitions);
79+
condition = repmat(names, 1, nbRepetitions);
8280
nrBlocks = length(condition);
8381
% Get the index of each condition
8482
staticIndex = find(strcmp(condition, 'static'));
8583
motionIndex = find(strcmp(condition, 'motion'));
8684

8785
% Assign the targets for each condition
88-
rangeTargets = [1 maxNumFixTargPerBlock];
86+
rangeTargets = [1 maxnbFixTargPerBlock];
8987
% Get random number of targets for one condition
90-
targetPerCondition = randi(rangeTargets, 1, numRepetitions);
88+
targetPerCondition = randi(rangeTargets, 1, nbRepetitions);
9189
% Assign the number of targets for each condition after shuffling
92-
numTargets = zeros(1, nrBlocks);
93-
numTargets(staticIndex) = Shuffle(targetPerCondition);
94-
numTargets(motionIndex) = Shuffle(targetPerCondition);
90+
nbTargets = zeros(1, nrBlocks);
91+
nbTargets(staticIndex) = Shuffle(targetPerCondition);
92+
nbTargets(motionIndex) = Shuffle(targetPerCondition);
9593

9694
%% Give the blocks the names with condition
9795

9896
cfg.designBlockNames = cell(nrBlocks, 1);
99-
cfg.designDirections = zeros(nrBlocks, numEventsPerBlock);
100-
cfg.designSpeeds = ones(nrBlocks, numEventsPerBlock) * speedEvent;
101-
cfg.designFixationTargets = zeros(nrBlocks, numEventsPerBlock);
97+
cfg.designDirections = zeros(nrBlocks, nbEventsPerBlock);
98+
cfg.designFixationTargets = zeros(nrBlocks, nbEventsPerBlock);
10299

103-
for iMotionBlock = 1:numRepetitions
100+
for iMotionBlock = 1:nbRepetitions
104101

105102
cfg.designDirections(motionIndex(iMotionBlock), :) = Shuffle(motionDirections);
106103
cfg.designDirections(staticIndex(iMotionBlock), :) = Shuffle(staticDirections);
@@ -125,20 +122,20 @@
125122

126123
chosenTarget = [];
127124

128-
tmpTarget = numTargets(iBlock);
125+
tmpTarget = nbTargets(iBlock);
129126

130127
switch tmpTarget
131128

132129
case 1
133130

134-
chosenTarget = randsample(2:numEventsPerBlock - 1, tmpTarget, false);
131+
chosenTarget = randsample(2:nbEventsPerBlock - 1, tmpTarget, false);
135132

136133
case 2
137134

138135
targetDifference = 0;
139136

140137
while targetDifference <= 2
141-
chosenTarget = randsample(2:numEventsPerBlock - 1, tmpTarget, false);
138+
chosenTarget = randsample(2:nbEventsPerBlock - 1, tmpTarget, false);
142139
targetDifference = (max(chosenTarget) - min(chosenTarget));
143140
end
144141

0 commit comments

Comments
 (0)