plot.BoneProfileR {BoneProfileR} | R Documentation |
Plot a bone section
Description
Display a bone section.
type value can be:
Image plot: original
, mineralized
, unmineralized
, section
Original is the original image, mineralized is the mineral interpretation of the section,
unmineralized is the unmineralized interpretation of the section, section is the interpretation of the section.
colors
shows the histograms of pixel information with foreground and background colors if they are defined.
3Dcolors
show the pixels colors in 3D
Global analysis: observations
, model
, observations+model
Radial analysis: radial
Periodic analysis: periodic
If angle is not null and a radial analysis exists, it will show the model for this angle.
mcmc
: It will show the posterior distribution of parameter.
For periodic analysis, you can see a particular parameter with parameter.name being
P, S, Min, Max, K1, or K2 or the global median compactness using parameter.name="compactness".
You can use col=rainbow(128) or hcl.colors(128) to see the region of transition. You can
also plot the average compactness using parameter.name="averagemodel".
Usage
## S3 method for class 'BoneProfileR'
plot(
x,
message = NULL,
type = "original",
angle = NULL,
show.all.angles = FALSE,
show.centers = TRUE,
show.colors = TRUE,
show.grid = TRUE,
analysis = 1,
parameter.name = "S",
options.mcmc = list(),
restorePar = TRUE,
mar = NULL,
angle.3D = 55,
CI = "ML",
replicates.CI = 1000,
show.legend = TRUE,
...
)
Arguments
x |
The bone image |
message |
The message to be displayed |
type |
The type of plot; see description |
angle |
Which angle model to show |
show.all.angles |
For periodic type and partial section, should all angles been shown? |
show.centers |
Should the centers be shown? |
show.colors |
Should the background and foreground colors be shown? |
show.grid |
Should the grid be shown? |
analysis |
Name or number of analysis to be plotted |
parameter.name |
The parameter to plot |
options.mcmc |
The option to plot type mcmc output |
restorePar |
If TRUE, restore the par parameter at the exit |
mar |
The margin for type being "model" or "observations" |
angle.3D |
The angle between x and y for 3Dcolors graph |
CI |
Which confidence interval should be plotted: MCMC or ML |
replicates.CI |
How many replicates to estimate CI? |
show.legend |
Should a legend be shown? |
... |
Default parameters for some functions |
Details
plot.BoneProfileR displays a bone section
Value
Nothing
Author(s)
Marc Girondot marc.girondot@gmail.com
See Also
Other BoneProfileR:
BP_AutoFit()
,
BP_ChooseBackground()
,
BP_ChooseCenter()
,
BP_ChooseForeground()
,
BP_DetectBackground()
,
BP_DetectCenters()
,
BP_DetectForeground()
,
BP_DuplicateAnalysis()
,
BP_EstimateCompactness()
,
BP_FitBayesianCompactness()
,
BP_FitBayesianPeriodicCompactness()
,
BP_FitMLCompactness()
,
BP_FitMLPeriodicCompactness()
,
BP_FitMLRadialCompactness()
,
BP_GetFittedParameters()
,
BP_ListAnalyses()
,
BP_LnLCompactness()
,
BP_OpenImage()
,
BP_Report()
,
Erinaceus_europaeus
,
summary.BoneProfileR()
Examples
## Not run:
# Not run:
library(BoneProfileR)
bone <- BP_OpenImage()
# or
path_Hedgehog <- system.file("extdata", "Erinaceus_europaeus_fem_2-1_small.png",
package = "BoneProfileR")
bone <- BP_OpenImage(file=path_Hedgehog)
bone <- BP_DetectBackground(bone=bone, analysis="logistic")
bone <- BP_DetectForeground(bone=bone, analysis="logistic")
plot(bone, type="colors")
bone <- BP_DetectCenters(bone=bone, analysis="logistic")
plot(bone, type="3Dcolors")
bone <- BP_EstimateCompactness(bone, analysis="logistic")
bone <- BP_FitMLCompactness(bone, analysis="logistic")
plot(bone)
############################################
# Example with comparison between two models
############################################
path_Hedgehog <- system.file("extdata", "Erinaceus_europaeus_fem_2-1_small.png",
package = "BoneProfileR")
bone <- BP_OpenImage(file=path_Hedgehog)
bone <- BP_DetectBackground(bone=bone, analysis="logistic")
bone <- BP_DetectForeground(bone=bone, analysis="logistic")
bone <- BP_DetectCenters(bone=bone, analysis="logistic")
bone <- BP_EstimateCompactness(bone, analysis="logistic")
bone <- BP_FitMLCompactness(bone, analysis="logistic")
plot(bone)
plot(bone, type="observations")
plot(bone, type="observations+model", analysis=1)
fittedpar <- BP_GetFittedParameters(bone, analysis="logistic",
ML=TRUE, return.all = FALSE)[, "mean"]
bone <- BP_DuplicateAnalysis(bone, from="logistic", to="flexit")
bone <- BP_FitMLCompactness(bone,
fitted.parameters=c(fittedpar, K1=1, K2=1),
fixed.parameters=NULL, analysis="flexit")
compare_AIC(Logistic=BP_GetFittedParameters(bone, analysis="logistic",
ML=TRUE, return.all = TRUE),
Flexit=BP_GetFittedParameters(bone, analysis="flexit",
ML=TRUE, return.all = TRUE))
out4p <- plot(bone, type="observations+model", analysis="logistic")
out6p <- plot(bone, type="observations+model", analysis="flexit")
############################################
# Fit distribution using Bayesian model
############################################
bone <- BP_FitBayesianCompactness(bone, analysis="logistic", n.adapt=100)
# Test the output - New in version 3.2
plot(bone, type="mcmc", options.mcmc = list(what="LnL"))
#########################################################################
# Clearly the distribution is not stationary; the adaptation was too short
#########################################################################
bone <- BP_FitBayesianCompactness(bone, analysis="logistic", n.adapt=10000)
# Now it is ok
plot(bone, type="mcmc", options.mcmc = list(what="LnL"))
#########################################################################
# New in version 3.2
#########################################################################
plot(bone, type="mcmc", options.mcmc = list(what="Posterior",
xlim=c(0.025, 0.035), breaks=seq(from=0.025, to=0.035, by=0.001)),
parameter.name = "S")
plot(bone, type="mcmc", options.mcmc = list(what="MarkovChain",
ylim=c(0.02, 0.04)),
parameter.name = "S")
#########################################################################
# Check the priors and the output
#########################################################################
mcmc <- RM_get(x=bone, RMname="logistic", valuename = "mcmc")
priors <- mcmc$parametersMCMC$parameters
parameters <- as.parameters(mcmc, index="median")
#########################################################################
# Now it is ok. It can be used
#########################################################################
plot(bone, type="observations+model", CI="MCMC")
plot(bone, type="observations+model", CI="ML")
#########################################################################
#############################################
# Radial compactness
#############################################
bone <- BP_FitMLRadialCompactness(bone, progressbar=TRUE)
plot(bone, type="radial", parameter.name=c("P", "S"))
plot(bone, type="radial", parameter.name=c("P", "S", "Min", "Max"))
plot(bone, type="radial", parameter.name="observed.compactness")
plot(bone, type="radial", parameter.name="linearized.observed.compactness")
#############################################
# Periodic analysis
# This model can take 10 minutes to be fitted
# And still more if you use large replicates.CI value
#############################################
bone <- BP_FitMLPeriodicCompactness(bone, analysis="logistic", control.optim=list(trace=2),
fitted.parameters=c(par, PSin=0.001, PCos=0.001,
SSin=0.001, SCos=0.001, MinSin=0.001, MinCos=0.001,
MaxSin=0.001, MaxCos=0.001), replicates.CI=2000)
plot(bone, type="periodic", parameter.name="compactness", col=rainbow(128))
plot(bone, type="periodic", parameter.name="compactness")
plot(bone, type="periodic", parameter.name="P", ylim=c(0, 1),
col=rgb(red = 0.7, green = 0.7, blue = 0.7, alpha = 0.2))
plot(bone, type="periodic", parameter.name="averagemodel")
## End(Not run)