Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LNDG
Multi-Attribute-Task
Commits
f3ad63c4
Commit
f3ad63c4
authored
Apr 17, 2020
by
Julian Kosciessa
Browse files
final version OA acquisition; timestamp 171205
parent
db90d6c8
Changes
181
Expand all
Show whitespace changes
Inline
Side-by-side
A_preRandomizeTaskDataforEEG_171206.m
0 → 100644
View file @
f3ad63c4
% Pre-create the experimental information to load during the experiment.
% 171206 adapted from MR version to EEG for older adults
%% initialize
if
ispc
pn
.
root
=
[
'C:'
,
filesep
,
'Users'
,
filesep
,
'eeg'
,
filesep
,
'Desktop'
,
filesep
,
'StateSwitchEEG_OA'
,
filesep
,
'C_Paradigm_171205'
,
filesep
];
else
disp
(
'Setup no supported.'
);
end
pn
.
SS
=
[
pn
.
root
,
'StateSwitch'
,
filesep
];
addpath
(
pn
.
SS
);
addpath
(
genpath
([
pn
.
root
,
'functions'
,
filesep
]));
addpath
(
genpath
([
pn
.
root
,
'helper'
,
filesep
]));
if
ispc
addpath
([
'C:'
,
filesep
,
'toolbox'
,
filesep
,
'Psychtoolbox'
]);
% PTB 3.0.11
else
addpath
(
genpath
(
'/Users/Shared/Psychtoolbox/'
));
% PTB 3.0.13 (160606)
end
if
ispc
Screen
(
'Preference'
,
'SkipSyncTests'
,
0
);
else
Screen
(
'Preference'
,
'SkipSyncTests'
,
1
);
oldLevel
=
Screen
(
'Preference'
,
'Verbosity'
,
4
);
% output debugging info
PsychDebugWindowConfiguration
(
0
,
0.3
)
end
%% pre-randomize data for MR experiment
for
ind1
=
1
:
4
for
ind2
=
1
:
2
for
ind3
=
1
:
99
if
numel
(
num2str
(
ind3
))
==
1
ind3_conv
=
[
'0'
,
num2str
(
ind3
)];
else
ind3_conv
=
num2str
(
ind3
);
end
ID
=
[
num2str
(
ind1
),
num2str
(
ind2
),
ind3_conv
];
disp
(
ID
);
% create randomization
expInfo
=
[];
expInfo
=
eval
([
'StateSwitch_createExpInfo_dynamic_170922'
]);
% save randomization
save
([
pn
.
root
,
'expInfo_EEG/'
,
ID
,
'_expInfo.mat'
],
'expInfo'
);
end
end
end
functions/mintersect.m
deleted
100644 → 0
View file @
db90d6c8
function
runIntersect
=
mintersect
(
varargin
)
%MINTERSECT Multiple set intersection.
% MINTERSECT(A,B,C,...) when A,B,C... are vectors returns the values
% common to all A,B,C... The result will be sorted. A,B,C... can be cell
% arrays of strings.
%
% MINTERSECT repeatedly evaluates INTERSECT on successive pairs of sets,
% which may not be very efficient. For a large number of sets, this should
% probably be reimplemented using some kind of tree algorithm.
%
% MINTERSECT(A,B,'rows') when A,B,C... are matrices with the same
% number of columns returns the rows common to all A,B,C...
%
% See also INTERSECT
flag
=
0
;
if
isempty
(
varargin
),
error
(
'No inputs specified.'
)
else
if
isequal
(
varargin
{
end
},
'rows'
),
flag
=
'rows'
;
setArray
=
varargin
(
1
:
end
-
1
);
else
setArray
=
varargin
;
end
end
runIntersect
=
setArray
{
1
};
for
i
=
2
:
length
(
setArray
),
if
isequal
(
flag
,
'rows'
),
runIntersect
=
intersect
(
runIntersect
,
setArray
{
i
},
'rows'
);
elseif
flag
==
0
,
runIntersect
=
intersect
(
runIntersect
,
setArray
{
i
});
else
error
(
'Flag not set.'
)
end
if
isempty
(
runIntersect
),
return
end
end
functions/palamedes1_8_2.zip
deleted
100644 → 0
View file @
db90d6c8
File deleted
functions/palamedes1_8_2/Palamedes/History.m
deleted
100644 → 0
View file @
db90d6c8
This diff is collapsed.
Click to expand it.
functions/palamedes1_8_2/Palamedes/PAL_AMPM_CreateLUT.m
deleted
100644 → 0
View file @
db90d6c8
%
%PAL_AMPM_CreateLUT Look-up Table (LUT) of Psychometric Function values
%
% syntax: PFLookUpTable = PAL_AMPM_CreateLUT(priorAlphaValues, ...
% priorBetaValues, priorGammaValues, priorLambdaValues, ...
% StimLevels, PF, gammaEQlambda)
%
% Creates a 5-D (alpha x beta x gamma x lambda x stimulus intensity)
% array of PF values.
%
%Internal function
%
%Introduced: Palamedes version 1.0.0 (NP)
%Modified: Palamedes version 1.2.0, 1.5.0, 1.6.0, 1.6.3 (see History.m)
function
PFLookUpTable
=
PAL_AMPM_CreateLUT
(
priorAlphaValues
,
priorBetaValues
,
priorGammaValues
,
priorLambdaValues
,
StimLevels
,
PF
,
gammaEQlambda
)
[
a
,
b
,
g
,
l
,
x
]
=
ndgrid
(
priorAlphaValues
,
priorBetaValues
,
priorGammaValues
,
priorLambdaValues
,
StimLevels
);
params
.
alpha
=
a
;
params
.
beta
=
10.
^
b
;
params
.
gamma
=
g
;
params
.
lambda
=
l
;
if
gammaEQlambda
params
.
gamma
=
l
;
end
PFLookUpTable
=
PF
(
params
,
x
);
\ No newline at end of file
functions/palamedes1_8_2/Palamedes/PAL_AMPM_PosteriorTplus1.m
deleted
100644 → 0
View file @
db90d6c8
%
%PAL_AMPM_PosteriorTplus1 Derives posterior distributions for combinations
% of stimulus intensity and response on trial T + 1 in psi method
% adaptive procedure.
%
% syntax: [PosteriorTplus1givenSuccess PosteriorTplus1givenFailure ...
% pSuccessGivenx] = PAL_AMPM_PosteriorTplus1(pdf, PFLookUpTable)
%
% Internal function
%
%Introduced: Palamedes version 1.0.0 (NP)
%Modified: Palamedes version 1.5.0, 1.6.1, 1.6.3 (see History.m)
function
[
PosteriorTplus1givenSuccess
,
PosteriorTplus1givenFailure
,
pSuccessGivenx
]
=
PAL_AMPM_PosteriorTplus1
(
pdf
,
PFLookUpTable
)
pdf5D
=
repmat
(
pdf
,
[
1
1
1
1
size
(
PFLookUpTable
,
5
)]);
pSuccessGivenx
=
sum
(
sum
(
sum
(
sum
(
pdf5D
.*
PFLookUpTable
,
1
),
2
),
3
),
4
);
PosteriorTplus1givenSuccess
=
pdf5D
.*
PFLookUpTable
;
PosteriorTplus1givenFailure
=
pdf5D
-
PosteriorTplus1givenSuccess
;
if
exist
(
'bsxfun.m'
,
'file'
)
PosteriorTplus1givenSuccess
=
bsxfun
(
@
rdivide
,
PosteriorTplus1givenSuccess
,
sum
(
sum
(
sum
(
sum
(
PosteriorTplus1givenSuccess
,
1
),
2
),
3
),
4
));
PosteriorTplus1givenFailure
=
bsxfun
(
@
rdivide
,
PosteriorTplus1givenFailure
,
sum
(
sum
(
sum
(
sum
(
PosteriorTplus1givenFailure
,
1
),
2
),
3
),
4
));
else
Denominator
=
squeeze
(
sum
(
sum
(
sum
(
sum
(
PosteriorTplus1givenSuccess
,
1
),
2
),
3
),
4
));
Denominator
=
repmat
(
Denominator
,
[
1
size
(
pdf5D
,
1
)
size
(
pdf5D
,
2
)
size
(
pdf5D
,
3
)
size
(
pdf5D
,
4
)]);
Denominator
=
permute
(
Denominator
,
[
2
3
4
5
1
]);
PosteriorTplus1givenSuccess
=
PosteriorTplus1givenSuccess
.
/
Denominator
;
Denominator
=
squeeze
(
sum
(
sum
(
sum
(
sum
(
PosteriorTplus1givenFailure
,
1
),
2
),
3
),
4
));
Denominator
=
repmat
(
Denominator
,
[
1
size
(
pdf5D
,
1
)
size
(
pdf5D
,
2
)
size
(
pdf5D
,
3
)
size
(
pdf5D
,
4
)]);
Denominator
=
permute
(
Denominator
,
[
2
3
4
5
1
]);
PosteriorTplus1givenFailure
=
PosteriorTplus1givenFailure
.
/
Denominator
;
end
\ No newline at end of file
functions/palamedes1_8_2/Palamedes/PAL_AMPM_expectedEntropy.m
deleted
100644 → 0
View file @
db90d6c8
%
%PAL_AMPM_expectedEntropy expected entropy values for different stimulus
% intensities.
%
% syntax: [PM expectedEntropy] = PAL_AMPM_expectedEntropy(PM,varargin)
%
%Internal function
%
%Introduced: Palamedes version 1.6.0 (NP)
%Modified: Palamedes version 1.6.1, 1.6.3 (see History.m)
function
[
PM
,
expectedEntropy
]
=
PAL_AMPM_expectedEntropy
(
PM
,
varargin
)
fixLapse
=
false
;
valid
=
0
;
if
~
isempty
(
varargin
)
if
strncmpi
(
varargin
{
1
},
'fixL'
,
4
)
fixLapse
=
varargin
{
2
};
valid
=
1
;
end
if
valid
==
0
warning
(
'PALAMEDES:invalidOption'
,
'%s is not a valid option. Ignored.'
,
varargin
{
1
})
end
end
[
PM
.
posteriorTplus1givenSuccess
,
PM
.
posteriorTplus1givenFailure
,
pSuccessGivenx
]
=
PAL_AMPM_PosteriorTplus1
(
PM
.
pdf
,
PM
.
LUT
);
if
fixLapse
tempSuccess
=
zeros
(
size
(
PM
.
posteriorTplus1givenSuccess
(:,:,:,
1
,:)));
tempFailure
=
zeros
(
size
(
PM
.
posteriorTplus1givenSuccess
(:,:,:,
1
,:)));
[
trash
,
I
]
=
PAL_findMax
(
PM
.
pdf
);
for
SR
=
1
:
length
(
PM
.
stimRange
)
tempSuccess
(:,:,:,:,
SR
)
=
PM
.
posteriorTplus1givenSuccess
(:,:,:,
I
(
4
),
SR
)
.
/
sum
(
sum
(
sum
(
sum
(
sum
(
PM
.
posteriorTplus1givenSuccess
(:,:,:,
I
(
4
),
SR
))))));
tempFailure
(:,:,:,:,
SR
)
=
PM
.
posteriorTplus1givenFailure
(:,:,:,
I
(
4
),
SR
)
.
/
sum
(
sum
(
sum
(
sum
(
sum
(
PM
.
posteriorTplus1givenFailure
(:,:,:,
I
(
4
),
SR
))))));
end
expectedEntropy
=
PAL_Entropy
(
tempSuccess
,
4
,
PM
.
marginalize
)
.*
pSuccessGivenx
+
PAL_Entropy
(
tempFailure
,
4
,
PM
.
marginalize
)
.*
(
1
-
pSuccessGivenx
);
else
expectedEntropy
=
PAL_Entropy
(
PM
.
posteriorTplus1givenSuccess
,
4
,
PM
.
marginalize
)
.*
pSuccessGivenx
+
PAL_Entropy
(
PM
.
posteriorTplus1givenFailure
,
4
,
PM
.
marginalize
)
.*
(
1
-
pSuccessGivenx
);
end
\ No newline at end of file
functions/palamedes1_8_2/Palamedes/PAL_AMPM_setupPM.m
deleted
100644 → 0
View file @
db90d6c8
%
%PAL_AMPM_setupPM Creates structure which contains settings for and
% results of Kontsevich & Tyler's (1999) psi adaptive method and
% variations on it (see Prins (2013) or
% www.palamedestoolbox.org/psimarginal.html)
%
% syntax: PM = PAL_AMPM_setupPM({optional arguments})
%
% PM = PAL_AMPM_setupPM creates and returns a structure containing
% settings for the psi method adaptive method using default settings.
%
% Default settings may be changed by providing pairwise arguments, where
% the first entry of the pair is a string indicating the field to be
% changed and the second entry provides the new value of the field.
% Modifiable fields and settings (default values in curly brackets):
%
% 'priorAlphaRange' vector {[-2:.05:2]}
% Vector containing values of threshold to be considered in posterior
% distribution.
%
% 'priorBetaRange' vector {[-1:.05:1]}
% Vector containing log (base 10) transformed values of slope to be
% considered in posterior distribution.
%
% 'priorGammaRange' scalar or vector {[.5]}
% Vector containing values of threshold to be considered in posterior
% distribution.
%
% 'priorLambdaRange' scalar or vector {[.02]}
% Vector containing values of threshold to be considered in posterior
% distribution.
%
% 'stimRange' vector {[-1:.1:1]}
% Possible stimulus values to be considered on each trial.
%
% 'prior' matrix {uniform}
% prior should have size: length(priorAlphaRange) x
% length(priorBetaRange) x length(priorGammaRange) x
% length(priorLambdaRange)
% But: Trailing singleton dimensions are ignored, e.g., if
% length(priorGammaRange) and length(priorLambdaRange) are both 1,
% prior is of size: length(priorAlphaRange) x length(priorBetaRange).
% User can specify a prior distribution using this option. For
% example of use, see PAL_AMPM_Demo.
%
% 'PF' inline function {@PAL_Gumbel}
% Form of psychometric function to be assumed by Psi method.
%
% 'numTrials' positive integer {50}
% Length of run in terms of number of trials
%
% 'gammaEQlambda' logical {false}
% When gammaEQlambda is set to true, gamma and lambda are both
% assumed to result from lapses. Any entry for 'priorGammaRange' will
% be ignored. Since it is assumed that gamma = lambda, a single
% parameter will be estimated for both, the prior used will be that
% set for 'priorLambdaRange'.
%
% 'marginalize' vector {[]} (or string)
% Allows users to marginalize parameters out of the posterior
% distribution before the to-be-minimized expected entropy is
% calculated. This allows one to include, say, the lapse rate in the
% posterior distribution without the method having the explicit goal
% of minimizing entropy with respect to the lapse rate. Roughly
% speaking, marginalized parameters will be estimated only insofar as
% doing so is the most optimal manner in which to reduce entropy in
% the non-marginalized parameters in the posterior distribution.
% To marginalize parameters, pass the string 'threshold', 'slope',
% 'guess', or 'lapse' after the string 'marginalize'. To marginalize
% more than one parameter, repeatedly call PAIR of arguments (e.g.,
% 'marginalize', 'lapse','marginalize','guess'). Parameters to be
% marginalized may also be specified by passing a vector
% containing a numerical code for each of the parameters to be added
% to marginalize list (1: threshold, 2: slope, 3: guess rate, 4:
% lapse rate). In order to remove a parameter from the list of to be
% marginalized parameters, use the negative symbol (i.e., -). For
% example, the call PM = PAL_AMPM_setupPM(PM,'marginalize',
% '-threshold') removes the threshold from PM's marginalize list (if
% it was indeed on there). PM = PAL_AMPM_setupPM(PM,'marginalize',
% [-1]) does the same. Example 2: The call: PM =
% PAL_AMPM_setupPM(PM,'marginalize',[-1 2 3 -4]) will result in the
% slope and guess rate to be marginalized, while the threshold and
% lapse rate will not be marginalized, whatever the previous
% marginalize list was. In order to delete all previous entries, pass
% empty vector. Note that parameters may be added to or removed from
% list at any point during a trial run. For more information see:
% www.palamedestoolbox.org/psimarginal.html
%
% Example: PM = PAL_AMPM_setupPM('numTrials',100, 'PriorLambdaRange', ...
% [0:.01:.1],'marginalize','lapse') creates a new structure using default
% settings for all fields except numTrials, priorLambdaRange, and
% marginalize. Setting 'PriorLambdaRange' to [0:.01:.1] will mean the
% method will include the lapse rate as a third dimension in the
% posterior distribution. Marginalizing the lapse rate means that on each
% trial the Psi method will place the stimulus such as to minimize
% expected entropy in the posterior across threshold and slope with the
% lapse rate marginalized.
%
%
% In order to change settings in an existing structure, pass the existing
% structure as the first argument. For example, given an existing
% structure 'PM' the call:
% PM = PAL_AMPM_setupPM(PM, 'gamma',.25)
% changes the field gamma in the existing structure 'PM' to .25 without
% affecting other settings in existing structure 'PM.'.
%
% PM's result storage fields:
%
% 'PM.x' stores stimulus intensities for all trials
% 'PM.response' stores responses for all trials (positive (correct,
% 'greater than'): 1, negative: 0)
% 'PM.pdf' stores posterior distribution
% 'PM.threshold' stores threshold estimates after each trial (marginal
% expected value of alpha in posterior)
% 'PM.slope' stores log slope estimates after each trial (marginal
% expected value of log beta in posterior)
% 'PM.guess' stores guess rate estimates after each trial (marginal
% expected value of gamma in posterior)
% 'PM.lapse' stores lapse rate estimates after each trial (marginal
% expected value of lambda in posterior)
% 'PM.seThreshold' stores standard error of threshold estimate (marginal
% standard deviation of alpha in posterior).
% 'PM.seSlope' stores standard error of log slope estimate (marginal
% standard deviation of log beta in posterior).
% 'PM.seGuess' stores standard error of guess rate estimate (marginal
% standard deviation of log beta in posterior).
% 'PM.seLapse' stores standard error of lapse rate estimate (marginal
% standard deviation of log beta in posterior).
% 'PM.thresholdUniformPrior', 'PM.slopeUniformPrior',
% 'PM.guessUniformPrior', 'PM.lapseUniformPrior',
% 'PM.seThresholdUniformPrior', 'PM.seSlopeUniformPrior',
% 'PM.seGuessUniformPrior', and 'PM.seLapseUniformPrior' ignore
% user-defined prior and determine estimates using a uniform prior
% instead.
% 'PM.stop' is used as termination flag. While stop criterion has not
% been reached, 'PM.stop' will equal 0, when criterion is reached,
% 'PM.stop' will be set to 1.
%
% References:
%
% Kontsevich, L.L. & Tyler, C.W. (1999). Bayesian adaptive estimation of
% psychometric slope and threshold. Vision Research, 39, 2729�2737.
%
% Prins, N. (2013). The psi-marginal adaptive method: how to give nuisance
% parameters the attention they deserve (no more, no less). Journal of
% Vision, 13(7):3, 1-17. doi: 10.1167/13.7.3
%
% Introduced: Palamedes version 1.0.0 (NP)
% Modified: Palamedes version 1.1.1, 1.2.0, 1.4.0, 1.5.0, 1.6.0, 1.6.1,
% 1.6.3, 1.8.2 (see History.m)
function
PM
=
PAL_AMPM_setupPM
(
varargin
)
NumOpts
=
length
(
varargin
);
message
=
'As of Palamedes 1.5.0, alpha values vary across rows and beta values vary '
;
message
=
[
message
'across columns of a 2-D (alpha x beta) PM.pdf (in earlier versions this was '
];
message
=
[
message
'vice versa). This will affect behavior of code written for previous versions '
];
message
=
[
message
'ONLY if a user-supplied prior was used and/or if code performed operations '
];
message
=
[
message
'on PM.pdf (e.g., if PM.pdf was plotted using for example
''
surf
''
). Code written for '
];
message
=
[
message
'earlier versions of Palamedes can be made compatible simply '
];
message
=
[
message
'by transposing any user-supplied prior (i.e., prior = prior
''
;) before passing it to '
];
message
=
[
message
'PAL_AMPM_setupPM and transposing PM.pdf before plotting it '
];
message
=
[
message
'(e.g., surf(PM.pdf
''
) instead of surf(PM.pdf)). Visit '
];
message
=
[
message
'www.palamedestoolbox.org/pal_ampm_incompatibility.html.'
];
warning
(
'PALAMEDES:AMPM_setupPM:priorTranspose'
,
message
);
warning
(
'off'
,
'PALAMEDES:AMPM_setupPM:priorTranspose'
);
if
mod
(
NumOpts
,
2
)
==
0
PM
.
priorAlphaRange
=
-
2
:
.
05
:
2
;
PM
.
priorBetaRange
=
-
1
:
.
05
:
1
;
PM
.
priorGammaRange
=
0.5
;
PM
.
priorLambdaRange
=
0.02
;
PM
.
gammaEQlambda
=
logical
(
false
);
PM
.
stimRange
=
-
1
:
.
1
:
1
;
[
PM
.
priorAlphas
,
PM
.
priorBetas
,
PM
.
priorGammas
,
PM
.
priorLambdas
]
=
ndgrid
(
PM
.
priorAlphaRange
,
PM
.
priorBetaRange
,
PM
.
priorGammaRange
,
PM
.
priorLambdaRange
);
PM
.
PF
=
@
PAL_Gumbel
;
PM
.
LUT
=
PAL_AMPM_CreateLUT
(
PM
.
priorAlphaRange
,
PM
.
priorBetaRange
,
PM
.
priorGammaRange
,
PM
.
priorLambdaRange
,
PM
.
stimRange
,
PM
.
PF
,
PM
.
gammaEQlambda
);
PM
.
prior
=
ones
(
size
(
PM
.
priorAlphas
));
PM
.
prior
=
PM
.
prior
.
/
sum
(
sum
(
sum
(
sum
(
PM
.
prior
))));
PM
.
pdf
=
PM
.
prior
;
[
PM
.
posteriorTplus1givenSuccess
,
PM
.
posteriorTplus1givenFailure
,
pSuccessGivenx
]
=
PAL_AMPM_PosteriorTplus1
(
PM
.
pdf
,
PM
.
LUT
);
ExpectedEntropy
=
PAL_Entropy
(
PM
.
posteriorTplus1givenSuccess
,
4
)
.*
pSuccessGivenx
+
PAL_Entropy
(
PM
.
posteriorTplus1givenFailure
,
4
)
.*
(
1
-
pSuccessGivenx
);
[
minEntropy
,
PM
.
I
]
=
min
(
squeeze
(
ExpectedEntropy
));
PM
.
xCurrent
=
PM
.
stimRange
(
PM
.
I
);
PM
.
x
=
PM
.
xCurrent
;
PM
.
numTrials
=
50
;
PM
.
response
=
[];
PM
.
stop
=
0
;
PM
.
marginalize
=
[];
else
PM
=
varargin
{
1
};
end
PM
.
firstsession
=
length
(
PM
.
x
)
==
1
;
if
NumOpts
>
1
opts
(
1
)
=
cellstr
(
'priorAlphaRange'
);
opts
(
2
)
=
cellstr
(
'priorBetaRange'
);
opts
(
3
)
=
cellstr
(
'priorGammaRange'
);
opts
(
4
)
=
cellstr
(
'priorLambdaRange'
);
opts
(
5
)
=
cellstr
(
'stimRange'
);
opts
(
6
)
=
cellstr
(
'prior'
);
opts
(
7
)
=
cellstr
(
'PF'
);
opts
(
8
)
=
cellstr
(
'numTrials'
);
opts
(
9
)
=
cellstr
(
'gamma'
);
%for compatibility with older usage
opts
(
10
)
=
cellstr
(
'lambda'
);
%for compatibility with older usage
opts
(
11
)
=
cellstr
(
'gammaEQlambda'
);
opts
(
12
)
=
cellstr
(
'marginalize'
);
supplied
=
logical
(
false
(
size
(
opts
)));
for
n
=
1
:
2
:
NumOpts
-
mod
(
NumOpts
,
2
)
n
=
n
+
mod
(
NumOpts
,
2
);
valid
=
0
;
if
strncmpi
(
varargin
{
n
},
opts
(
1
),
6
)
PM
.
priorAlphaRange
=
varargin
{
n
+
1
};
valid
=
1
;
supplied
(
1
)
=
true
;
end
if
strncmpi
(
varargin
{
n
},
opts
(
2
),
6
)
PM
.
priorBetaRange
=
varargin
{
n
+
1
};
valid
=
1
;
supplied
(
2
)
=
true
;
end
if
strncmpi
(
varargin
{
n
},
opts
(
3
),
6
)
||
(
strncmpi
(
varargin
{
n
},
opts
(
9
),
5
)
&&
~
strncmpi
(
varargin
{
n
},
opts
(
11
),
6
))
PM
.
priorGammaRange
=
varargin
{
n
+
1
};
valid
=
1
;
supplied
(
3
)
=
true
;
end
if
strncmpi
(
varargin
{
n
},
opts
(
4
),
6
)
||
strncmpi
(
varargin
{
n
},
opts
(
10
),
5
)
PM
.
priorLambdaRange
=
varargin
{
n
+
1
};
valid
=
1
;
supplied
(
4
)
=
true
;
end
if
strncmpi
(
varargin
{
n
},
opts
(
5
),
4
)
PM
.
stimRange
=
varargin
{
n
+
1
};
valid
=
1
;
supplied
(
5
)
=
true
;
end
if
strcmpi
(
varargin
{
n
},
opts
(
6
))
PM
.
prior
=
varargin
{
n
+
1
};
PM
.
prior
=
PM
.
prior
.
/
sum
(
sum
(
sum
(
sum
(
PM
.
prior
))));
PM
.
pdf
=
PM
.
prior
;
valid
=
1
;
supplied
(
6
)
=
true
;
end
if
strcmpi
(
varargin
{
n
},
opts
(
7
))
PM
.
PF
=
varargin
{
n
+
1
};
valid
=
1
;
supplied
(
7
)
=
true
;
end
if
strncmpi
(
varargin
{
n
},
opts
(
8
),
4
)
PM
.
numTrials
=
varargin
{
n
+
1
};
valid
=
1
;
supplied
(
8
)
=
true
;
end
if
strncmpi
(
varargin
{
n
},
opts
(
11
),
6
)
PM
.
gammaEQlambda
=
logical
(
varargin
{
n
+
1
});
valid
=
1
;
supplied
(
11
)
=
true
;
end
if
strncmpi
(
varargin
{
n
},
opts
(
12
),
6
)
switch
PAL_whatIs
(
varargin
{
n
+
1
})
case
0
PM
.
marginalize
=
[];
case
1
for
index
=
1
:
length
(
varargin
{
n
+
1
})
if
varargin
{
n
+
1
}(
index
)
>
0
&&
isempty
(
find
(
PM
.
marginalize
==
varargin
{
n
+
1
}(
index
)))
PM
.
marginalize
=
[
PM
.
marginalize
varargin
{
n
+
1
}(
index
)];
end
if
varargin
{
n
+
1
}(
index
)
<
0
PM
.
marginalize
=
PM
.
marginalize
(
PM
.
marginalize
~=
abs
(
varargin
{
n
+
1
}(
index
)));
end
end
case
2
if
strncmpi
(
varargin
{
n
+
1
},
'threshold'
,
5
)
&&
isempty
(
find
(
PM
.
marginalize
==
1
))
PM
.
marginalize
=
[
PM
.
marginalize
1
];
end
if
strncmpi
(
varargin
{
n
+
1
},
'slope'
,
5
)
&&
isempty
(
find
(
PM
.
marginalize
==
2
))
PM
.
marginalize
=
[
PM
.
marginalize
2
];
end
if
strncmpi
(
varargin
{
n
+
1
},
'guess'
,
5
)
&&
isempty
(
find
(
PM
.
marginalize
==
3
))
PM
.
marginalize
=
[
PM
.
marginalize
3
];
end
if
strncmpi
(
varargin
{
n
+
1
},
'lapse'
,
5
)
&&
isempty
(
find
(
PM
.
marginalize
==
4
))
PM
.
marginalize
=
[
PM
.
marginalize
4
];
end
if
strncmpi
(
varargin
{
n
+
1
},
'-threshold'
,
5
)
PM
.
marginalize
=
PM
.
marginalize
(
PM
.
marginalize
~=
1
);
end
if
strncmpi
(
varargin
{
n
+
1
},
'-slope'
,
5
)
PM
.
marginalize
=
PM
.
marginalize
(
PM
.
marginalize
~=
2
);
end
if
strncmpi
(
varargin
{
n
+
1
},
'-guess'
,
5
)
PM
.
marginalize
=
PM
.
marginalize
(
PM
.
marginalize
~=
3
);
end
if
strncmpi
(
varargin
{
n
+
1
},
'-lapse'
,
5
)
PM
.
marginalize
=
PM
.
marginalize
(
PM
.
marginalize
~=
4
);
end
end
valid
=
1
;
supplied
(
12
)
=
true
;
end
if
valid
==
0
warning
(
'PALAMEDES:invalidOption'
,
'%s is not a valid option. Ignored.'
,
varargin
{
n
});
end
end
if
PM
.
gammaEQlambda
==
true
;
PM
.
priorGammaRange
=
0
;
%value will be ignored
end
if
supplied
(
1
)
||
supplied
(
2
)
||
supplied
(
3
)
||
supplied
(
4
)
[
PM
.
priorAlphas
,
PM
.
priorBetas
,
PM
.
priorGammas
,
PM
.
priorLambdas
]
=
ndgrid
(
PM
.
priorAlphaRange
,
PM
.
priorBetaRange
,
PM
.
priorGammaRange
,
PM
.
priorLambdaRange
);
if
~
supplied
(
6
)
PM
.
prior
=
ones
(
size
(
PM
.
priorAlphas
));
PM
.
prior
=
PM
.
prior
.
/
sum
(
sum
(
sum
(
sum
(
PM
.
prior
))));
if
PM
.
firstsession
==
1
%First session. Otherwise keep going with existing PM.pdf
PM
.
pdf
=
PM
.
prior
;
end
end
end
if
supplied
(
1
)
||
supplied
(
2
)
||
supplied
(
3
)
||
supplied
(
4
)
||
supplied
(
5
)
||
supplied
(
6
)
||
supplied
(
7
)
||
supplied
(
12
)
PM
.
LUT
=
PAL_AMPM_CreateLUT
(
PM
.
priorAlphaRange
,
PM
.
priorBetaRange
,
PM
.
priorGammaRange
,
PM
.
priorLambdaRange
,
PM
.
stimRange
,
PM
.
PF
,
PM
.
gammaEQlambda
);
[
PM
,
expectedEntropy
]
=
PAL_AMPM_expectedEntropy
(
PM
);
[
minEntropy
,
PM
.
I
]
=
min
(
squeeze
(
expectedEntropy
));
PM
.
xCurrent
=
PM
.
stimRange
(
PM
.
I
);
PM
.
x
(
length
(
PM
.
x
))
=
PM
.
xCurrent
;
end
if
PM
.
firstsession
==
1
PM
.
x
(
1
)
=
PM
.
xCurrent
;
end
end
if
PM
.
firstsession
==
1
PM
.
threshold
=
[];
PM
.
slope
=
[];
PM
.
guess
=
[];
PM
.
lapse
=
[];
PM
.
seThreshold
=
[];
PM
.
seSlope
=
[];
PM
.
seGuess
=
[];
PM
.
seLapse
=
[];
PM
.
thresholdUniformPrior
=
[];
PM
.
slopeUniformPrior
=
[];
PM
.
guessUniformPrior
=
[];
PM
.
lapseUniformPrior
=
[];
PM
.
seThresholdUniformPrior
=
[];
PM
.
seSlopeUniformPrior
=
[];
PM
.
seGuessUniformPrior
=
[];
PM
.
seLapseUniformPrior
=
[];
end
\ No newline at end of file
functions/palamedes1_8_2/Palamedes/PAL_AMPM_updatePM.m
deleted
100644 → 0
View file @
db90d6c8
%
%PAL_AMPM_updatePM Updates structure which contains settings for and
% results of psi method adaptive method (see also PAL_AMPM_setupPM).
%
% syntax: PM = PAL_AMPM_updatePM(PM,response,{optional argument})
%
%After having created a structure 'PM' using PAL_AMPM_setupPM, use
% something akin to the following loop to control stimulus intensity
% during experimental run:
%
% while ~PM.stop
%
% %Present trial here at stimulus magnitude in 'PM.xCurrent'
% %and collect response (1: correct/greater than, 0: incorrect/
% %smaller than)
%