Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flow centrality #45

Closed
wants to merge 7 commits into from
Closed

Flow centrality #45

wants to merge 7 commits into from

Conversation

alexanderbates
Copy link
Collaborator

  • Not currently available in the natverse (only clunky catnat)
  • Could also go in catmaid package
  • Needs synapses, might not be appropriate for nat
  • A little slow, needs speeeding up

* Not currently available in the natverse (only clunky catnat)
* Could also go in catmaid package
* Needs synapses, might not be appropriate for nat
* A little slow, needs speeeding up
@jefferis
Copy link
Contributor

jefferis commented Jan 27, 2020 via email

R/neurons.R Show resolved Hide resolved
@romainFr
Copy link
Collaborator

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.

nodes[, c("post","pre","up.syns.in","up.syns.out","flow.cent")] = 0
nodes[,"Label"] = 3
nodes = nodes[unlist(c(root, lapply(segs, function(x) x[-1]))),]
syns.in = x$connectors[x$connectors$prepost == 1, ][, "treenode_id"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general connectors(x) is preferred to x$connectors since some day the details of how we store synapse information could change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could import from rcatmaid

Copy link
Collaborator Author

@alexanderbates alexanderbates left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose the question is whether or not we want this package to just deal with sending cyphers and making other API queries, or whether we want bits of code that help analysis of data retrieved from neuPrint. In general we do not perhaps, but things like flow_centrality are fairly specifically useful for neuprint/catmaid neurons.

@jefferis
Copy link
Contributor

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

  • synapses
  • tags
  • somata

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
Copy link
Collaborator Author

@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

@alexanderbates alexanderbates deleted the flow-centrality branch February 5, 2020 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants