Open jgermain22 opened 3 months ago
Hi @jgermain22,
Thanks for the feedback :) Could you please specify more what you mean by "saving the protein locations"?
The feature you requested is (sort of) implemented but not part of the GUI yet, partially because I am not sure which format would be best for integration with subsequent software. Personally, I needed STAR files for my workflow, and I used the following code to create surface oversampling inputs from the collapsed parameterizations.
Rotation handling code I copied from pyTME (https://github.com/KosinskiLab/pyTME/blob/296c1a58e958a48782edad2fdfbceae4cd323858/tme/matching_utils.py#L906)
After you copied the helper functions above to your notebook, you can perform surface oversampling like so:
data = gui.data_structure
models = data.cluster_list_fits_objects
# Average distance of sampled points in units of sampling rate
sampling_rate = 15
# Pixel size in units Unit / Voxel (typically unit is angstrom)
pixel_size = 6.72
# The parametrization is fit to the center of the membrane (minimal error)
# If your downstream tool requires having points on the outer leaflet, you
# can set this half the membrane thickness in unit (typically angstrom)
membrane_offset = 9.5
# Path to output star files
output_prefix = "/path/to/output"
for index, model in enumerate(data.cluster_list_fits_objects):
old_radii = model.radii
model.radii = np.add(model.radii, np.multiply(membrane_offset, data.pixel_size))
# Compute number of required to achieve a given spatial sampling rate
n_samples = model.points_per_sampling(sampling_rate * pixel_size / 2)
# Sample points and corresponding normals from parametrization
points = model.sample(n_samples, sample_mesh = True, mesh_init_factor=5)
normals = model.compute_normal(points)
# Convert sampled points into voxel space
points = np.divide(points, pixel_size).astype(int)
zyz_normals = np.array([
rotation_aligning_vectors(normals[index], convention="zyz")
for index in range(normals.shape[0])
])
write_star(
f"{output_prefix}_{index}.star",
translations=points,
rotations=zyz_normals
)
model.radii = old_radii
Hope that gives you an idea where to start and feel free to reach out in case of issues :)
Best, Valentin
Thank you so much! Is this Relion 4 or Relion 5 coordinates?
I have only used this with Relion 4 so far. Going over the release notes, version 5 appears to be compatible with these star files though
Relion 5 coordinate system is quite different it seems as they set 0,0 as the center of the tomogram rather than the IMOD convention. It looks like its an easy conversion but the coordinate system is in Angstrom rather than pix which is odd. I havent tried it myself but I will soon. https://github.com/3dem/relion/issues/1137
Ah, yes, you will need to add the shift.
gui.data_structure.shape
and gui.data_structure.pixel_size
keep track of the tomogram box size and corresponding voxel size along each axis. Those can be used to compute the scaling factor mentioned in the issue you linked :)
Something like this should do the trick
center = np.multiply(
np.divide(gui.data_structure.shape, 2) - 1,
gui.data_structure.shape.pixelsize
)
points = points - center
# Points are in angstrom already so omit
# points = np.divide(points, pixel_size).astype(int)
Sure Ill give this a try! Are you planning on incorporating this into the GUI?
Yes, this will be added to the GUI :)
However, the timeline isn't set yet, as we are also working on other features, like support for triangular meshes on top of the available parametrizations
Hello! I was wondering what the angel convention is when saving the 'protein locations'?
Also I was wondering if it would be possible to to add functionality to convert the membrane fits to oversampled particle pick locations. Basically making the fits into a grid with a defined sampling then getting the normal vectors for downstream STA. Right now I am using this package (https://github.com/EuanPyle/Membrane_Associated_Picking) but it would be amazing if this kind of functionality was available in colabseg! Thank you again for making a great tool!! Best Jason