Gain reference application by Mag_distortion_correction


Recently I could not apply gain reference by using Mag_distortion_correction. What happened is, after applying gain reference, unblur could not align frames correctly and the result image looked terrible. I guess this is due to the update affecting tif2mrc command. So I applied gain reference by using "clip mult -n 16 img.mrc gain.mrc gain_applied.mrc, then used unblur. This worked well. But the problem is... the values in the shift file are slightly different from what I got before with mag_distortion_correction. So I wonder how different mag_distortion_correction & clip command are in applying gain reference. For me, mag_distortion_correction seems working better. So, I wonder whether this issue can be fixed..

Thanks a lot,



In principle, the gain correction is mag_distortion_correction is done exactly as clip does it using the command you showed. That is, it mutliplies the input image by the gain reference image and by a constant of 16. This is the part of the code (in mag_distortion_correct.f90):

do j=1,input_image%GetLogicalDimension(2)
do i=1,input_image%GetLogicalDimension(1)
input_image%real_values(i,j,1) = 16.0 * gain_reference%real_values(i,j,1) * input_image%real_values(i,j,1)

Based on the information presented, I don't have a good guess as to why you're getting bad results now. I don't know what change in tif2mrc could be causing this, other than perhaps if it now flips the image or rotates it when it didn't use to, or vice versa.


In reply to by Alexis

I was suspicious they might change some format of header if there is in mrc file. But it is good to know that Mag_distortion_correction also use the same principle in applying gain reference. Thanks!



It turned out that IMOD new version (4.8) writes bytes signed while older version writes bytes unsigned. (I do not understand what this exactly means, but you would). And this change made my mag_distortion_correction go wrong. After I switched IMOD to older version, it worked again. Thanks for your reply.

And can I ask you another question? For me, mag_distortion_correction looks working better than just using 'clip' and 'binvol' commands in IMOD. And David Mastronarde suspected that Mag_distortion_correction is "binning" by Fourier cropping to avoid the loss of high frequency information and the possible aliasing. Is this correct?

Thanks again for your help, in advance.


In reply to by JinYoung

Hi Jin,

Thanks for clarifying regarding IMOD's change with regards to signed/unsigned integers. Unfortunately, I don't expect we will be able to fully support this in mag_distortion_correct in the short term.

David's suspicion is correct - we use Fourier cropping to resample data in all our programs.