Support #1902
open
aligning defocus pairs - switching to phase correlation
Added by Gabriel Lander over 12 years ago.
Updated over 12 years ago.
Category:
Python scripting
Affected Version:
Appion/Leginon 2.1.0
Description
When trying to align noisy defocal pairs when the en image is less than 1um defocus, cross correlation does a very bad job, failing about 75% of the time. I updated defocal pair alignment to first low pass filter the image to twice the pixel size before binning, and then use phase correlation to find the peak.
This seems to work about 95% of the time now, and in my tests still works well on en images that are further from focus. Although this is working for us really well now, it should be further tested, and maybe this should be turned into an option when working with defocal pairs.
- Assignee changed from Anchi Cheng to Gabriel Lander
- Priority changed from Normal to Immediate
Gabe, r16906 causes a circular import of apDatabase imports apDefocalPair and apDefocalPair imports apDatabase. Need fixing
just noticed this, 5 people from 2 labs just emailed me complaining that appion is broken. Is there another way to get the pixel size from an image?
inelegant solution is importing apDatabase inside the function
r16910
Gabe,
I don't have good solution for circular import. Appion modules are not organized enough for me to point you to a better place.
The other possibility to get around the problem is that since you don't care about the actual pixel size in this case, just fake it to be 1.0.
Funny part about your use of apImage.filterImg() is that radius is default to 0.0 and therefore it would not do any low pass filter anyway.
good point, we don't need pixel size. I was using a hard value of 20 for testing before I switched to using the shrink factor, I didn't think to take it out.
But I'm confused about why it would be using rad=0
apImage.filterImg(imgdata1['image'],apix1,apix1*shrinkfactor1*2)
can be changed to
apImage.filterImg(imgdata1['image'],1.0,shrinkfactor1*2)
but it will still use rad=0.0 unless I specify a radius & bin?
Neil,
I think filterImg is your code. Any comment?
- Assignee changed from Gabriel Lander to Neil Voss
- Priority changed from Immediate to Urgent
Neil,
Sorry I forgot to add you as watcher. Please assign back to Gabe after you comment on the filtering behavior.
I've changed apDefocalPair.py in r16921 with fake apix but I still think he might not get the filtering effect without a radius.
So, on the circular import, can we remove the "import apDefocalPairs" from apDatabase.py, maybe move the functions in question to a new file or apDefocalPairs. apDatabase is a pretty low level file.
On the fix r16921, there is a typo, binnning2 has three "n".
As for the default, radius=0.0 means do not filter. I added the function in March 2007, when I was changing "Selexon" and Scott was still at AMI. So, I have little insight.
I have not done enough with defocal pairs to offer any algorithm help either. But I thought I had it working pretty well at the time, I cannot say why I chose cross-correlation over phase-correlation.
- Assignee changed from Neil Voss to Gabriel Lander
- Category set to Python scripting
- Assignee changed from Gabriel Lander to Anchi Cheng
- Priority changed from Urgent to Normal
removed all the apix stuff, just use 1.0 & shrinkfactor*2 as the radius for filtering. This is working very well for our close-to-focus defocal pairs at this end.
Also available in: Atom
PDF