ComputationalCryoEM / ASPIRE-Python

Algorithms for Single Particle Reconstruction
http://spr.math.princeton.edu
GNU General Public License v3.0
46 stars 21 forks source link

Read pixel size from STAR file #322

Open janden opened 3 years ago

janden commented 3 years ago

In RelionSource, we should have the ability to read the pixel size from the STAR file if it's not supplied as an argument.

chris-langfield commented 2 years ago

I stumbled on this issue while looking for something else. I did a bit of digging and found that there are a few Relion metadata labels that could correspond.

Running relion_refine --print_metadata_labels | grep Pixel (with Relion 3.1) shows me:

          rlnDetectorPixelSize (double) : Pixel size of the detector (in micrometers)
             rlnImagePixelSize (double) : Pixel size (in Angstrom)
rlnMicrographOriginalPixelSize (double) : Pixel size of original movie before binning in Angstrom/pixel.
        rlnMicrographPixelSize (double) : Pixel size of (averaged) micrographs after binning in Angstrom/pixel.
                  rlnPixelSize (double) : Size of the pixels in the references and images (in Angstroms)
     rlnResolutionInversePixel (double) : Resolution (in 1/pixel, Nyquist = 0.5)

It seems like what we may want is rlnImagePixelSize, if we find it in the STAR file we are given. It may depend on what stage in the Relion pipeline the star file we give ASPIRE is at.

garrettwrong commented 2 years ago

It may depend on what stage in the Relion pipeline the star file we give ASPIRE is at.

😨

janden commented 2 years ago

Yeah I'd go for rlnImagePixelSize. If it's there, we can use it, otherwise we require it provided by the user.

garrettwrong commented 1 year ago

We get asked about pixel size sometimes when we demo. It might be nice to knock this out...

chris-langfield commented 1 year ago

After looking through a lot of RELION tutorial data, I believe rlnImagePixelSize is indeed what we want.

However, this columns seems to have been introduced only in RELION 3.1. This is also the version where a new standard for data starfiles was introduced. In 3.0 and earlier there was just one data_ block containing particles, but 3.1 and later introduces the data_optics block in starfiles. The rlnImagePixelSize parameter only appears in this block, not in the particles block. Our RelionSource seems to be set up to read only starfiles from 3.0 and earlier. This does, however, match the version of a lot of the EMPIAR datasets we're working with.

We should consider updating RelionSource.populate_metadata() to be able to handle both styles in light of this. (This issue would be resolved as part of this larger project)

There is code in CoordinateSource that could be relevant as far as handling optics group blocks:

https://github.com/ComputationalCryoEM/ASPIRE-Python/blob/0bd790b954fc74d4d003b06f5a2b21586b352447/src/aspire/source/coordinates.py#L288-L335

chris-langfield commented 1 year ago

To allow for multiple subsets of a data set having different Zernike coefficients, relion-3.1 implements the new concept of optics groups. Optics groups are defined in a separate table called data_optics at the top of a STAR file, which will also contain a table called data_movies, data_micrographs or data_particles, depending on what type of images it refers to. The second table is similar to the content of STAR files in previous releases, but contains a new column called rlnOpticsGroup, which is also present in the dataoptics table. Common CTF-parameters, like rlnVoltage and `rlnSphericalAberration, but also the new rlnOddZernike and rlnEvenZernike, can be stored once for each optics group in the data_optics table, without the need to store them for each particle/micrograph in the second table.

https://relion.readthedocs.io/en/release-3.1/Whats-new.html

garrettwrong commented 1 year ago

Yeah, we should probably make an issue about reading/writing version 3.1 data and link this (or mark this as duplicate). I suspect this is now a medium sized project.

chris-langfield commented 1 year ago

Yep, I'll write one up. I think we can then close this one out but mention that we want to read rlnImagePixelSize in the new issue.

chris-langfield commented 1 year ago

Continue discussion as part of wider issue in #735

garrettwrong commented 1 month ago

Re-opening, incomplete.