Differences between revisions 3 and 4
Revision 3 as of 2007-03-13 15:24:35
Size: 2392
Editor: SteveLudtke
Comment:
Revision 4 as of 2008-11-26 04:42:28
Size: 2400
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 26: Line 26:
If you want to do interactive GUI programming, such as writing a program like 'e2boxer.py --gui' for example, you need to use a PyQT4 event loop. The EMAN2 interactive GUI programming environment is based on [http://ipython.scipy.org/moin/ ipython]. You must have ipython 0.7.3 or above to use it: If you want to do interactive GUI programming, such as writing a program like 'e2boxer.py --gui' for example, you need to use a PyQT4 event loop. The EMAN2 interactive GUI programming environment is based on [[http://ipython.scipy.org/moin/|ipython]]. You must have ipython 0.7.3 or above to use it:
Line 38: Line 38:
 * [http://blake.bcm.edu/eman2/doxygen_html/classEMAN_1_1EMData.html EMData methods]
 * [http://blake.bcm.edu/eman2/doxygen_html/classEMAN_1_1Transform3D.html Transform3D class for Euler angle conversions, etc.]
 * [http://blake.bcm.edu/eman2/doxygen_html/ The main autogenerated documentation] (specifically, the pages for processors, comparitors, etc.)
 * [[http://blake.bcm.edu/eman2/doxygen_html/classEMAN_1_1EMData.html|EMData methods]]
 * [[http://blake.bcm.edu/eman2/doxygen_html/classEMAN_1_1Transform3D.html|Transform3D class for Euler angle conversions, etc.]]
 * [[http://blake.bcm.edu/eman2/doxygen_html/|The main autogenerated documentation]] (specifically, the pages for processors, comparitors, etc.)

EMAN2 Programming Quickstart

This page contains some example sessions to get you started using EMAN2 from Python. This is not aimed at mainstream users, but is for those wanting to move into programming in EMAN2.

Here is a sample EMAN2 session:

python
>>> from EMAN2 import *
>>> a=test_image()
>>> display(a)              # Use the middle mouse on the image for controls, right mouse to pan
>>> b=[test_image(),test_image(1),test_image(2)]
>>> display(b)              # Again, middle and right mouse
>>> a*=-1
>>> display(a)
>>> c=a.process("filter.lowpass.gauss",{"sigma":.125})        # use 'e2help.py processor [-v]' or from python 'dump_processors()'
>>> display(c)
>>> c=a.copy()              # Note, memory management is automatic, this will delete the old c
>>> c.process_inplace("filter.lowpass.gauss",{"sigma":.125})  # equivalent to above
>>> display(c)              # Note that this blocks !  See below for nonblocking example
>>> print a.cmp("dot",c,{"negative":0,"normalize":1})         # e2help.py cmp [-v] or dump_cmps()
>>> d=c.do_fft()
>>> e=d.calc_radial_dist(64,0.0,1.0,1)                        # radial power spectrum
>>> print e
>>> plot(e)                 # Note that this is a static image, not an interactive plot

If you want to do interactive GUI programming, such as writing a program like 'e2boxer.py --gui' for example, you need to use a PyQT4 event loop. The EMAN2 interactive GUI programming environment is based on ipython. You must have ipython 0.7.3 or above to use it:

e2.py
>>> a=[test_image(i) for i in range(3)]
>>> display(a)
>>> a[1]*=-1

Now, how does this second example differ from the first. The difference is that it's running within a GUI event loop. So, when you issue the 'b=EMImage(a)' command, an image display window opens, but you immediately get another python prompt. When you then do a[1]*=-1, the change is immediately displayed.

Here are some good links into the documentation:

Eman2ProgQuickstart (last edited 2022-02-18 00:36:44 by TunayDurmaz)