Commit 435e9544 authored by Jean-Karim Heriche's avatar Jean-Karim Heriche

Fixed #21. Prevent crash when clicking on an image if no ROI is defined by...

Fixed #21. Prevent crash when clicking on an image if no ROI is defined by checking if ROI variables (i.e. rv$roiX...) are NULL in addition to empty.
parent 65f168c9
......@@ -59,7 +59,7 @@ explore_image_server <-function(input, output, session, rv){
output$imageViewer1 <- renderImageViewer({
image1 <- img1()
if(!is.null(image1)) {
if(!is.null(rv$pixelPosition) && rv$roiX!="") { # input$roiX!="" => ROI selection enabled
if(!is.null(rv$pixelPosition) && !is.null(rv$roiX) && rv$roiX!="") { # input$roiX!="" => ROI selection enabled
r <- ceiling(rv$metadataImg1$coreMetadata$sizeX/100)
colorMode(image1) = Color
image1 <- drawCircle(image1, rv$pixelPosition[1], rv$pixelPosition[2], r, "red", fill=TRUE, z=1)
......@@ -79,11 +79,11 @@ explore_image_server <-function(input, output, session, rv){
k <- 1 # number of data points to retrieve
clickPosition <- NULL
roiData <- NULL
if(!is.null(input$pixelPosition) && rv$roiX != "" && rv$roiY != "") {
if(!is.null(input$pixelPosition) && !is.null(rv$roiX ) && !is.null(rv$roiY) && rv$roiX != "" && rv$roiY != "") {
## Depends only on input$pixelPosition (input$roiX and input$roiY are not expected to change here).
## This prevents being run upon clearing row selection.
isolate({
if(rv$roiFrame != "") {
if(!is.null(rv$roiFrame) && rv$roiFrame != "") {
clickPosition <- data.frame(t(c(rv$pixelPosition, rv$selectedFrame)))
## Make sure we're looking only for ROIs present in the frame currently displayed
## This assumes that we interact with imageViewer1
......
......@@ -55,7 +55,7 @@ explore_image_server2 <-function(input, output, session, rv){
output$imageViewer2 <- renderImageViewer({
image2 <- img2()
if(!is.null(image2)) {
if(!is.null(rv$pixelPosition) && rv$roiX != "") { # input$roiX != "" => ROI selection enabled
if(!is.null(rv$pixelPosition) && !is.null(rv$roiX) && rv$roiX != "") { # input$roiX != "" => ROI selection enabled
r <- ceiling(rv$metadataImg2$coreMetadata$sizeX/100)
colorMode(image2) = Color
image2 <- drawCircle(image2, rv$pixelPosition[1], rv$pixelPosition[2], r, "red", fill=TRUE, z=1)
......
......@@ -106,7 +106,7 @@ plot_server <- function(input, output, session, rv) {
}) # End renderTable
output$info <- renderTable({
if(!is.null(rv$imgPath1) && !is.null(rv$pixelPosition) && rv$roiX != "") {
if(!is.null(rv$imgPath1) && !is.null(rv$pixelPosition) && !is.null(rv$roiX) && rv$roiX != "") {
data.frame("X" = rv$pixelPosition[1], "Y" = rv$pixelPosition[2], "Z/T" = rv$selectedFrame, "File" = rv$imgPath1)
} else {
data.frame("X" = NA, "Y" = NA, "Z/T" = NA, "File" = NA)
......
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