-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathet_processStims_nametrain.m
68 lines (53 loc) · 2.82 KB
/
et_processStims_nametrain.m
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
function [cfg,expParam] = et_processStims_nametrain(cfg,expParam,sesName,phaseName,phaseCount)
% function [cfg,expParam] = et_processStims_nametrain(cfg,expParam,sesName,phaseName,phaseCount)
fprintf('Configuring %s %s (%d)...\n',sesName,phaseName,phaseCount);
phaseCfg = cfg.stim.(sesName).(phaseName)(phaseCount);
if ~isfield(phaseCfg,'familyNames')
if ~phaseCfg.isExp
phaseCfg.familyNames = cfg.stim.practice.familyNames;
else
phaseCfg.familyNames = cfg.stim.familyNames;
end
end
% add the species in order from 1 to nSpecies; this is ok because, for each
% subject, each species number corresonds to a random species letter, as
% determined in et_saveStimList()
speciesOrder = nan(length(cfg.stim.familyNames),cfg.stim.nSpecies);
for f = 1:length(cfg.stim.familyNames)
speciesOrder(f,:) = (1:cfg.stim.nSpecies);
end
% initialize naming cells, one for each block
expParam.session.(sesName).(phaseName)(phaseCount).nameStims = cell(1,length(phaseCfg.blockSpeciesOrder));
for b = 1:length(phaseCfg.blockSpeciesOrder)
for s = 1:length(phaseCfg.blockSpeciesOrder{b})
for f = 1:length(cfg.stim.familyNames)
if ismember(cfg.stim.familyNames{f},phaseCfg.familyNames)
% get the indices for this species
sInd = [expParam.session.(sprintf('f%dTrained',f)).speciesNum] == speciesOrder(f,phaseCfg.blockSpeciesOrder{b}(s));
% % get the indices for this species
% sInd = find([expParam.session.(sprintf('f%dTrained',f)).speciesNum] == speciesOrder(f,phaseCfg.blockSpeciesOrder{b}(s)));
% % shuffle the stimulus index
% randind = randperm(length(sInd));
% % shuffle the exemplars
% thisSpecies = expParam.session.(sprintf('f%dTrained',f))(sInd(randind));
thisSpecies = expParam.session.(sprintf('f%dTrained',f))(sInd);
% sort by exemplar number so they're always in the same order
[~,exemplarInd] = sort([thisSpecies.exemplarNum]);
thisSpecies = thisSpecies(exemplarInd);
% add them to the naming list based on nameIndices
expParam.session.(sesName).(phaseName)(phaseCount).nameStims{b} = cat(1,...
expParam.session.(sesName).(phaseName)(phaseCount).nameStims{b},...
thisSpecies(phaseCfg.nameIndices{b}{s}));
end
end % for each family
end % for each species
% if there are more than X consecutive exemplars from the same
% family, reshuffle for the experiment. There's probably a better way
% to do this but it works.
% naming
fprintf('Shuffling %s name training (%d) task stimuli.\n',sesName,phaseCount);
[expParam.session.(sesName).(phaseName)(phaseCount).nameStims{b}] = et_shuffleStims(...
expParam.session.(sesName).(phaseName)(phaseCount).nameStims{b},'familyNum',phaseCfg.nameMaxConsecFamily);
end % for each block
fprintf('Done.\n');
end % function