natverse / neuprintr

R client utilities for interacting with the neuPrint connectome analysis service
http://natverse.org/neuprintr
3 stars 3 forks source link

Flow centrality #45

Closed alexanderbates closed 4 years ago

alexanderbates commented 4 years ago
jefferis commented 4 years ago

@romainFr do you have any comments on this?

Sent from my iPhone

On 27 Jan 2020, at 22:37, Alexander Bates notifications@github.com wrote:

@alexanderbates requested your review on: #45 Flow centrality.

— You are receiving this because your review was requested. Reply to this email directly, view it on GitHub, or unsubscribe.

romainFr commented 4 years ago

I haven't thought much about flow centrality, but it does sound like it could be a nice feature to add. I'd need to get a bit more familiar with neuron objects and Casey's algorithm before giving very insightful feedback though.

jefferis commented 4 years ago

Hmm, I have a feeling that there are certain neuron features first implemented in catmaid that really ought to be added to nat at this point. This includes generic handling of

You are right @alexanderbates that I hadn't thought through re connectors that it is currently defined in the catmaid package only. One option would be to define the generics in nat and leave the implementation of specific methods to other packages.

In fact this would probably allow us to avoid writing such methods in a number of cases. Take

xform.catmaidneuron<-function(x, reg, ...) {
  xt=NextMethod(x)
  conns <- connectors(x)
  if(!is.null(conns)) {
    xyzmatrix(conns) <-  xform(xyzmatrix(conns), reg=reg, ...)
    xt[['connectors']] <- conns
  }
  xt
}

I think if we defined a connectors generic in nat. We could then change xform.neuron in nat to something like:

xform.neuron<-function(x, reg, FallBackToAffine=TRUE, na.action='error', ...) {
  points=xyzmatrix(x)  
  pointst=xformpoints(reg, points, FallBackToAffine=FallBackToAffine, 
                na.action=na.action, ...)
  xyzmatrix(x)<-pointst
  conns <- connectors(x)
  if(!is.null(conns)) {
    xyzmatrix(conns) <-  xform(xyzmatrix(conns), reg=reg, ...)
    x[['connectors']] <- conns
  }
  x
}

In fact we could do even better and eliminate the second call to xform by rbinding the node and connector locations together.

alexanderbates commented 4 years ago

@jefferis we should make synapses a feature of nat. In the meantime, the contents of this branch has been moved to a new package specifically for hemibrain data analysis: https://github.com/flyconnectome/hemibrainr