Open dokato opened 2 years ago
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.
units
d
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')
set_units.neurons
> 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:
resample
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 ad
matrix.Known problems:
when using Ops it resets to unitless:
Problems with operations that have units
assigning extra class doesn't really help
set_units.neurons
doesn't seem to be recognizedHappy to take some pointers.
TODO:
resample
with units