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
Skeletor #35
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @alexanderbates, thanks for the PR. I have made a few comments implying changes. Could you respond to them or ping me if you have queries? Best, G.
R/flywire-skeleton.R
Outdated
savedir <- tempdir() | ||
ff=file.path(savedir, paste0(id, '.obj')) | ||
reticulate::py_run_string(sprintf("m.export('%s')",ff), ...) | ||
res=sapply(ff, readobj::read.obj, convert.rgl = TRUE, simplify = FALSE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since nat 1.10.2 (which is required by fafbseg) read.neurons will read meshes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced
@@ -0,0 +1,10 @@ | |||
base |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexanderbates I'm not really sure about the wisdom of including rmarkdown caches here. Was this intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah no, it was not intentional. Somehow this was generated when I ran build_site().
You can gain access to the `Graphene/Chunkedgraph` server like below: | ||
|
||
1. Visit https://globalv1.flywire-daf.com/auth/api/v1/refresh_token, | ||
2. Copy the token present there, let's say it was "xxyyzz" | ||
3. create a file named `chunkedgraph-secret.json` that has the following contents | ||
3. create a file named `chunkedgraph-secret.json` at location `~.cloudvolume/secrets/chunkedgraph-secret.json`. For example, in Terminal: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo ~.cloudvolume/secrets/chunkedgraph-secret.json
-> ~/.cloudvolume/secrets/chunkedgraph-secret.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorted
4. Save the file in the location `~.cloudvolume/secrets/chunkedgraph-secret.json` | ||
5. Now you have access to the chunked graph server | ||
|
||
You can also use the fafbseg function `set_chunkedgraph_token` to add your token to this file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexanderbates I am about to change this function's name to flywire_set_token
. Furthermore, I think there is really no point in this lengthy description as flywire_set_token
/set_chunkedgraph_token
does everything you need including getting the new token from the flywire website.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay! I just updated these old instructions a bit because i found it helpful
docs/pkgdown.yml
Outdated
@@ -1,10 +1,10 @@ | |||
pandoc: 2.7.3 | |||
pkgdown: 1.5.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexanderbates can you please remove all changes to the docs/ folder. I would rather regenerate this myself after merging to master. Otherwise there are so many changes I find it hard to see the wood from the trees. There is however one thing that is missing, you could please edit _pkgdown.yml
(note leading underscore) to add your new exported function(s). Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an easy way to revert all changes within a specified folder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* we shouldn't need to do this if we are skeletonising .obj files on disk
* 'skeletor' of github.com:natverse/fafbseg: Replace WHO with WH0
* for skeletonisation and radii calculation
* 'skeletor' of github.com:natverse/fafbseg: Update skeletor to work with more methods arguments conflicts due to double edits including in errors where there were logic changes on both sides that needed integrating
* 'skeletor' of github.com:natverse/fafbseg: Add theta argument for mesh cleaning w.r.t skeleton
R/flywire-skeleton.R
Outdated
@@ -21,7 +22,12 @@ | |||
#' You will need to have the \code{ncollpyde} | |||
#' python3 module installed. You can get this with \code{pip3 install ncollpyde}. If you get issues | |||
#' related to this module, best to set this to \code{FALSE}. | |||
#' @param radius Logical. Whether or not to return radius information for each skeleton node. | |||
#' @param theta numeric. Used if \code(clean==TRUE). For each twig we generate the dotproduct between the tangent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexanderbates, this should be \code{clean=TRUE}
. Can you fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't feel like running R CMD check before pushing (which you should), you should at least run devtools::check_man()
to make sure that the docs aren't broken!
@alexanderbates for reference a conditional test along these lines
|
R/flywire-skeleton.R
Outdated
savedir <- if(!is.null(save.obj)){ | ||
save.obj | ||
}else{ | ||
tempdir() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tempdir()
is the root temporary folder of the R session. You should not delete it (as you found out the other day when you were deleting bridging registrations). It is better to make your own temporary folder
dir.create(td<-tempfile())
td
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexanderbates: you should also add an on.exit hook to delete that folder on exit
on.exit(unlink(td, recursive=TRUE))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, done
R/flywire-skeleton.R
Outdated
@@ -364,8 +364,7 @@ py_skeletor <- function(id, | |||
if(reroot){ | |||
neuron = reroot_hairball(neuron, k.soma.search = k.soma.search, radius.soma.search = radius.soma.search, brain = brain) | |||
} | |||
if(mesh3d|save.obj){ | |||
if(is.null(mesh)){ | |||
if(mesh3d|!is.null(save.obj)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexanderbates: as a general rule it is better to use || or && for this kind of logic in if statements as those operators short circuit i.e. they stop evaluating when the value of the expression is certain. So if you do
if(shortcheck() | longcheck())
both are evaluated even if shortcheck() returns TRUE whereas
if(shortcheck() || longcheck())
would stop evaluating if shortcheck() returned TRUE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want convincing, here is some code
fastcheck <- function(x=T) {
message("fast")
x
}
slowcheck <- function(x=T) {
message("slow")
x
}
message("|| operator")
if(fastcheck() || slowcheck()) {
message("if!")
} else {
message("else!")
}
message("| operator")
if(fastcheck() | slowcheck()) {
message("if!")
} else {
message("else!")
}
|| operator
fast
if!
| operator
fast
slow
if!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I'll also apply this more generally.
R wrapper for a skeleton pipeline in python to skeletonise neuron meshes, e.g. from FlyWire. Also, documentation and article describing how to install related python modules (updated version of Istvan Taiusz's flyconnectome slack post)