-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetStimTable.m
More file actions
72 lines (62 loc) · 1.9 KB
/
getStimTable.m
File metadata and controls
72 lines (62 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
function [StimTable] = getStimTable(imgPerm)
% Ensure imgPerm is valid (1-ordered + group contiguous)
if testImgPerm(imgPerm)
error('Invalid imgPerm.');
end
% Set a sorted list of category names
catNames = {
'Ani'; % 0
'Art'; % 1
'Fac'; % 2
'Foo'; % 3
'Lin'; % 4
'Obj'; % 5
'Pla'; % 6
'Spa'; % 7
'Tex'; % 8
};
% Number of images per category
nImgsPerCat = 6;
% Size of StimTable
nStim = numel(catNames)*nImgsPerCat;
% Preallocate the variables
StimTable = struct;
StimTable.catName = cell(nStim,1);
StimTable.imgName = cell(nStim,1);
StimTable.catId = nan(nStim,1); % 0-ordered
StimTable.imgId = nan(nStim,1); % 0-ordered
StimTable.trigId_Typical = nan(nStim,1);
StimTable.trigId_Oddball = nan(nStim,1);
StimTable.imgPath_Typical = cell(nStim,1);
StimTable.imgPath_Oddball = cell(nStim,1);
StimTable.textureIdx_Typical = nan(nStim,1);
StimTable.textureIdx_Oddball = nan(nStim,1);
% Loop through to populate the variables
iIn = 0;
for iCat = 1:numel(catNames)
catName = catNames{iCat};
for iImg = 1:nImgsPerCat
iIn = iIn + 1;
imgName = sprintf('%s%i',catName,iImg-1);
StimTable.catName{iIn} = catName;
StimTable.imgName{iIn} = imgName;
StimTable.imgPath_Typical{iIn} = fullfile('.','Imgs','Typicals',...
[imgName,'.png']);
StimTable.imgPath_Oddball{iIn} = fullfile('.','Imgs','Oddballs',...
[imgName,'.png']);
end
end
StimTable.imgId = imgName2imgId(StimTable.imgName);
StimTable.catId = imgId2catId(StimTable.imgId);
StimTable.trigId_Typical = getTrigId(StimTable.imgId,0);
StimTable.trigId_Oddball = getTrigId(StimTable.imgId,1);
% Create the unsorted StimTable
StimTable = struct2table(StimTable);
% Sort the rows of the table
StimTable = StimTable(imgPerm,:);
return
function [fail] = testImgPerm(imgPerm)
M = kron(eye(9),ones(1,6)./6);
a = M*imgPerm;
fail = sum((sort(a)-(3.5:6:51.5)').^2) > 1e-16;
return