Using Reconstructors from Python

Reconstructors are modular objects which take a set of images and assemble them in some way into a single higher dimensional image. Normally this means taking 2-D projections in known orientations and producing a single 3-D volumetric reconstruction, but the concept extends to taking 1-D projections and producing 2-D reconstructions, or even other algorithms which do not work with projections.

The primary projector you will find in use in EMAN2 is the 'fourier' reconstructor (the wiener_fourier reconstructor is also used a lot). You can get a list of all reconstructors from the command line with 'e2help.py reconstructors'. Adding '-v 2' will give more details. Programmatically from Python, the same information can be obtained using the dump_reconstructors() or dump_reconstructors_list() (for programmatic access) functions in python.

You can get detailed information on how reconstructors work from the autogenerated documentation, but here is an example showing typical usage. An additional good example is e2make3d.py:

   1 # p contains a list of projection objects with the "xform.projection" attribute
   2 recon=Reconstructors.get("fourier", {"sym":"c1","size":(pad,pad,pad),"mode":"gauss_2","verbose":True})
   3 
   4 # In typical usage this sequence would be repeated multiple times, with information about quality
   5 # and normalization improving on each cycle. 2-3 cycles is generally sufficient. This has 1 1/2 iterations
   6 # hardcoded. ie - insert slices once, check qualities, then reconstruct one more time.
   7 recon.setup()
   8 scores=[]
   9                 
  10 # First pass to assess qualities and normalizations
  11 for i,p in enumerate(stack):
  12   p2=p.get_clip(Region(-(pad-boxsize)/2,-(pad-boxsize)/2,pad,pad))
  13   p2=recon.preprocess_slice(p2,p["xform.projection"])
  14   recon.insert_slice(p2,p["xform.projection"],1.0)
  15 
  16 # after building the model once we can assess how well everything agrees
  17 for p in stack:
  18   p2=p.get_clip(Region(-(pad-boxsize)/2,-(pad-boxsize)/2,pad,pad))
  19   p2=recon.preprocess_slice(p2,p["xform.projection"])
  20   recon.determine_slice_agreement(p2,p["xform.projection"],1.0,True)
  21   scores.append((p2["reconstruct_absqual"],p2["reconstruct_norm"]))
  22 
  23 # setup for the second run
  24 recon.setup()
  25 
  26 thr=0.7*(scores[len(scores)/2][0]+scores[len(scores)/2-1][0]+scores[len(scores)/2+1][0])/3;             # this is rather arbitrary
  27 for i,p in enumerate(stack):
  28   if scores[i][0]<thr : continue
  29                         
  30   p2=p.get_clip(Region(-(pad-boxsize)/2,-(pad-boxsize)/2,pad,pad))
  31   p2=recon.preprocess_slice(p2,p["xform.projection"])
  32   p2.mult(scores[i][1])
  33   recon.insert_slice(p2,p["xform.projection"],1.0)
  34                 
  35 ret=recon.finish(True)
  36 ret=ret.get_clip(Region((pad-boxsize)/2,(pad-boxsize)/2,(pad-boxsize)/2,boxsize,boxsize,boxsize))

Eman2Reconstructors (last edited 2011-01-15 06:41:50 by SteveLudtke)