KTPsi {OPI} | R Documentation |
An implementation of Kontsevich and Tyler \Psi
algorithm.
Description
An implementation of Kontsevich and Tyler (Vis Res 39 (1999) pages 2729–2737 default parameterised for Standard Automated Perimetry. based on A. Turpin, D. Jankovic and A.M. McKendrick, "Identifying Steep Psychometric Function Slope Quickly in Clinical Applications", Vision Research, 50(23). November 2010. Pages 2476-2485
Usage
KTPsi(
domains = list(slopes = 1:5, thresholds = 20:40, fps = c(0, 0.025, 0.05, 0.1, 0.2), fns
= c(0, 0.025, 0.05, 0.1, 0.2)),
priors = list(slopes = rep(1, length(domains$slopes))/length(domains$slopes),
thresholds = rep(1, length(domains$thresholds))/length(domains$thresholds), fps =
rep(1, length(domains$fps))/length(domains$fps), fns = rep(1,
length(domains$fns))/length(domains$fns)),
stimValues = 17:40,
stopType = "N",
stopValue = 140,
maxPresentations = 200,
minInterStimInterval = NA,
maxInterStimInterval = NA,
verbose = 0,
makeStim,
...
)
KTPsi.start(
domains = list(slopes = 1:5, thresholds = 20:40, fps = c(0, 0.025, 0.05, 0.1, 0.2), fns
= c(0, 0.025, 0.05, 0.1, 0.2)),
priors = list(slopes = rep(1, length(domains$slopes))/length(domains$slopes),
thresholds = rep(1, length(domains$thresholds))/length(domains$thresholds), fps =
rep(1, length(domains$fps))/length(domains$fps), fns = rep(1,
length(domains$fns))/length(domains$fns)),
stimValues = 17:40,
stopType = "N",
stopValue = 140,
maxPresentations = 200,
minInterStimInterval = NA,
maxInterStimInterval = NA,
verbose = 0,
makeStim,
...
)
KTPsi.step(state, nextStim = NULL, fixedStimValue = NA)
KTPsi.final(state, method = "expectation")
KTPsi.stop(state)
Arguments
domains |
A list of 4 vectors:
|
priors |
A list of 4 vectors:
Each prior should the same length as its |
stimValues |
Vector of allowable stimulus values. |
stopType |
|
stopValue |
Value for number of presentations ( |
maxPresentations |
Maximum number of presentations regardless of |
minInterStimInterval |
If both |
maxInterStimInterval |
|
verbose |
|
makeStim |
A function that takes a stimulus value and numPresentations and returns an OPI datatype ready for passing to opiPresent. See examples. |
... |
Extra parameters to pass to the opiPresent function |
state |
Current state of the KTPsi as returned by (eg) |
nextStim |
The next stimulus to present in a suitable format for passing to |
fixedStimValue |
Currently ignored. |
method |
Either |
Details
The assumed psychometric function is the cumulative Gaussian:
\mbox{fp}+(1-\mbox{fp}-\mbox{fn})(1-\mbox{pnorm}(x, \mbox{threshold}, \mbox{slope})
hence domain$slopes
are standard deviations and domain$thresholds
are the mean.
While it is assumed that domains$thresholds
and stimValues
are in dB, this need not be the case.
As long as the makeStim
function converts stimValues
into cd/\mbox{m}^2
for the opiPresent
function, then any units should work.
The checkFixationOK
function is called (if present in stim made from makeStim
)
after each presentation, and if it returns FALSE, the pdf for that state is not changed
(ie the presentation is ignored), but the stim, number of presentations etc is recorded in
the state.
If more than one KTPsi is to be interleaved (for example, testing multiple locations), then thePsi
KTPsi.start
, KTPsi.step
, KTPsi.stop
and KTPsi.final
calls can maintain
the state of the KTPsi after each presentation, and should be used. If only a single KTPsi is
required, then the simpler KTPsi
function can be used, which is a wrapper for the four functions
that maintain state. See examples below.
Value
Single location
KTPsi
returns a list containing
-
npres
Total number of presentations used. -
respSeq
Response sequence stored as a matrix: row 1 is dB values of stimuli, row 2 is 1/0 for seen/not-seen, row 3 is fixated 1/0 (always 1 ifcheckFixationOK
not present in stim objects returned frommakeStim
). -
pdfs
Ifverbose
is bigger than 0, then this is a list of the pdfs used for each presentation, otherwise NULL. -
final
The mean/median/mode of the final pdf, depending onstimChoice
, which is the determined threshold. -
opiResp
A list of responses received from each successful call toopiPresent
withinKTPsi
.
Multilple locations
KTPsi.start
returns a list that can be passed to KTPsi.step
, KTPsi.stop
, and KTPsi.final
. It represents the state of a KTPsi at a single location at a point in time and contains the following.
-
name
KTPsi
A copy of all of the parameters supplied to KTPsi.start:
domains
,priors
,stimValues
,stopType
,stopValue
,maxPresentations
,makeStim
andopiParams
.-
psi
A matrix wherepsi[domain_index, stim]
is the probability of seeingstim
assuming the psychometric function for the domain indexdomain_index
. -
labels
A text representation ofpsi[domain_index, ]
, or the the psychometric function for the domain indexdomain_index
. -
pdf
Current pdf: vector of probabilities the same length as product of lengths ofdomain
elements. -
numPresentations
The number of timesKTPsi.step
has been called on this state. -
stimuli
A vector containing the stimuli used at each call ofKTPsi.step
. -
responses
A vector containing the responses received at each call ofKTPsi.step
. -
responseTimes
A vector containing the response times received at each call ofKTPsi.step
. -
fixated
A vector containing TRUE/FALSE if fixation was OK according tocheckFixationOK
for each call ofKTPsi.step
(defaults to TRUE ifcheckFixationOK
not present). -
opiResp
A list of responses received from each call toopiPresent
withinKTPsi.step
.
KTPsi.step
returns a list containing
-
stat:
The new state after presenting a stimuli and getting a response. -
resp
The return from theopiPresent
call that was made.
KTPsi.stop
returns TRUE
if the KTPsi has reached its stopping criteria, and FALSE
otherwise.
KTPsi.final
returns an estimate of threshold based on state based on its parameter.
TRUE if the state
has reached its stopping criteria, and FALSE otherwise.
References
Kontsevich and Tyler. Vision Research 39 (1999) pages 2729–2737.
A. Turpin, D. Jankovic and A.M. McKendrick, "Identifying Steep Psychometric Function Slope Quickly in Clinical Applications", Vision Research, 50(23). November 2010. Pages 2476-2485
A. Turpin, P.H. Artes and A.M. McKendrick "The Open Perimetry Interface: An enabling tool for clinical visual psychophysics", Journal of Vision 12(11) 2012.
See Also
Examples
chooseOpi("SimGaussian")
if(!is.null(opiInitialize(sd = 2)$err))
stop("opiInitialize failed")
# This section is for single location KTPsi
# Stimulus is Size III white-on-white as in the HFA
makeStim <- function(db, n) {
s <- list(x=9, y=9, level=dbTocd(db), size=0.43, color="white",
duration=200, responseWindow=1500, checkFixationOK=NULL)
class(s) <- "opiStaticStimulus"
return(s)
}
KTPsi(makeStim = makeStim, stopType="H", stopValue= 3, tt=30, fpr=0.03)
KTPsi(makeStim = makeStim, stopType="N", stopValue= 27, verbose = 0, tt=30, fpr=0.03)
# For multiple locations...
## Not run:
states <- lapply(1:10, function(loc) KTPsi.start(makeStim = makeStim))
unfinished <- 1:10
while (length(unfinished) > 0) {
loc <- unfinished[[1]]
states[[loc]] <- KTPsi.step(states[[loc]])$state
if (KTPsi.stop(states[[loc]]))
unfinished <- unfinished[-1]
}
## End(Not run)