Wiki Page Content

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:

e2.py                       # this runs ipython (provided with EMAN2 binaries) and does '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                   # should update the image widget (if you left it open) immediately
>>> 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 when display() is no longer using it
>>> c.process_inplace("filter.lowpass.gauss",{"sigma":.125})  # equivalent to above
>>> display(c)              # Note that this is not the same 'c' as above. The original c still exists, but you've lost access to it
>>> print a.cmp("dot",c,{"negative":0,"normalize":1})         # e2help.py cmp -v 1 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

The session above is for interactive work. If you want to write your own program that uses EMAN2, the EMAN2/examples directory has a lot of good examples. Try 'average.py' to get started. e2fftsynth.py for a more complicated example with GUI elements.

Here are some good links into the documentation:

Eman2ProgQuickstart (last edited 2013-08-27 04:05:34 by SteveLudtke)