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

Is a division by voxel size missing in sphere radius logic? #64

Closed
jasper-tms opened this issue Jan 26, 2025 · 2 comments
Closed

Is a division by voxel size missing in sphere radius logic? #64

jasper-tms opened this issue Jan 26, 2025 · 2 comments

Comments

@jasper-tms
Copy link

It looks to me like sphere_annotation() is expecting radii in the units of the annotation layer (often voxels), and is then scaling z down so that the physical size (nm) of the sphere is the same in all axes:

def sphere_annotation(
center,
radius,
z_multiplier,
id=None,
description=None,
linked_segmentation=None,
tag_ids=None,
):
"""
Assumes the z-axis is anistropic

That seems sensible enough, but that means sphere_annotation() must be called with radii already converted to the unit of the annotation layer. SphereMapper says it expects the radius_column to contain radii in nm, but I think those values are getting passed to sphere_annotation() as those nm values that the user provides, without the conversion to layer resolution that I think needs to happen before calling sphere_annotation():

rs = data[col_rad][relinds].values
if viewer_resolution:
z_multiplier = viewer_resolution[1] / viewer_resolution[2]
else:
z_multiplier = self._z_multiplier
descriptions = self._descriptions(data[relinds])
linked_segs = self._linked_segmentations(data[relinds])
tags = self._assign_tags(data)
annos = [
viewer.sphere_annotation(
pt,
r,

If I'm seeing this correctly, then something like

        rs /= viewer_resolution[1]

could be stuck between the following two lines to do the conversion:

if viewer_resolution:
z_multiplier = viewer_resolution[1] / viewer_resolution[2]

Having added that one line, my spheres now appear at the correct size when I'm passing in nm radii values in an annotation layer that has its units as voxels.

@ceesem
Copy link
Collaborator

ceesem commented Jan 27, 2025

Yeah, good catch. It looks like the current code only scales the points and not the radius. I'll fix this.

@ceesem
Copy link
Collaborator

ceesem commented Jan 30, 2025

Should be fixed by #65 in the current release

@ceesem ceesem closed this as completed Jan 30, 2025
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