Skip to content

Instantly share code, notes, and snippets.

@mcdlee
Created October 13, 2020 02:29
Show Gist options
  • Save mcdlee/6409da1692288df3ffed915050ce822f to your computer and use it in GitHub Desktop.
Save mcdlee/6409da1692288df3ffed915050ce822f to your computer and use it in GitHub Desktop.
RadExp

Reference

  • DOI: 10.1097/HP.0b013e318235153a
library(shiny)
isotopeTable <- read.csv("isotope.csv")
isotopeList <- isotopeTable$isotope
generateActivityTable <- function(Bq){
Unit <- c("Bq", "kBq", "MBq", "mCi", "Ci")
Activity <- c(Bq, Bq/1E3, Bq/1E6, Bq/3.7E7, Bq/3.7E10)
table <- data.frame(Unit, Activity)
return(table)
}
generateERTable <- function(Bq, ERcons){
Distance <- c("5 cm", "50 cm", "1 m", "2 m")
ExposureRate <- c(Bq/3.7E7*ERcons/25,
Bq/3.7E7*ERcons/2500,
Bq/3.7E7*ERcons/10000,
Bq/3.7E7*ERcons/40000)
table <- data.frame(Distance, ExposureRate)
return(table)
}
isotope ExpRateCons f-factor
I-131 2.2 0.963
Cs-134 8.76 0.965
Cs-137 3.43 0.962
library(shiny)
shinyServer(function(input, output) {
#Calculate
coeff <- eventReactive(input$update,{
switch(input$unit,
"CPS"=1,
"CPM"=1/60)
}, ignoreNULL = FALSE)
#The unit is mGy.cm^2/mCi.Hr
ERcons <- eventReactive(input$update, {
isotopeTable$ExpRateCons[match(input$isotope, isotopeTable$isotope)] *
isotopeTable$f.factor[match(input$isotope, isotopeTable$isotope)] * 10
}, ignoreNULL = FALSE)
#The unit is "Bq"
activity <- eventReactive(input$update, {input$count*coeff()/input$sensitivity*100},
ignoreNULL = FALSE)
actTable <- eventReactive(input$update, {generateActivityTable(activity())}, ignoreNULL = FALSE)
ERTable <- eventReactive(input$update, {generateERTable(activity(), ERcons())}, ignoreNULL = FALSE)
#Output
output$result <- renderText({
paste("The isotope is ", input$isotope)
})
output$activity <- renderText({
paste("The activity is ", activity(), "Bq", "=", activity()/37000000, "mCi")
})
output$actTable <- renderTable(actTable(), digits = -2)
output$ERcons <- renderText({
paste("The exposure rate constant is", ERcons(), "mGy.cm^2/mCi.h")
})
output$ERtable <- renderTable(ERTable(), digits = -2)
})
library(shiny)
# Define UI for application that draws a histogram
shinyUI(fluidPage(
# Application title
titlePanel("How much radionuclide is there?"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
selectInput("isotope", "Isotope: ", isotopeList),
numericInput("count", "Count rate: ", min=0, value=NA),
selectInput("unit", "Unit: ", c("CPS", "CPM")),
sliderInput("sensitivity", "Sensitivity: ", min=0, max=100, value=30, post="%"),
actionButton("update", "Update view")
),
# Show a plot of the generated distribution
mainPanel(
textOutput("result"),
textOutput("activity"),
tableOutput("actTable"),
hr(),
textOutput("ERcons"),
tableOutput("ERtable"),
"The unit of exposure rate is mGy/hr"
)
)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment