fit_MRMC: Fit and Draw the FROC models (curves)

Description Usage Arguments

View source: R/fit_Bayesian_FROC.R

Description

Fit and Draw the FROC models (curves).

Usage

 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
fit_MRMC(
  dataList,
  DrawCurve = FALSE,
  type_to_be_passed_into_plot = "p",
  verbose = TRUE,
  print_CI_of_AUC = TRUE,
  PreciseLogLikelihood = FALSE,
  summary = TRUE,
  dataList.Name = "",
  prior = 1,
  ModifiedPoisson = TRUE,
  mesh.for.drawing.curve = 10000,
  significantLevel = 0.7,
  cha = 1,
  war = floor(ite/5),
  ite = 10000,
  dig = 3,
  see = 1234569,
  Null.Hypothesis = FALSE,
  prototype = FALSE,
  model_reparametrized = FALSE,
  Model_MRMC_non_hierarchical = TRUE,
  ww = -0.81,
  www = 0.001,
  mm = 0.65,
  mmm = 0.001,
  vv = 5.31,
  vvv = 0.001,
  zz = 1.55,
  zzz = 0.001,
  ...
)

Arguments

dataList

A list, specifying an FROC data to be fitted a model. It consists of data of numbers of TPs, FPs, lesions, images. .In addition, if in case of mutiple readers or mutiple modalities, then modaity ID and reader ID are included also.

The dataList will be passed to the function rstan::sampling() of rstan. This is a variable in the function rstan::sampling() in which it is named data.

For the single reader and a single modality data, the dataList is made by the following manner:

dataList.Example <- list(

h = c(41,22,14,8,1), # number of hits for each confidence level

f = c(1,2,5,11,13), # number of false alarms for each confidence level

NL = 124, # number of lesions (signals)

NI = 63, # number of images (trials)

C = 5) # number of confidence, .. the author thinks it can be calculated as the length of h or f ...? ha, why I included this. ha .. should be omitted.

Using this object dataList.Example, we can apply fit_Bayesian_FROC() such as fit_Bayesian_FROC(dataList.Example).

To make this R object dataList representing FROC data, this package provides three functions:

dataset_creator_new_version()

Enter TP and FP data by table .

create_dataset()

Enter TP and FP data by interactive manner.

Before fitting a model, we can confirm our dataset is correctly formulated by using the function viewdata().

—————————————————————————————-

A Single reader and a single modality (SRSC) case.

—————————————————————————————-

In a single reader and a single modality case (srsc), dataList is a list consisting of f, h, NL, NI, C where f, h are numeric vectors and NL, NI, C are positive integers.

f

Non-negative integer vector specifying number of false alarms associated with each confidence level. The first component corresponding to the highest confidence level.

h

Non-negative integer vector specifying number of Hits associated with each confidence level. The first component corresponding to the highest confidence level.

NL

A positive integer, representing Number of Lesions.

NI

A positive integer, representing Number of Images.

C

A positive integer, representing Number of Confidence level.

The detail of these dataset, see the datasets endowed with this package. 'Note that the maximal number of confidence level, denoted by C, are included, however, Note that confidence level vector c should not be specified. If specified, will be ignored , since it is created by c <-c(rep(C:1)) in the inner program and do not refer from user input data, where C is the highest number of confidence levels. So, you should write down your hits and false alarms vector so that it is compatible with this automatically created c vector.

data Format:

A single reader and a single modality case

——————————————————————————————————

NI=63,NL=124 confidence level No. of false alarms No. of hits
In R console -> c f h
----------------------- ----------------------- ----------------------------- -------------
definitely present c[1] = 5 f[1] = F_5 = 1 h[1] = H_5 = 41
probably present c[2] = 4 f[2] = F_4 = 2 h[2] = H_4 = 22
equivocal c[3] = 3 f[3] = F_3 = 5 h[3] = H_3 = 14
subtle c[4] = 2 f[4] = F_2 = 11 h[4] = H_2 = 8
very subtle c[5] = 1 f[5] = F_1 = 13 h[5] = H_1 = 1

—————————————————————————————————

* false alarms = False Positives = FP

* hits = True Positives = TP

Note that in FROC data, all confidence level means present (diseased, lesion) case only, no confidence level indicating absent. Since each reader marks his suspicious location only if he thinks lesions are present, and marked positions generates the hits or false alarms, thus each confidence level represents that lesion is present. In the absent case, reader does not mark any locations and hence, the absent confidence level does not relate this dataset. So, if reader think it is no lesion, then in such case confidence level is not needed.

Note that the first column of confidence level vector c should not be specified. If specified, will be ignored , since it is created by c <-c(rep(C:1)) automatically in the inner program and do not refer from user input data even if it is specified explicitly, where C is the highest number of confidence levels. So you should check the compatibility of your data and the confidence level vector c <-c(rep(C:1)) via a table which can be displayed by the function viewdata().

—————————————————————————————

Multiple readers and multiple modalities case, i.e., MRMC case

—————————————————————————————

In case of multiple readers and multiple modalities, i.e., MRMC case, in order to apply the function fit_Bayesian_FROC(), dataset represented by an R list object representing FROC data must contain components m,q,c,h,f,NL,C,M,Q.

C

A positive integer, representing the highest number of confidence level, this is a scalar.

M

A positive integer vector, representing the number of modalities.

Q

A positive integer, representing the number of readers.

m

A vector of positive integers, representing the modality ID vector.

q

A vector of positive integers, representing the reader ID vector.

c

A vector of positive integers, representing the confidence level. This vector must be made by rep(rep(C:1), M*Q)

h

A vector of non-negative integers, representing the number of hits.

f

A vector of non-negative integers, representing the number of false alarms.

NL

A positive integer, representing the Total number of lesions for all images, this is a scalar.

Note that the maximal number of confidence level (denoted by C) are included in the above R object. However, each confidence level vector is not included in the data, because it is created automatically from C. To confirm false positives and hits are correctly ordered with respect to the automatically generated confidence vector,

the function viewdata() shows the table. Revised 2019 Nov 27 Revised 2019 Dec 5

Example data.

Multiple readers and multiple modalities ( i.e., MRMC)

—————————————————————————————————

Modality ID Reader ID Confidence levels No. of false alarms No. of hits.
m q c f h
-------------- ------------- ------------------------ ------------------- ----------------
1 1 3 20 111
1 1 2 29 55
1 1 1 21 22
1 2 3 6 100
1 2 2 15 44
1 2 1 22 11
2 1 3 6 66
2 1 2 24 55
2 1 1 23 1
2 2 3 5 66
2 2 2 30 55
2 2 1 40 44

—————————————————————————————————

* false alarms = False Positives = FP

* hits = True Positives = TP

DrawCurve

Logical: TRUE of FALSE. Whether the curve is to be drawn. TRUE or FALSE. If you want to draw the FROC and AFROC curves, then you set DrawCurve =TRUE, if not then DrawCurve =FALSE. The reason why the author make this variable DrawCurve is that it takes long time in MRMC case to draw curves, and thus Default value is FALSE in the case of MRMC data.

type_to_be_passed_into_plot

"l" or "p".

verbose

A logical, if TRUE, then the redundant summary is printed in R console. If FALSE, it suppresses output from this function.

print_CI_of_AUC

Logical, if TRUE then Credible intervals of AUCs for each modality are plotted.

PreciseLogLikelihood

Logical, that is TRUE or FALSE. If PreciseLogLikelihood = TRUE(default), then Stan calculates the precise log likelihood with target formulation. If PreciseLogLikelihood = FALSE, then Stan calculates the log likelihood by dropping the constant terms in the likelihood function. In past, I distinct the stan file, one is target formulation and the another is not. But non-target formulation cause some Jacobian warning, thus I made all stanfile with target formulation when I uploaded to CRAN. Thus this variable is now meaningless.

summary

Logical: TRUE of FALSE. Whether to print the verbose summary. If TRUE then verbose summary is printed in the R console. If FALSE, the output is minimal. I regret, this variable name should be verbose.

dataList.Name

This is not for user, but the author for this package development.

prior

positive integer, to select the prior

ModifiedPoisson

Logical, that is TRUE or FALSE.

If ModifiedPoisson = TRUE, then Poisson rate of false alarm is calculated per lesion, and a model is fitted so that the FROC curve is an expected curve of points consisting of the pairs of TPF per lesion and FPF per lesion.

Similarly,

If ModifiedPoisson = TRUE, then Poisson rate of false alarm is calculated per image, and a model is fitted so that the FROC curve is an expected curve of points consisting of the pair of TPF per lesion and FPF per image.

For more details, see the author's paper in which I explained per image and per lesion. (for details of models, see vignettes , now, it is omiited from this package, because the size of vignettes are large.)

If ModifiedPoisson = TRUE, then the False Positive Fraction (FPF) is defined as follows (F_c denotes the number of false alarms with confidence level c )

\frac{F_1+F_2+F_3+F_4+F_5}{N_L},

\frac{F_2+F_3+F_4+F_5}{N_L},

\frac{F_3+F_4+F_5}{N_L},

\frac{F_4+F_5}{N_L},

\frac{F_5}{N_L},

where N_L is a number of lesions (signal). To emphasize its denominator N_L, we also call it the False Positive Fraction (FPF) per lesion.

On the other hand,

if ModifiedPoisson = FALSE (Default), then False Positive Fraction (FPF) is given by

\frac{F_1+F_2+F_3+F_4+F_5}{N_I},

\frac{F_2+F_3+F_4+F_5}{N_I},

\frac{F_3+F_4+F_5}{N_I},

\frac{F_4+F_5}{N_I},

\frac{F_5}{N_I},

where N_I is the number of images (trial). To emphasize its denominator N_I, we also call it the False Positive Fraction (FPF) per image.

The model is fitted so that the estimated FROC curve can be ragraded as the expected pairs of FPF per image and TPF per lesion (ModifiedPoisson = FALSE )

or as the expected pairs of FPF per image and TPF per lesion (ModifiedPoisson = TRUE)

If ModifiedPoisson = TRUE, then FROC curve means the expected pair of FPF per lesion and TPF.

On the other hand, if ModifiedPoisson = FALSE, then FROC curve means the expected pair of FPF per image and TPF.

So,data of FPF and TPF are changed thus, a fitted model is also changed whether ModifiedPoisson = TRUE or FALSE. In traditional FROC analysis, it uses only per images (trial). Since we can divide one image into two images or more images, number of trial is not important. And more important is per signal. So, the author also developed FROC theory to consider FROC analysis under per signal. One can see that the FROC curve is rigid with respect to change of a number of images, so, it does not matter whether ModifiedPoisson = TRUE or FALSE. This rigidity of curves means that the number of images is redundant parameter for the FROC trial and thus the author try to exclude it.

Revised 2019 Dec 8 Revised 2019 Nov 25 Revised 2019 August 28

mesh.for.drawing.curve

A positive large integer, indicating number of dots drawing the curves, Default =10000.

significantLevel

This is a number between 0 and 1. The results are shown if posterior probabilities are greater than this quantity.

cha

A variable to be passed to the function rstan::sampling() of rstan in which it is named chains. A positive integer representing the number of chains generated by Hamiltonian Monte Carlo method, and, Default = 1.

war

A variable to be passed to the function rstan::sampling() of rstan in which it is named warmup. A positive integer representing the Burn in period, which must be less than ite. Defaults to war = floor(ite/5)=10000/5=2000,

ite

A variable to be passed to the function rstan::sampling() of rstan in which it is named iter. A positive integer representing the number of samples synthesized by Hamiltonian Monte Carlo method, and, Default = 1111

dig

A variable to be passed to the function rstan::sampling() of rstan in which it is named ...??. A positive integer representing the Significant digits, used in stan Cancellation. Default = 5,

see

A variable to be passed to the function rstan::sampling() of rstan in which it is named seed. A positive integer representing seed used in stan, Default = 1234.

Null.Hypothesis

Logical, that is TRUE or FALSE. If Null.or.Alternative.Hypothesis = FALSE(default), then fit the alternative model to dataList (for details of models, see vignettes ). If Null.or.Alternative.Hypothesis = TRUE, then fit the null model to dataList.(for details of models, see vignettes ). Note that the null model is constructed under the null hypothesis that all modality are same observer performance ability. The alternative model is made under the assumption that all modality are not same. The reason why author creates this parameter is to test the null hypothesis by the Bayes factor. But the result of test is not desired one for me. Thus the test is under construction.

prototype

A logical, if TRUE then the model is no longer a generative model. Namely, in generally speaking, a dataset drawn from the model cannot satisfy the condition that the sum of the numbers of hits over all confidence levels is bounded from the above by the number of lesions, namely,

Σ_c H_c ≤ N_L

However, this model (TRUE ) is good in the sense that it admits various initial values of MCMC sampling.

if FALSE, then the model is precisely statistical model in the sense that any dataset drawn from the model satisfies that the sum of the number of hits is not greater than the number of lesions, namely,

Σ_c H_c ≤ N_L.

This model is theoretically perfect. However, in the practically, the calculation will generates some undesired results which caused by the so-called floo .... I forget English :'-D. The flood point??? I forgeeeeeeeeeeeeet!! Ha. So, prior synthesizes very small hit rates such as 0.0000000000000001234 and it cause the non accurate calculation such as 0.00000,,,00000123/0.000.....000012345= 0.0012 which becomes hit rate and thus OH No!. Then it synthesizes Bernoulli success rate which is not less than 1 !! To avoid this, the author should develop the theory of prior to avoid this very small numbers, however the author has idea but now it does not success.

If prototype = TRUE, then the model for hits is the following:

H_5 \sim Binomial(p_5,N_L)

H_4 \sim Binomial(p_4,N_L)

H_3 \sim Binomial(p_3,N_L)

H_2 \sim Binomial(p_2,N_L)

H_1 \sim Binomial(p_1,N_L)

On the other hand, if prototype = FALSE, then the model for hits is the following:

H_5 \sim Binomial( p_5,N_L )

H_4 \sim Binomial( \frac{p_4}{1-p_5},N_L - H_5)

H_3 \sim Binomial( \frac{p_3}{1-p_5-p_4},N_L - H_5-H_4)

H_2 \sim Binomial( \frac{p_2}{1-p_5-p_4-p_3},N_L - H_5-H_4-H_3)

H_1 \sim Binomial( \frac{p_1}{1-p_5-p_4-p_3-p_2},N_L - H_5-H_4-H_3-H_2)

Each number of lesions is adjusted so that the sum of hits Σ_c H_c is less than the number of lesions (signals, targets) N_L. And hence the model in case of prototype = FALSE is a generative model in the sense that it can replicate datasets of FROC arises. Note that the adjustment of the number of lesions in the above manner leads us the adjustment of hit rates. The reason why we use the hit rates such as \frac{p_2}{1-p_5-p_4-p_3} instead of p_c is that it ensures the equality E[H_c/N_L] = p_c. This equality is very important. To establish Bayesian FROC theory so that it is compatible to the classical FROC theory, we need the following two equations,

E[H_c/N_L] = p_c,

E[F_c/N_X] = q_c,

where E denotes the expectation and N_X is the number of lesion or the number of images and q_c is a false alarm rate, namely, F_c \sim Poisson( q_c N_X).

Using the above two equations, we can establish the alternative Bayesian FROC theory preserving classical notions and formulas. For the details, please see the author's pre print:

Bayesian Models for ,,, for?? I forget my paper title .... :'-D. What the hell!? I forget,... My health is so bad to forget , .... I forget.

The author did not notice that the prototype is not a generative model. And hence the author revised the model so that the model is exactly generative model.

But the reason why the author remains the prototype model(prototype = TRUE) is that the convergence of MCMC sampling in case of MRMC is not good in the current model (prototype = FALSE) . Because it uses fractions \frac{p_1}{1-p_5-p_4-p_3-p_2} and which is very dangerous to numerical perspective. For example, if p_1 is very small, then the numerator and denominator of \frac{p_1}{1-p_5-p_4-p_3-p_2} is very small. Both of them is like 0.000000000000000123.... and such small number causes the non accurate results. So, sometimes, it occurs that \frac{p_1}{1-p_5-p_4-p_3-p_2} >1 which never occur in the theoretical perspective but unfortunately, in numerically occurs.

SO, now, the author try to avoid such phenomenon by using priors but it now does not success.

Here of course we interpret the terms such as N_L - H_5-H_4-H_3 as the remained targets after reader get hits. The author thinks it is another manner to do so like N_L -H_1-H2-H_3, but it does not be employed. Since the author thinks that the reader will assign his suspicious lesion location from high confidence level and in this view point the author thinks it should be considered that targets are found from the highest confidence suspicious location.

model_reparametrized

A logical, if TRUE, then a model under construction is used.

Model_MRMC_non_hierarchical

A logical. If TRUE, then the model of multiple readers and multiple modalities consits of no hyper parameters. The reason why the author made this parameter is that the hyper parameter make the MCMC posterior samples be unstable. And also, my hierarachical model is not so good in theoretical perspective. Thus, I made this. The Default is TRUE.

ww

Each of which is a real number specifying one of the parameter of prior

www

Each of which is a real number specifying one of the parameter of prior

mm

Each of which is a real number specifying one of the parameter of prior

mmm

Each of which is a real number specifying one of the parameter of prior

vv

Each of which is a real number specifying one of the parameter of prior

vvv

Each of which is a real number specifying one of the parameter of prior

zz

Each of which is a real number specifying one of the parameter of prior

zzz

Each of which is a real number specifying one of the parameter of prior

...

Additional arguments


BayesianFROC documentation built on Jan. 23, 2022, 9:06 a.m.