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

[WIP] units #498

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

[WIP] units #498

wants to merge 1 commit into from

Conversation

dokato
Copy link
Contributor

@dokato dokato commented May 27, 2022

I decided to include my first attempts to suport units in nat (#470) for reference.

I used units package and implemented assignement of units to XYZW columns of a d matrix.

Known problems:

  • when using Ops it resets to unitless:
> head(pnu$d,2)
  PointNo Label             X             Y             Z         W Parent
1       1     2 186.8660 [um] 132.7093 [um] 88.20393 [um] 1.01 [um]     -1
2       2     2 187.3355 [um] 131.1558 [um] 90.59680 [um] 1.27 [um]      1
> head((pnu+3)$d, 2)
  PointNo Label        X        Y         Z         W Parent
1       1     2 189.8660 135.7093  91.20393 1.01 [um]     -1
2       2     2 190.3355 134.1558  93.59680 1.27 [um]      1
  • Problems with operations that have units
> pnu+ set_units(3,'um')
Error in pnu + set_units(3, "um") : 
  non-numeric argument to binary operator
In addition: Warning message:
Incompatible methods ("Ops.neuron", "Ops.units") for "+" 
  • assigning extra class doesn't really help
> class(pnu) <- c(class(pnu), "units")
> pnu
'neuron' with 180 vertices in 1 tree and additional classes 'units'
> pnu + set_units(3,'um')
  • custom generic set_units.neurons doesn't seem to be recognized
> set_units(pn)
Error in UseMethod("set_units") : 
  no applicable method for 'set_units' applied to an object of class "c('neuron', 'list')"

Happy to take some pointers.

TODO:

  • fix all issues above
  • resample with units

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.

1 participant