-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CTF metadata parameters #87
Conversation
pyem/metadata.py
Outdated
df[star.Relion.BEAMTILTX] = np.arcsin(cs['ctf/tilt_A'][:, 0] / cs['ctf/cs_mm'] * 1e-7) * 1e3 | ||
df[star.Relion.BEAMTILTY] = np.arcsin(cs['ctf/tilt_A'][:, 1] / cs['ctf/cs_mm'] * 1e-7) * 1e3 | ||
df[star.Relion.Z_neg1_3] = df[star.Relion.BEAMTILTX] # does this also require a conversion factor of 2π * Cs * λ^2 | ||
df[star.Relion.Z_pos1_3] = df[star.Relion.BEAMTILTY] # does this also require a conversion factor of 2π * Cs * λ^2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this also need a conversion factor, or is that already taken care of in BEAMTILTX and BEAMTILTY?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the _3 coefficients are 2 * π * λ**2 times the tilt vector (tilt_A
) like in Eqn 5 from the older "new tools for automated high-resolution..." paper.
In Zernike terminology these are the horizontal and vertical coma components. Then there are the "vertical and oblique trefoil" Z(-3,3) and Z(3,3), I think they have the same prefactor as the tilt and are called 'trefoil_A' in cryoSPARC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the _3 coefficients are 2 * π * λ**2 times the tilt vector (tilt_A) like in Eqn 5 from the older "new tools for automated high-resolution..." paper.
Did you mean to write 2 * π * Cs * λ**2
here instead? Equation 5 includes the Cs (spherical abberation) term, and we also used 2 * π * Cs * λ**2
as the prefactor for the trefoil terms in the code here too.
I'm going to proceed on the assumption that you did mean to say 2 * π * Cs * λ**2
, so if that's not the case please clarify and I can edit/fix things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... although I see here that the cs['ctf/cs_mm']
term was divided out from ctf/tilt_A
, so perhaps i should not be re-introducing it.
|
In case you're curious, I just ran it on a test file I had lying around, and got this output for the data_optics metadata in the output .star file:
I don't know if the quotation marks around our Zernike coefficient strings will be a problem for Relion to parse, that's another thing to check. |
@GenevieveBuckley I ended up merging this into a new branch, since it was easier for me to review and make changes that way. I did some refactoring to match the code I had already put in the master branch for the star.Relion and star.UCSF constants, and for writing the Zernike coefs field out to a star file in the right format and order for Relion. I also pulled out all of the π/wavelength/etc prefactors into some pre-computed variables. Apologies if it's a little disorienting! I think this way is less error prone, but it also might be less readable / easy to connect to the equations. We could change it back if you think that is best. Finally, I corrected the conversions according to my current understanding. I think we should test it with some data where CTF refinement in both Relion and cryoSPARC yields a similar improvement to the resolution, and then compare the coefficients we obtain. I have a feeling they might only be correct to some linear operation. When we're sure the branch is ready we can squash it into one commit and merge with the master branch. I'll probably ask you to do that in another PR at that point so that the credit is reflected clearly on GitHub. |
Ah, I was a bit confused about why this was marked merged, makes much more sense if you've put it into a separate branch to test things with. Thank you for refactoring some things. I'll head over to your Sure, squash merging a second PR sounds like the cleanest way to do it. |
Closes #86
Converting the CTF parameter metadata from CryoSPARC back to Relion star files.
This work is in progress, I'm opening the PR to make collaboration & code review easier. I've tried to implement the suggestions from #86 (comment).