teamtomo / ttmask

Mask creation CLI tool for cryo-EM/ET
BSD 3-Clause "New" or "Revised" License
3 stars 3 forks source link

Spherical mask issues #46

Open jojoelfe opened 1 month ago

jojoelfe commented 1 month ago

Description

Thanks @milesagraham for this awesome tool!

I've tried to generate a spherical mask using this command:

ttmask sphere --sidelength 12 --sphere-diameter 12 --output ../../../mask.mrc

but the resulting mrc was all 0.

When I manually run this code (whithout edge moothing and shell creation) things seem to work:

from ttmask.box_setup import box_setup
sphere_radius = 6

# establish our coordinate system and empty mask
coordinates_centered, mask = box_setup(12)

#determine distances of each pixel to the center
distance_to_center = np.linalg.norm(coordinates_centered, axis=-1)

# set up criteria for which pixels are inside the sphere and modify values to 1.
inside_sphere = distance_to_center < (sphere_radius / 1)
mask[inside_sphere] = 1

but the resulting spherical mask does appear to not be quite centered:

image

Happy to dig into this myself at some point, but thought I should let you know first.

milesagraham commented 1 month ago

Hi @jojoelfe , thanks for this. I hadn't updated the package to fix the sphere bug. Sorry about that - it is done now so the mrc will no longer be blank if you upgrade.

Re. mis-centering, I'm taking a look and hopefully find what I've got wrong. It isn't immediately obvious to me, so bear with me while I figure it out!

Many thanks for your catch, Miles