You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
We would like to make it possible for users to express the arrays expressed in pixels in a dataset (or per array?) to SI units.
One way to achieve this in a more general way would be via the envisioned transforms module.
An example follows:
frommovement.transformsimportscale# Convert pixels to cm (assume 10 pix/cm)# Passing a float/int as a factor results in uniform scaling across all `space` dimsds.position=scale(ds.position, factor=0.1, space_unit="cm") # store space_unit in position.attributes
The advantage of this approach is that it would also allow arbitrary scaling factors, not necessarily to metric units.
# Normalise coordinates to a 0-1 range covering a ROI named "arena"arena= {"xmin": 10, "xmax": 690, "ymin": 20, "ymax": 580}
arena["xsize"] =arena["xmax"] -arena["xmin"]
arena["ysize"] =arena["ymax"] -arena["ymin"]
# move origin to arena cornerds.position=translate(ds.position, to=[arena.xmin, arena.ymin])
# scale so that arena extents are in [0, 1] rangeds.position=scale(ds.position, factor=[1/xsize, 1/ysize])
If factor is a scalar, we could interpret it as uniform scale (all 2 or 3 spatial dimensions)
If factor is a list/array-like we could interpret it as 1 factor per x, y, (z) dimensions (length of factor should match number of spatial dimensions).
Is your feature request related to a problem? Please describe.
We would like to make it possible for users to express the arrays expressed in pixels in a dataset (or per array?) to SI units.
Additional context
Somewhat linked to this issue on unit-aware xarrays
The text was updated successfully, but these errors were encountered: