Skip to content

Instantly share code, notes, and snippets.

@alisterburt
Created August 8, 2022 14:58
Show Gist options
  • Select an option

  • Save alisterburt/706cbdff00e7011064dbf09589bbe972 to your computer and use it in GitHub Desktop.

Select an option

Save alisterburt/706cbdff00e7011064dbf09589bbe972 to your computer and use it in GitHub Desktop.
ribosome tilt-series simulation
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alisterburt

alisterburt commented Aug 22, 2022 via email

Copy link
Copy Markdown
Author

@inter1965

Copy link
Copy Markdown

Still something wrong.

Ah, you will need to invert the rotations then Sent from mobile - apologies for brevity

On 21 Aug 2022, at 13:42, Xhark @.> wrote: @. commented on this gist. The result of ReconstructParticleTomo doesn't resemble a ribosome structure. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

@alisterburt

Copy link
Copy Markdown
Author

had a look - model_orientations is multiplying coordinates which are zyx not xyz, that's the source of the error

@inter1965

Copy link
Copy Markdown

Does that mean rlnTomoProjX should be row 3 and rlnTomoProjZ should be row 1 of transformations?

had a look - model_orientations is multiplying coordinates which are zyx not xyz, that's the source of the error

@alisterburt

alisterburt commented Aug 23, 2022

Copy link
Copy Markdown
Author

No, rlnTomoProjXYZW are fine, you would need to exchange columns 1 and 3 in the rotation matrices for the particles then exchange rows 1 and 3

@inter1965

inter1965 commented Aug 23, 2022

Copy link
Copy Markdown

something like below? looks like the transpose of the rotation matrix inside the affine transformation matrix.
inverse_transformations = transformations.copy()
for no in range(transformations.shape[0]):
inverse_transformations[no, :3, [2, 0]] = transformations[no, :3, [0, 2]]
inverse_transformations[no, [2, 0], :3] = inverse_transformations[no, [0, 2], :3]

No, rlnTomoProjXYZW are fine, you would need to exchange columns 1 and 3 in the rotation matrices for the particles then exchange rows 1 and 3

@alisterburt

Copy link
Copy Markdown
Author

I don't think so, here is some guidance...

  • transformations are the (4, 4) projection matrices which related 3D position to 2D position in tilt-image
  • model_orientations is a stack of (3, 3) rotation matrices which rotate the model (ribosome Ca coordinates) around its center

The problem is that I didn't need to keep track of the orientations carefully, I just wrote them out into the file for compatibility. To be sure they are correct you need to track what these matrices are transforming (xyz column vectors? zyx column vectors?) and how that data is placed into 3D/2D (axes of images are ordered zyx, slowest to fastest in memory)

All of these must be consistent and the conversion from rotation matrix to euler angles must follow the RELION convention for your experiment to produce the result you expect :) be careful, active rotation of coordinates is the inverse of the rotation of the coordinates of the fourier slice which is what relion does internally with its euler angles

@inter1965

inter1965 commented Aug 24, 2022

Copy link
Copy Markdown

Thanks for the explanation, hence it should be something below,
inverse_model_orientations = model_orientations.copy()
inverse_model_orientations[:, :, :, [2, 0]] = model_orientations[:, :, :, [0, 2]]
inverse_model_orientations[:, :, [2, 0], :] = inverse_model_orientations[:, :, [0, 2], :]

I don't think so, here is some guidance...

  • transformations are the (4, 4) projection matrices which related 3D position to 2D position in tilt-image
  • model_orientations is a stack of (3, 3) rotation matrices which rotate the model (ribosome Ca coordinates) around its center

The problem is that I didn't need to keep track of the orientations carefully, I just wrote them out into the file for compatibility. To be sure they are correct you need to track what these matrices are transforming (xyz column vectors? zyx column vectors?) and how that data is placed into 3D/2D (axes of images are ordered zyx, slowest to fastest in memory)

All of these must be consistent and the conversion from rotation matrix to euler angles must follow the RELION convention for your experiment to produce the result you expect :) be careful, active rotation of coordinates is the inverse of the rotation of the coordinates of the fourier slice which is what relion does internally with its euler angles

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment