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
from lxml import etree | |
json_file = "/Users/burta2/data/fakery/MotionAndCTF2D/average/20170629_00021_frameImage_motion.json" | |
# <GridMovementX Width="1" Height="1" Depth="3" MarginX="0" MarginY="0" MarginZ="0"> | |
# <Node X="0" Y="0" Z="0" Value="-5.1639977" /> | |
# <Node X="0" Y="0" Z="1" Value="0.7089546" /> | |
# <Node X="0" Y="0" Z="2" Value="4.455043" /> | |
# </GridMovementX> | |
# <GridMovementY Width="1" Height="1" Depth="3" MarginX="0" MarginY="0" MarginZ="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
import os | |
from concurrent.futures import ThreadPoolExecutor, as_completed | |
from pathlib import Path | |
def find_relion_dirs(root_dir): | |
""" | |
Recursively walks through the directory and finds all directories that contain a 'Refine3D' or 'Class3D' subdirectory. | |
Args: |
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 ast | |
import einops | |
import numpy as np | |
import starfile | |
from scipy.spatial.transform import Rotation as R | |
DO_VIS = True | |
particle_star = starfile.read('matching.star') |
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 h3 | |
import einops | |
def get_h3_grid_at_resolution(resolution: int) -> list[str]: | |
"""Get h3 cells (their h3 index) at a given resolution. | |
Each cell appears once | |
- resolution 0: 122 cells, every ~20 degrees | |
- resolution 1: 842 cells, every ~7.5 degrees |
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
from enum import Enum | |
from pathlib import Path | |
import starfile | |
import mrcfile | |
import napari | |
import numpy as np | |
from magicgui import magicgui, widgets | |
RECONSTRUCTION_DIR = '/Users/burta2/Downloads/10499/reconstruction' |
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
from pathlib import Path | |
from typing import Sequence | |
import dask | |
import mrcfile | |
import numpy as np | |
import torch | |
import pandas as pd | |
import dask.array as da |
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() |
NewerOlder