Skip to content

Conversation

@PlethoraChutney
Copy link

This PR ensures that refined shifts are correct in STAR files created with csparc2star.py

This discussion in our forum led to us noticing that csparc2star.py uses the image pixel size to convert shifts from pixels to angstroms. However, the shifts in alignment{2D,3D}/shift are in terms of the pixels in alignment{2D/3D}/psize_A, which may differ from the image pixel size if the job which refined these shifts performed on-the-fly downsampling. This results in shifts which are wrong by a factor of the ratio between the two pixel sizes.

image
image
image

(the last 0.02 Å is from all the per-particle scales being reset to 1.0)

Since we don't care about the refinement pixel size in the final star file, I took what seemed the simplest route and just converted them immediately after loading the first .cs file. I tested this with an exported .cs file and the passthrough .cs file from the job itself. Since it looks like cryosparc_2_cs_model_parameters() is never called on passthroughs I think this should always work...

The change to star.py fixes a separate issue in which .star files produced by csparc2star.py never had particle shifts because sync_origins_from_angst() didn't save the _rlnOrigin{X/Y}Angst columns and the _rlnOrigin{X/Y} columns were dropped as deprecated. The missing shifts then prevented CryoSPARC from importing the poses at all. Please do let me know if this isn't a bug and I missed a setting somewhere!

Thanks, and please let me know if you have any more questions or if you need me to rework it some other way!

@asarnow
Copy link
Owner

asarnow commented Jan 28, 2025

@PlethoraChutney I added the missing inplace=True, unfortunately it's not straightforward to cherry pick edits. About the origins, the change of unit is currently the responsibility of the user via --boxsize. I'd like to replace that with the explicit metadata check you have, but it should be around metadata.cryosparc2:349 in a way that doesn't break existing scripts using --boxsize. Or maybe better, it could be in cryosparc2_model_parameters(), where we are already checking for the different types of alignment metadata fields.

@PlethoraChutney
Copy link
Author

Ah, great point. I've moved the apix check to cryosparc2_model_parameters().

@asarnow
Copy link
Owner

asarnow commented Jan 29, 2025

Were those fields present before cryoSPARC v4.5? I guess we either have to put it there, and make --boxsize a no-op, or put it where --boxsize gets used in parse_cryosparc_2_cs() and only do one or the other.

I want a user using old scripts that use --boxsize to do this conversion not to notice a change.

@PlethoraChutney
Copy link
Author

Yes, the {dimension}/psize_A metadata fields have always been around, as far as I can tell (at least since v2). Let me know which of your two suggestions you prefer -- I could also add a check for whether args.boxsize is set to a value that is not close to shape * blob_psize / align_psize?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants