Skip to content

Commit

Permalink
making mrc file
Browse files Browse the repository at this point in the history
  • Loading branch information
milesagraham committed May 17, 2024
1 parent d67cb06 commit 12d56d2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/ttmask/sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@
import napari
import typer
from scipy.ndimage import distance_transform_edt
import mrcfile


@cli.command(name='sphere')
def sphere(
boxsize: int = typer.Option(...),
sphere_diameter: float = typer.Option(...),
soft_edge_size: int = typer.Option(...),
):

sphere_radius = sphere_diameter / 2
c = boxsize // 2
center = np.array([c, c, c])
mask = np.zeros(shape=(boxsize, boxsize, boxsize), dtype=np.float32)

center = np.array([boxsize // 2, boxsize // 2,
boxsize // 2])
mask = np.zeros(shape=(boxsize, boxsize, boxsize))
print(mask.dtype)

# 2d positions of all pixels
positions = np.indices([boxsize, boxsize, boxsize])
Expand All @@ -37,7 +39,5 @@ def sphere(

mask[boundary_pixels] = (0.5 * np.cos(normalised_distance_from_edge) + 0.5)

viewer = napari.Viewer(ndisplay=3)
viewer.add_image(mask)
napari.run()

# mrcfile.read("bla.mrc")
mrcfile.write("sphere.mrc", mask, voxel_size=4, overwrite=True)

0 comments on commit 12d56d2

Please sign in to comment.