Commit f8253b32 authored by Jean-Karim Heriche's avatar Jean-Karim Heriche

Display corresponding image (and show ROI marker) when selecting a row in the data table.

parent 71991af0
......@@ -295,7 +295,7 @@ server <- function(input, output, session) {
output$fileColumn1 <- renderUI({
colNames <- names(rv$data)
## Try to infer from name and set as default
found <- grepl("image.*[path|file]", colNames, ignore.case = TRUE)
found <- grepl("path|file", colNames, ignore.case = TRUE) & grepl("image|intensit", colNames, ignore.case = TRUE)
selection <- NULL
if(any(found)) {
selection <- colNames[found]
......@@ -310,16 +310,16 @@ server <- function(input, output, session) {
## Second image selection
output$fileColumn2 <- renderUI({
colNames <- names(rv$data)
# ## Try to infer from name and set as default
# found <- grepl("image.*path", colNames, ignore.case = TRUE)
# selection <- NULL
# if(any(found)) {
# selection <- colNames[found]
# }
## Try to infer from name and set as default
found <- grepl("path|file", colNames, ignore.case = TRUE) & grepl("label|mask", colNames, ignore.case = TRUE)
selection <- NULL
if(any(found)) {
selection <- colNames[found]
}
selectizeInput(inputId = "fileCol2",
label = "Column with file names for image 2",
multiple = TRUE,
selected = NULL,
selected = selection,
choices = c("",colNames),
options = list(maxItems = 1))
})
......@@ -339,7 +339,7 @@ server <- function(input, output, session) {
req(input$datafile) ## Proceed only if file selected
## When reading semicolon separated files,
## having a comma separator causes `read.csv` to error
## having a comma separator causes read.csv to error
tryCatch(
{
rv$data <- read.csv(input$datafile$datapath,
......@@ -363,17 +363,16 @@ server <- function(input, output, session) {
# Get index of each column
# Note: indexing starts at 0 but if row names are present they are in column 0
# so we don't use -1 to get the actual column indices.
rv$colsToHide <- match(input$colsToHide, colnames(rv$data))
rv$colsToHide <- match(input$colsToHide, colnames(rv$data))
})
## Show the data table
output$dataTable <- renderDT(
output$dataTable <- renderDT({
datatable(rv$data[rv$currentRows,],
selection = list(mode = 'multiple', selected = rv$selectedRows),
extensions = c('FixedHeader', 'ColReorder', 'Buttons'),
filter = "top",
escape = FALSE, # Don't escape HTML code in the table to allow checkboxes
editable = FALSE,
escape = FALSE, # Don't escape HTML code in the table to allow e.g. checkboxes
options = list(displayModeBar = TRUE,
fixedHeader = TRUE,
colReorder = TRUE,
......@@ -401,14 +400,15 @@ server <- function(input, output, session) {
}")
)
)
)), server = TRUE) # Server side processing required for large data tables
## Make a proxy to manipulate the table after it's been rendered
## All data point selection irrespective of origin
## should select rows in the proxy table which then
## updates the plot and/or the image(s)
proxy <- dataTableProxy('dataTable')
))
}, server = TRUE) # Server side processing required for large data tables
## Make a proxy to manipulate the table after it's been rendered
## All data point selection irrespective of origin
## should select rows in the proxy table which then
## updates the plot and/or the image(s)
proxy <- dataTableProxy('dataTable')
## Show the plot
output$plot <- renderPlotly({
req(rv$data)
......@@ -502,6 +502,14 @@ server <- function(input, output, session) {
## Interactions with the table
observe({
rv$selectedRows <- input$dataTable_rows_selected
if(length(rv$selectedRows) == 1) {
rv$imgPath1 <- as.character(rv$data[rv$selectedRows, input$fileCol1])
rv$imgPath2 <- as.character(rv$data[rv$selectedRows, input$fileCol2])
if(!is.null(input$roiX) && input$roiX != "" && !is.null(input$roiY) && input$roiY != ""){
rv$pixelPosition <- unlist(rv$data[rv$selectedRows, c(input$roiX, input$roiY)])
rv$selectedFrame <- rv$data[rv$selectedRows, input$roiFrame]
}
}
updateFilters()
})
observeEvent(input$selectFiltered, {
......@@ -632,7 +640,6 @@ server <- function(input, output, session) {
} else {
cat("No ROI selection\n")
}
# cat(input$roiX, ":", rv$pixelPosition[1], " ", input$roiY, ":", rv$pixelPosition, " ", input$roiFrame, ":", rv$selectedFrame, "\n")
cat("X:", rv$pixelPosition[1], " ", "Y:", rv$pixelPosition[2], " ", "Z/T:", rv$selectedFrame, "\n")
cat("Current image 1:", rv$imgPath1, "\n")
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment