Function to convert EMAN2's coefficients into the coefficients of the IMOD format.

236 views
Skip to first unread message

digvij...@gmail.com

unread,
Aug 24, 2020, 4:12:48 PM8/24/20
to EMAN2
Hello everyone

I am trying to convert the transformation coefficients, obtained from the EMAN2's iterative alignment of tilt-series, into the coefficients of the IMOD format (available in .xf) . The goal is to do the weighted back-projected in IMOD using EMAN2's transformation coefficients. 

Can you please confirm if the transformation operations listed below for EMAN2 are correct? Even more useful if someone already has a function to convert EMAN2's coefficients into the coefficients of the IMOD format. 

Transformations in EMAN2 to align tilt-series:

(1)  Translation along X :
X' = X + DX

(2) Translation along Y:
Y' = Y + DX. Z'=Z.

(3) Rotation along Z by the angle a
[X'' Y'' Z''] = [X' Y' Z'] [cosa sina 0
                                -sina  cosa 0
                                 0       0.    1]

(4) Rotation along Y by the angle b
[X''' Y''' Z'''] = [X'' Y'' Z'']   [ cosb   0   -sinb
                                          0         1      0
                                          sinb    0      cosb]

(5) Rotation along X by the angle c
[X'''' Y'''' Z''''] = [X''' Y''' Z''']  [1   0      0
                                            0  cosc sinc
                                            0 -sinc cosc]


Transformations in IMOD to align tilt-series (taken from IMOD's website)

 Each linear transformation in a transform file is specified by a line with six numbers (A11 A12  A21 A22 DX DY) where the coordinate (X, Y) is transformed to (X', Y') by:
 X' = A11 * X + A12 * Y + DX
 Y' = A21 * X + A22 * Y + DY

Thanks

--

MuyuanChen

unread,
Aug 24, 2020, 4:44:52 PM8/24/20
to em...@googlegroups.com
I do not know how to convert to .xf file in IMOD but here are some hints...

The easiest way should be to take a look at the function “make_ali()” in e2tomogram.py. It essentially takes in the unaligned images and the tltparams matrix and generate an aligned tilt series similar to the IMOD fashion. It will also save the 3D transform in the image header. 

You should also be able to turn EMAN2 transform objects into all kinds of formats like this. 

Muyuan

--
--
----------------------------------------------------------------------------------------------
You received this message because you are subscribed to the Google
Groups "EMAN2" group.
To post to this group, send email to em...@googlegroups.com
To unsubscribe from this group, send email to eman2+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/eman2

---
You received this message because you are subscribed to the Google Groups "EMAN2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eman2+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eman2/13982d13-35b7-492e-8b91-e1bdc68f3e19n%40googlegroups.com.

digvij...@gmail.com

unread,
Sep 9, 2020, 1:25:21 PM9/9/20
to EMAN2
Thanks a lot, Muyuan. 

Cheers

Alister Burt

unread,
Jul 22, 2021, 6:20:32 AM7/22/21
to EMAN2
Hi all,
I had to do this conversion yesterday so wrote a little script which can be found at emanjson2imodxf, copying here in case it's useful for someone.

The script can be installed via pip, probably best to install into a virtual environment.
pip install emanjson2imodxf

and is used as follows
Usage: emanjson2imodxf [OPTIONS]

  Convert an EMAN2 json file into an IMOD xf file.

Options:
  -i, --input PATH   EMAN2 json file  [required]
  -o, --output PATH  IMOD xf file (output)  [required]
  --help             Show this message and exit.

Cheers,

Alister

MuyuanChen

unread,
Jul 22, 2021, 1:35:08 PM7/22/21
to em...@googlegroups.com
Thank you. I took a look at the script but it seems that it only reads the x/y translation and tilt axis rotation angle? It seems that this will make the alignment slightly off in most cases…
I do not have a good way to deal with the off axis tilt angles either and that is why there is never an official conversion script. From what I understand, IMOD handles that with sheering of 2D images, but we try to avoid an extra round of interpolation in general...
Muyuan

Alister Burt

unread,
Jul 26, 2021, 6:12:50 AM7/26/21
to em...@googlegroups.com
Hi Muyuan,

Thanks for picking up on that - I chose not to include x-axis tilt in the 2D transform because downstream processing tools don’t account for this distortion.

My goal was to produce initial alignments for Warp/M which will later be refined. In this context, I accept a slightly less accurate initial tomogram to avoid distorting the projection images in the tilt-series. Re: interpolation, I guess that’s an issue if you don’t compose the transforms prior to applying them? In any case, I prefer not to shear the projection images.

Thanks for all the great tools! 

Cheers,

Alister

Reza Khayat

unread,
Mar 21, 2022, 3:21:03 PM3/21/22
to EMAN2
Hi Alister,

Thanks for producing this tool. However, if I apply the produced IMOD transformation parameters to the stack, the images end up rotating and translating all over the place. Is this supposed to happen, or am I doing something wrong? Thanks.

Best wishes,
Reza

Alister Burt

unread,
Mar 21, 2022, 6:57:59 PM3/21/22
to em...@googlegroups.com
Hi Reza,

I never used this myself beyond some test data where it worked - there was a more recent patch suggested by Alex Noble which I accepted without really testing, maybe go back a version and see if that makes a difference?

If your EMAN alignments have quite a lot of x-tilt this tool will be unsuitable :)

Cheers,

Alister

On 21 Mar 2022, at 19:21, Reza Khayat <khaya...@gmail.com> wrote:

Hi Alister,
You received this message because you are subscribed to a topic in the Google Groups "EMAN2" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/eman2/bSp9ZvllIzk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to eman2+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eman2/5fed5145-55a6-4863-bc52-a715f35beb34n%40googlegroups.com.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages