natverse / rcatmaid

R package providing API access to the CATMAID web image annotation tool
https://natverse.github.io/rcatmaid
GNU General Public License v3.0
9 stars 6 forks source link

teach catmaid:::plot3d.catmaidneuron about plotly engine #145

Open jefferis opened 5 years ago

jefferis commented 5 years ago

Currently:

> catmaid:::plot3d.catmaidneuron
function(x, WithConnectors=FALSE, WithNodes=FALSE, soma=FALSE, ...) {
  soma=plot3d_somarad(x, soma)
  rglreturnlist=NextMethod(WithNodes=WithNodes, soma=soma)
  if (WithConnectors) {
    conndf = connectors(x)
    # only try to plot if the neuron has connectors
    if (length(conndf)){
      rglreturnlist[['synapses']] = 
        points3d(xyzmatrix(conndf), col = c(pre ='red', post = 'cyan')[conndf$prepost + 1])
    }
  }
  invisible(rglreturnlist)
}

We need to change the return logic to match plot3d.neuron:

  if (plotengine == 'rgl'){
    invisible(rglreturnlist)
  } else{
    psh <- psh %>% 
      plotly::layout(showlegend = FALSE, scene=list(camera=.plotly3d$camera))
    assign("plotlyscenehandle", psh, envir=.plotly3d)
    psh
  }

and we need to add plotly support for the synaptic locations (i.e. instead of points3d)

jefferis commented 3 years ago

@SridharJagannathan could you check if we can plot catmaid synapses in plotly in rstudio cloud? It may be that we need to fix this issue.