Skip to content

Commit

Permalink
Add checkbox to mirror points
Browse files Browse the repository at this point in the history
  • Loading branch information
jdmanton committed Jul 2, 2015
1 parent ed6bbbb commit 5b42f9e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
18 changes: 16 additions & 2 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,21 @@ shinyServer(function(input, output) {
transformed_points <- reactive({
pts <- points()
if(input$fromPts != input$toPts) {
pts <- xform_brain(pts, sample=get(input$fromPts), reference=get(input$toPts))
if(input$mirror_points) {
tryCatch({
pts <- mirror_brain(pts, get(input$fromPts))
pts <- xform_brain(pts, sample=get(input$fromPts), reference=get(input$toPts))
}, error = function(e) {
tryCatch({
pts <- xform_brain(pts, sample=get(input$fromPts), reference=get(input$toPts))
pts <- mirror_brain(pts, get(input$toPts))
}, error = function(e) {
stop("Could not mirror points")
})
})
} else {
pts <- xform_brain(pts, sample=get(input$fromPts), reference=get(input$toPts))
}
}
pts
})
Expand Down Expand Up @@ -152,7 +166,7 @@ shinyServer(function(input, output) {
text3d(0,0,-1.5,"and click bridge!")
} else {
# Dummy plot
spheres3d(pts, radius=5, color=rainbow(length(points())))
spheres3d(pts, radius=5, color=rainbow(length(pts)))
plot3d(get(paste0(input$toPts, ".surf")), col="grey", alpha=0.3)
frontalView()
}
Expand Down
1 change: 1 addition & 0 deletions ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ tabPanel("Coordinates",
h2("Original points"),
HTML('<textarea id="input_points" rows="16" cols=60>100 200 50
400 100 10</textarea>'),
checkboxInput("mirror_points", "Mirror?", value=FALSE),
submitButton("Bridge"),
br(),
h3("In 3D"),
Expand Down

0 comments on commit 5b42f9e

Please sign in to comment.