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

symmetric_manc drops body position #16

Open
dokato opened this issue Jun 14, 2021 · 3 comments
Open

symmetric_manc drops body position #16

dokato opened this issue Jun 14, 2021 · 3 comments

Comments

@dokato
Copy link
Collaborator

dokato commented Jun 14, 2021

What is?

After calling symmetric_manc soma coordinates become NA:

> before
      bodyid       X       Y       Z     n                from                  to nside
10004  10004 20958.5 39272.5 41095.5  6249 20958, 39292, 40809 20959, 39253, 41382     L
10010  10010 21441.0 39443.5 59953.0  6724 21441, 39725, 60635 21441, 39162, 59271     L
10011  10011 31054.5 39992.0 40853.5 12686 30141, 39992, 39865 31968, 39992, 41842     R
10013  10013 13448.5 37048.5 41536.0  1259 13448, 38253, 41587 13449, 35844, 41485     L
10014  10014 10637.0 31555.5 46236.0   103 10640, 32351, 46195 10634, 30760, 46277     L
10016  10016 17567.0 21542.0 50313.0  2999 17102, 21542, 49816 18032, 21542, 50810     L
> after #symmetric_manc
      bodyid  X  Y  Z     n                from                  to nside 
10004  10004 NA NA NA  6249 20958, 39292, 40809 20959, 39253, 41382     L 
10010  10010 NA NA NA  6724 21441, 39725, 60635 21441, 39162, 59271     L          
10011  10011 NA NA NA 12686 30141, 39992, 39865 31968, 39992, 41842     R     
10013  10013 NA NA NA  1259 13448, 38253, 41587 13449, 35844, 41485     L     
10014  10014 NA NA NA   103 10640, 32351, 46195 10634, 30760, 46277     L   
10016  10016 NA NA NA  2999 17102, 21542, 49816 18032, 21542, 50810     L

Expected behaviour

Soma positions become symmetrised too.

@jefferis
Copy link
Contributor

Thanks for pointing this out. It is a units problem. symmetric_manc wants coordinates in microns but these coords are in raw voxels. Given how different they are I think we could probably add some logic inside symmetric_manc to guess. Even better would be a reusable function that did this any time we wanted to use xyzmatrix. Perhaps something like this:

manc_xyzmatrix<-function(x, inunits=c("guess", "raw", "microns"), outunits=c("in", "raw", "microns"), ...) {
}

Better still would be general units support for nat!

@dokato
Copy link
Collaborator Author

dokato commented Jun 18, 2021

Actually, what happened here is

after <- symmetric_manc(before/125)

but indeed, the division does not apply to X,Y,Z. As I always forget what data you need to divide by what, I'll have a look at units support soon.

@jefferis
Copy link
Contributor

There is special handling for attached metadata data.frames for xform.neuronlist

https://github.com/natverse/nat/blob/master/R/xform.R#L209-L228

however it is controlled by an argument since it would be possible to have XYZ metadata columns that you didn't want to be touched.

*.neuronlist is much simpler:

https://github.com/natverse/nat/blob/2da55fa227666471d0231b90dde0fe565a519860/R/neuronlist.R#L945

it should probably be translated to Ops.neuronlist but implement Ops is slightly more complicated. Here is the implementation for Ops.neuron

https://github.com/natverse/nat/blob/88507a819c2b4b4f16ada74a79560abc4d260fc5/R/neuron.R#L345

we would either need to

  • add the same kind of data.frame logic to *.neuronlist and +.neuronlist and have it always on, or relegate more complex scaling operations to scale.neuronlist or scale.neuron.

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

No branches or pull requests

2 participants