Project

General

Profile

Actions

Support #1902

open

aligning defocus pairs - switching to phase correlation

Added by Gabriel Lander about 12 years ago. Updated about 12 years ago.

Status:
Assigned
Priority:
Normal
Assignee:
Category:
Python scripting
Target version:
-
Start date:
07/10/2012
Due date:
% Done:

0%

Estimated time:
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.

Actions #1

Updated by Anchi Cheng about 12 years ago

  • 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

Actions #2

Updated by Gabriel Lander about 12 years ago

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

Actions #3

Updated by Anchi Cheng about 12 years ago

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.

Actions #4

Updated by Gabriel Lander about 12 years ago

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?

Actions #5

Updated by Anchi Cheng about 12 years ago

Neil,

I think filterImg is your code. Any comment?

Actions #6

Updated by Anchi Cheng about 12 years ago

  • 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.

Actions #7

Updated by Neil Voss about 12 years ago

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.

Actions #8

Updated by Neil Voss about 12 years ago

  • Assignee changed from Neil Voss to Gabriel Lander
Actions #9

Updated by Gabriel Lander about 12 years ago

  • 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.

Actions

Also available in: Atom PDF