timothygrant80 / cisTEM

Other
32 stars 26 forks source link

Spurious bans of intensity near edges of MIP files after template matching #512

Open mgiammar opened 1 month ago

mgiammar commented 1 month ago

I've been analyzing template matching results on ribosomes for a large number of micrographs, and a fairly consistent issue I've been seeing is a large band of high intensity near the edges of the MIP and scaled MIP files. This is not totally detrimental to the project results since I can crop out these portions when they arise, but I want to make this bug report to see if there is a quick fix for this issue and to make sure my understanding of the template matching pipeline is accurate.

I've also checked to make sure that these bands of artifacts are not coming from another data acquisition or processing step. These show up on movies produced on different microscopes at different pixel sizes and with movies aligned from Ublur, MotionCor3, and direct summing of the movie frames.

Brief data processing pipeline (for images shown)

4096x4096 micrographs at pixel size of 0.95 Å/px. Template of large ribosomal subunit at 0.95 Å/px with shape of 512x512x512.

Movies were aligned with MotionCor3 with local patch alignment, then template matching was run via the CLI using cisTEM version b21db55.

Observed behavior

For some of the 2D micrographs (~10%), the scaled MIPs show strong intensities around the edges; all other output statistic files show similar structures. These streaks generally end 256 pixels from the edges of the image. The correlation average shows bands of high/low intensity around the edges as opposed to the structured correlation averages near the centers of the image.

match_tempalte artifacts

The structure projections from make template result also show odd behavior, probably because many locations from the micrograph are being called above the z-score threshold.

image

Other projections from the same dataset look normal:

image

Expected behavior

Scaled MIPs are roughly isotropic throughout space with some small but high-intensity clusters of pixels corresponding to locations of ribosomes. No streaky artifacts along the edges of any of the output statistics.

My interpretation of the bug and template matching pipeline

I have a good theoretical understanding of how template matching works by taking Fourier slices of a structure and doing the cross correlation operation in the Fourier domain, and I believe the convention cisTEM uses is peak locations correspond to the centers of particles in the image; this is done by padding half the heigh and width of the template projection (512/2=256) along each axis of the image. Since these artifacts end 256 pixels from the edge of the images I suspect these two are related.

Is there anything special the match template program is doing for padding other than zero-padding (i.e. mean-padding or edge-padding)?

Are there any workarounds to this besides cropping out the affected areas?

Thanks again for your help!

jojoelfe commented 1 month ago

make_template_result has a parameter called "Ignore N pixels from the edge of the MIP", which by default (if you enter -1) should be set to 1/2 of the template. Did you use something else?

No good idea what happend in the case of weird reprojection...

mgiammar commented 1 month ago

Thanks for the quick reply. The parameter for "Ignore N pixels from the edge of the MIP" was set to the default of -1. Makes sense given how the cross-correlation is being done.

I agree that the reprojection is super weird.

bHimes commented 1 month ago

It looks like the projections have relatively strong density around the edges, likely ghosting (aliasing) which can be caused by a number of factors depending on how your 3d template was prepared.

Could you describe your template generation and also share the 3d for us to take a look at?

mgiammar commented 1 month ago

The template was generated using the simulate program in cisTEM with the following parameters:

        **   Welcome to Simulator   **

             Version : 0.25
            Compiled : Mar 28 2024
     Library Version : 2.0.0-alpha-295-b21db55-dirty
         From Branch : ctffind5_merge
                Mode : Interactive

Output filename [lsu.mrc]                          : lsu2.mrc
Make a 3d scattering potential? [yes]              : 
Wanted output size [512]                           : 
Number of threads [8]                              : 
PDB file name [parsed_6Q8Y.pdb]                    : 
Add another type of particle? [no]                 : 
Output pixel size (Angstroms) [0.95]               : 
Linear scaling of per atom bFactor [1]             : 
Per atom (xtal) bFactor added to all atoms [0]     : 

Oversampling your 3d by a factor of 2 for calculation.
electrons/Ang^2 in a frame at the specimen [1.0]   : 
number of frames per movie (micrograph or tilt)
[50]                                               : 
Set expert options? [no]                           : 

Here's a download link for the template: https://berkeley.box.com/s/9wot6fazi8l27lmr4ayrjo9iby1rbz98 Let me know if have any issues downloading it.

Thanks again for taking a look at this!