Skip to content

Instantly share code, notes, and snippets.

@alisterburt
Created February 28, 2025 17:55
Show Gist options
  • Save alisterburt/87761bb77d0d8d9c5c9d02abf4a5af4a to your computer and use it in GitHub Desktop.
Save alisterburt/87761bb77d0d8d9c5c9d02abf4a5af4a to your computer and use it in GitHub Desktop.
render a projection below a volume in napari
import napari
import mrcfile
import torch
from torch_fourier_slice import project_3d_to_2d
volume = torch.tensor(mrcfile.read("run_class001.mrc")).float()
projection = project_3d_to_2d(volume, rotation_matrices=torch.eye(3))
d, h, w = volume.shape
viewer = napari.Viewer(ndisplay=3)
viewer.add_image(volume.numpy(), translate=[d, 0, 0], name="volume")
viewer.add_image(projection.numpy(), name="projection")
napari.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment