-
Notifications
You must be signed in to change notification settings - Fork 12
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
Scale pixels to SI units #366
Comments
One way to achieve this in a more general way would be via the envisioned An example follows: from movement.transforms import scale
# Convert pixels to cm (assume 10 pix/cm)
# Passing a float/int as a factor results in uniform scaling across all `space` dims
ds.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 corner
ds.position = translate(ds.position, to=[arena.xmin, arena.ymin])
# scale so that arena extents are in [0, 1] range
ds.position = scale(ds.position, factor=[1/xsize, 1/ysize]) If |
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: