Learn R Programming

BayesianFROC (version 0.2.1)

DrawCurves: Draw the FROC curves

Description

The function makes a plot of the FROC curve, the AFROC curve and FPF and TPF.

Usage

DrawCurves(StanS4class, modalityID, readerID, title = TRUE,
  indexCFPCTP = FALSE, upper_x, upper_y, new.imaging.device = TRUE,
  Colour = TRUE, DrawFROCcurve = TRUE, DrawAFROCcurve = FALSE,
  DrawAUC = TRUE, DrawCFPCTP = TRUE, Draw.Flexible.upper_y = TRUE,
  Draw.Flexible.lower_y = TRUE, summary = TRUE, type = 4,
  color_is_changed_by_each_reader = FALSE,
  Draw.inner.circle.for.CFPCTPs = TRUE)

Arguments

StanS4class

An S4 object of class stanfitExtended which is an inherited class from the S4 class stanfit. This R object can be passed to the DrawCurves(), ppp() and ... etc

modalityID

A positive integer vector indicating modalityID. If it is not given, then the first modality is chosen.

readerID

A positive integer vector indicating readerID. If it is not given, then the first reader is chosen.

title

Logical: TRUE of FALSE. If TRUE (default), then title of curves are drawn.

indexCFPCTP

TRUE of FALSE. If TRUE, then the cumulative false and hits are specified with its confidence level.

upper_x

This is a upper bound for the axis of the horisontal coordinate of FROC curve.

upper_y

This is a upper bound for the axis of the vertical coordinate of FROC curve.

new.imaging.device

Logical: TRUE of FALSE. If TRUE (default), then open a new device to draw curve. Using this we can draw curves in same plain by new.imaging.device=FALSE.

Colour

Logical: TRUE of FALSE. whether Colour of curves is dark theme or not.

DrawFROCcurve

Logical: TRUE of FALSE. Whether or not FROC curves are shown.

DrawAFROCcurve

Logical: TRUE of FALSE. Whether or not AFROC curves are shown.

DrawAUC

TRUE of FALSE. If TRUE then area under the AFROC curves are painted.

DrawCFPCTP

Logical: TRUE of FALSE. Whether or not the pairs of FPF and TPF are shown.

Draw.Flexible.upper_y

Logical: TRUE of FALSE. Whether or not the upper bounds of vertical axis are determined automatically.

Draw.Flexible.lower_y

Logical: TRUE of FALSE. Whether or not the lower bounds of vertical axis are determined automatically.

summary

Logical: TRUE of FALSE. Whether to print the verbose summary, i.e., logical; 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.

type

An integer, for the color of background and etc.

color_is_changed_by_each_reader

A logical, if TRUE, then the FROC curves, AFROC curves, and FPF, TPF are colored accordingly by each reader. The aim of FROC analysis is to compare the modality and not reader, so the default value is false, and curves and FPF and TPF are colored by each modalities.

Draw.inner.circle.for.CFPCTPs

TRUE or FALSE. If true, then to plot the cumulative false positives and true positives the plot points is depicted by two way, one is a large circle and one is a small circle. By see the small circle, user can see the more precise position of these points.

Details

The function makes a plot of the FROC curves and AFROC curves for user's specified modality and user's specified reader. Using this function repeatedly, we can draw the different reader and modality in a same plane simultaneously. So, we can visualize the difference of modality (reader).

Examples

Run this code
# NOT RUN {
#================The first example======================================
# }
# NOT RUN {
#1) Build the S4 class object by the following:



  fit <- fit_Bayesian_FROC(
  BayesianFROC::dataList.Chakra.Web,    # data to which fit the model
                           ite=1111     # iteration of MCMC, very few, should be more.
                           )


# The object "fit" is an S4 class object
# whose S4 class is an inherited class from stanfit in the rstan package.

#<<Minor comments>>
#Note that return value "fit" is not an stanfit S4 object generated by rstan::stan(),
#but some inherited S4 class object which is an S4 object of
# some inherited S4 class from the stanfit class.





#2) Now, we obtain the S4 class object named "fit".
  # Using this S4 class object, we draw the curves by:



          DrawCurves(fit,modality = 1,reader = 4)

#From this code, FROC curve for the first modality and fourth reader is drawn.







#3) By changing, e.g., the modality,
   #we can draw the curves for different  modalities.
   #This shows the comparison of modalites.
   # In the following R script,
   #  the first draw curve for the 2 nd modality and the fourth reader,
   # and the second R script draw for the 3rd modality and the 4 th reader,
   # respectively.



            DrawCurves(fit,modality = 2,reader = 4)
            DrawCurves(fit,modality = 3,reader = 4)



# Curves are overwritten for the sake of comparison.
# When comparing modalities fitted by the hierarchical Bayesian Model to the same data,
# the upper FROC curve or AFROC curve, the better the AUC.









#4) By applying the function with respect to different modalities
#   in this manner, we can draw  AFROC (FROC) curves in the same plain.



#5) If you want to draw the FROC curves
#for reader ID =1,2,3,4 and modality ID =1,2, then the code is as follows;

                  DrawCurves(
                            fit,
                            modalityID = c(1,2,3,4),
                            readerID = c(1,2)
                            )
# Each color of curves corresponds to the modality ID.
# So, even if curves are different readers and same modality, then color is same.







#6) If you want to see only data points, then by DrawFROCcurve = F, it will be done.

DrawCurves(fit,
           DrawCFPCTP = TRUE,      # This implies data points are ploted.
           DrawFROCcurve = FALSE,  # From this, the curves are not drawn.
           modalityID = c(1,2,3,4),
           readerID  = c(1)
           )







#7) If you use the plot in submission and it is not allowed to use color, then
#   by Colour =F, you can get black and white plots, e.g.,


DrawCurves(fit,
          DrawCFPCTP = TRUE,
          DrawFROCcurve = TRUE,
          modalityID = c(1,2,3,4),
          readerID  = c(1),
          Colour = FALSE    # From this, you can get plots without colors.
          )







#8)  For AFROC, use DrawAFROCcurve = T

DrawCurves(fit,
          DrawFROCcurve = FALSE,
          DrawAFROCcurve = TRUE,
          modalityID = c(1,2,3,4),
          readerID  = c(1))






#9)

# In order to compare modality, we draw curves by each modality
# The 1-st modality with all readers 1,2,3,4:


DrawCurves(fit,modalityID = 1,readerID = 1:4, new.imaging.device = T)

#The 2-nd modality with all readers 1,2,3,4:
DrawCurves(fit,modalityID = 2,readerID = 1:4, new.imaging.device = F)


#The 3-rd modality with all readers 1,2,3,4:
DrawCurves(fit,modalityID = 3,readerID = 1:4, new.imaging.device = F)


#The 4-th modality with all readers 1,2,3,4:
DrawCurves(fit,modalityID = 4,readerID = 1:4, new.imaging.device = F)


#The 5-th modality with all readers 1,2,3,4:
DrawCurves(fit,modalityID = 5,readerID = 1:4, new.imaging.device = F)



# Draw for all pairs of modalities and readers:

            DrawCurves(
                        modalityID = 1:fit@dataList$M,
                          readerID = 1:fit@dataList$Q,
                       StanS4class = fit
                        )









# Changea the color by


                             DrawCurves(fit, type = 2)
                             DrawCurves(fit, type = 3)
                             DrawCurves(fit, type = 4)
                             DrawCurves(fit, type = 5)
                             DrawCurves(fit, type = 6)
                             DrawCurves(fit, type = 7)





#================The Second Example======================================================

#This function is available in the case of a single reader and a single modality.
#The reason why the maintainer separate the fitting and drawing curves is, in MRMC case,
#It tooks a time to drawing, but in the a single reader and a single modality case, drawing
# the curve is very fast, so in fitting process the curves are also depicted, however
# by this function user can draw the FROC curves.





#First, we prepare the data endowed with this package.





                          dat  <- get(data("dataList.Chakra.1"))




#Second, we run the stan funtion
#with data named "dat"  and the author's Bayesian model.





                             fit <-  fit_srsc(dat)





# Drawing the curves by


                             DrawCurves(fit)






# Changea the color by


                             DrawCurves(fit, type = 2)
                             DrawCurves(fit, type = 3)
                             DrawCurves(fit, type = 4)
                             DrawCurves(fit, type = 5)
                             DrawCurves(fit, type = 6)
                             DrawCurves(fit, type = 7)

#      Close the graphic device to avoid errors in R CMD check.

         Close_all_graphic_devices()
# }
# NOT RUN {
# dottest
# }

Run the code above in your browser using DataLab