I have built a Shiny App that works well locally and is able to automatically open a separate app (ImageJ Fiji), run a macro code to analyze an image, and then feed the results back to the Shiny App using the following:
Path0 <- "C:/Users/Username/Fiji.app/ImageJ-win64.exe --ij2 --run C:/Users/Username/Fiji.app/macros/TestingShiny.ijm"
system(Path0)
I'm now trying to use shinyapps.io to run the app so that other users will not have to download R in order to run the full analysis (I'm thinking Fiji will still need to be downloaded on every user's computer).
I made a very abbreviated version of my app to test out, and there is (understandably) a disconnect when trying to run this file path and system call once deployed on shinyapps.io.
## Load Packages
pacman::p_load(pacman, rmarkdown, shiny, shinydashboard, shinyWidgets, fresh, here, tinytex, htmlwidgets)
# Create the theme
Theme <- create_theme(
adminlte_color(
red = "#FF4719"
),
adminlte_sidebar(
dark_bg = "#293745",
dark_hover_bg = "#3CAAFF",
)
)
## Assign File Paths
Path0 <- "C:/Users/Username/Fiji.app/ImageJ-win64.exe --ij2 --run C:/Users/Username/Fiji.app/macros/TestingShiny.ijm"
ui <- dashboardPage(skin = "red",
dashboardHeader(
title = h4(HTML("Test"))),
dashboardSidebar(
sidebarMenu(id = "sidebarid",
menuItem("Test Run", tabName = "info"))),
dashboardBody(
use_theme(Theme),
tabItems(
tabItem(tabName = "info",
fluidRow(
column( width = 4,
fluidRow(
actionBttn(inputId = "go", label = "Go!"),
tableOutput(outputId = "text"))
)
)))))
server <- function(input, output, session) {
## Sets observeEvent with eventReactive for Go button click
observeEvent(input$go, {
## Runs Fiji and accompanying macro
system(Path0)
## Pulls Result file from Output folder
Result <- eventReactive(input$go, {read.delim(Path1)})
Filepath1 <- here("Output", "Log.txt")
write.csv(Result(), Filepath1 , row.names = FALSE)
## Displays the result
output$text <- renderTable(align = 'c', {Result()})
})}
shinyApp(ui, server)
Is there a way to pass the file path of the Fiji app and macro file on the client's side so that it can open and run on their computer then feed the results back to the Shiny App? Would shinyFiles or shiny::fileInput() work here?
No, it is not possible for a deployed app on to open and run another app (Fiji) on the client side.
is a platform for hosting and deploying Shiny apps, which are web-based applications that run on the server-side. When a user accesses a Shiny app, the app runs on the server, and the user interacts with it through a web browser.
Fiji, on the other hand, is a desktop application that needs to be installed and run on the client-side (i.e., the user's local machine).
Due to security restrictions and the architecture of web applications, a Shiny app running on cannot:
However, there are alternative solutions to achieve similar functionality, such as: