Override pixel size in particle level

Greeting there,

I have two datasets collected in two different day in one week, with pixel size information record as 1.0745A and 1.074A in header respectively. I input the pixel size as it is what it is when I impot the movies (1.0745A and 1.074A respectively), the pixel size from the two datasets were all reported as 1.074A after motion correction and CTF estimation. The error was reported when I try to merge the two dataset for 2D classification. Is there any easy way so that I can override the pixel size to keep them same in particle level?

Thanks and cheers,

Hi @yanhezhao,

Unfortunately, you encountered this error because CryoSPARC requires the Å/pix of particle images to be within 0.0001 Å of each other in order to combine them, but we can certainly make some suggestions on how to deal with merging your two datasets! To be sure we give the best advice, it would be really helpful if you could clarify a few things:

  1. Were the two datasets were recorded on:
    a) different microscopes or cameras (i.e. the recorded pixel sizes for the two datasets were genuinely calibrated as different and you are confident in those calibrations).
    b) the same microscope and camera (i.e. one dataset was initially processed with a slightly wrong pixel size and they both should have been the same value).

  2. Did you perform motion correction and CTF estimation in CryoSPARC?

  3. Do you have an intuition about what sort of resolution range this dataset might achieve?

  4. Do you plan to use Reference-Based Motion Correction during your processing pipeline for this data?

Hi @hbridges1,

Thank you so much for your reply.

  1. Two datasets were recorded on b) the same microscope and camera (actually in one week, two datasets were recorded with 1.074A and 1.0745A in the image header respectively). So yes, one dataset was initially processed with slightly wrong pixel size and they both should have been the same value.

2, Yes, I did motion correction and CTF estimation in CryoSPARC. BTW, I checked the header of micrographs from two datasets after motion correction, all have the same value as 1.074A. Based on the error I got which means the pixel size is still writed as 1.0745A in the cs file of one of the datasets.

3, My intuition is 5-7A.

4, I have no plan to use [Reference-Based Motion Correction].

Thanks again,

Hi @hbridges1,

I am trying to solve the problem by following the post ‘pixel size change’.

Using following command I thought I have one of my dataset’s pixel size overrided to 1.0740A in cs.
Then I rextract particles and combine with another dataset for 2D classification, but got same error, which means the override didn’t work.
What command could be used to check the movie_blob/psize_A in the cs?

from cryosparc_compute import dataset
d = dataset.Dataset().from_file(‘/project/cellbiology/Nicastro_lab/nusr/yanhe/linux/data/cryoSPARC/P18/J1538/P18_J1538_passthrough_micrographs.cs’)
d.data[‘movie_blob/psize_A’] = 1.0740
d.to_file(‘/project/cellbiology/Nicastro_lab/nusr/yanhe/linux/data/cryoSPARC/P18/J1538/P18_J1538_passthrough_micrographs.cs’)

Thanks and cheers,

Hi @yanhezhao,

Thanks for getting back with that information!

As the difference in pixel size is rather small in your case, the pixel-size and defocus value discrepancy in the CTF will likely be negligible and it is reasonable to simply adjust the pixel size of the extracted particles as you have attempted.

As your micrographs were imported with a different pixel size, every time you re-extract, cryoSPARC will revert to taking the pixel size information from the micrographs again, and so you will need to adjust the pixel size each time, unless you adjust the pixel size at the micrograph level.

We suggest an approach where the original file is not changed, but a new job is created, so that you can keep a good track of what processes were used during your pipeline. The following procedure works best where the pixel size discrepancy is very small (such as your case) or where particles are expected to benefit from local (defocus) refinement (for example they have good signal-to-noise and are not particularly small).

You can find an example script to adjust the pixel size of particles and check the new pixel size in the output job here. To run the script it would be something like
python change_apix_extract.py P100,W1,J3 1.074 where the final number is the new pixel size that you are specifying.

Instructions for required python libraries and for how to connect to CryoSPARC are in the README here.

The code allows you to adjust the pixel size after extraction to whatever you like and will output the particles to the CryoSPARC GUI as an “external” job type with the title “change_angpix_particles”, or you can give this a different title. You may then go ahead with using these particles in 2D classification. In cases where the data do benefit from local CTF refinement, this can be performed to correct for the mismatch in CTF fit and pixel size, but in your case this in unlikely to be problematic.

For other users or scenarios, limitations to this process are:

  1. if the pixel size discrepancy is more substantial and particles are small or of too low signal-to-noise for local CTF refinement, the CTF mismatch between pixel size and defocus values may adversely affect the achievable resolution or map quality.
  2. reference-based motion correction will not proceed after external manipulation of the particle pixel size.

In either of the above cases, we recommend either re-running motion correction and patch CTF at the correct pixel size or adjusting the pixel size of the micrographs after Patch Motion Correction.

Hi @rposert ,

Thanks a lot for your reply.
To avoid any unexpected trouble, what I am trying to do is override the pixel size in the cs file from the motion correction folder, then re-run the CTF estimation and extract the particles, but looks like the pixel size is not changing. Could you help me out?

Below is the command I used,

from cryosparc_compute import dataset
d = dataset.Dataset().from_file(‘/project/cellbiology/Nicastro_lab/nusr/yanhe/linux/data/cryoSPARC/P18/J1538/P18_J1538_passthrough_micrographs.cs’)
d.data[‘movie_blob/psize_A’] = 1.0740
d.to_file(‘/project/cellbiology/Nicastro_lab/nusr/yanhe/linux/data/cryoSPARC/P18/J1538/P18_J1538_passthrough_micrographs.cs’)

Thanks and cheers,

Hi @yanhezhao,

One option for you is to re-import the movies with the correct pixel size and re-run Patch Motion Correction, Patch CTF and particle re-extraction.

If you prefer to change the pixel size of Patch Motion Corrected micrographs and then only re-run Patch CTF and re-extraction of particles, then it is possible to perform pixel size adjustment on the motion corrected micrographs using cryosparc-tools, and we have provided an example script for this here. To run the script it would be something like:

python change_apix_micrographs.py P100,W1,J3 1.074 where the final number is the new pixel size that you are specifying.

The code allows you to adjust the pixel size of Patch Motion Corrected micrographs to whatever you like and will output the particles to the CryoSPARC GUI as an “external” job type with the title “micrographs_pix_updated”, and in the terminal will output a message to tell you what the external job number and updated pixel size is.

Using either of these strategies will mean that all downstream processing is at the correct pixel size and allow Reference-Based Motion Correction to run, if it is appropriate for the project.

1 Like