This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import einops | |
import numpy as np | |
import torch | |
import mrcfile | |
import napari | |
from torch_fourier_slice import project_3d_to_2d | |
from torch_image_lerp import sample_image_2d | |
from torch_grid_utils import coordinate_grid | |
from scipy.spatial.transform import Rotation as R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from scipy.spatial.transform import Rotation as R | |
# set up rotation matrices for rotations around X axis | |
rotation_angles = np.linspace(0, 90, 50) | |
Rx = R.from_euler('x', angles=rotation_angles, degrees=True).as_matrix() | |
print(Rx.shape) | |
# set up column vector which points along y | |
z_vec = np.array([0, 0, 1]).reshape((3, 1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://docs.google.com/presentation/d/1QD6J1SR2_Q_7DivvtIE_P1ScrFGcU9yk-46ZmVavmf0/edit#slide=id.g27333d73966_0_16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import starfile | |
import napari | |
from scipy.spatial.transform import Rotation as R | |
df = starfile.read('particles_warp.star') | |
xyz = df[['rlnCoordinateX', 'rlnCoordinateY', 'rlnCoordinateZ']].to_numpy() | |
eulers = df[['rlnAngleTiltPrior', 'rlnAnglePsiPrior']].to_numpy() | |
rotation_matrices = R.from_euler(seq='YZ', degrees=True, angles=eulers).inv().as_matrix() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
from cmap import Colormap | |
h, w = 512, 868 | |
image = np.random.random(size=(h, w)) | |
defocus = np.array([[0, 1], | |
[1, 0]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Recenter and reorient RELION particles | |
This shows the gist of how to manually move/reorient RELION particles in 3D. | |
You define a set of shifts and orientations in the coordinate system of the | |
reference for all 'subparticles' you want to generate from each existing particle. | |
""" | |
import pandas as pd | |
import starfile | |
import numpy as np | |
from scipy.spatial.transform import Rotation as R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import napari | |
import numpy as np | |
from skimage import data | |
from napari_threedee.manipulators.base_manipulator import BaseManipulator | |
class FullManipulator(BaseManipulator): | |
def __init__(self, viewer, layer=None): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import torch | |
import einops | |
import mmdf | |
from libtilt.grids._patch_grid_utils import patch_grid_centers | |
from libtilt.grids import coordinate_grid | |
RESOLUTION_ANGSTROMS = 3.4 | |
VOLUME_SIZE = (512, 512, 512) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import einops | |
def sliding_window_3d(tensor, window_size): | |
d, h, w = tensor.shape | |
window_depth, window_height, window_width = window_size | |
# Calculate the number of windows in each dimension | |
new_d = d - window_depth + 1 | |
new_h = h - window_height + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import h3 | |
import torch | |
import einops | |
from scipy.spatial.transform import Rotation as R | |
def get_h3_grid_at_resolution(resolution: int) -> list[str]: | |
"""Get h3 cells (their h3 index) at a given resolution. |
NewerOlder