Difference: CemSparxNotes (6 vs. 7)

Revision 717 Feb 2011 - Main.BillRice

 
META TOPICPARENT name="CemITApplications"
Contents

Install

  • download and install EMAN2 daily release
  • in EMAN2/eman2.cshrc, Pythonpath needs to be corrected from default:
       setenv PYTHONPATH ${EMAN2DIR}/python/Python-2.7.1-ucs4/lib/python2.7/:${EMAN2DIR}/lib:${EMAN2DIR}/bin:${PYTHONPATH}
    

Use

  • most instructions are on the sparx wiki

conversion of stacks

  • /cryoem/script/prep_sxali.xsh will convert a stack to hdf5 format and add all params:
    #!/bin/tcsh
    # little script to convert a stack to hdf format and get all params ready for sparx alignment
    
    e2proc2d.py $1 $1:r.hdf
    sxheader.py $1:r.hdf --params="active" --one
    sxheader.py $1:r.hdf --params="xform.align2d" --zero
    
    echo made new stack $1:r.hdf, all images active and 2d alignment params zeroed
    

command line

  • to run in interactive mode, run command "sparx"
    • this uses ipython, loads all eman2 and sparx libs, graphics are available

making scripts

  • for python scripts, need to run the python which came with eman2 and import the proper libs
  • put the following at start of scripts:
    #! ${EMAN2DIR}/python/Python-2.6.5-ucs4/bin/python
    
    from EMAN2 import *
    from sparx import *
    # add any other needed libs
    

some little tools when running interactively

  • load an image, view it , get some info, and write new image to file:
    data=EMData()  #create an object to hold the image
    data.read_image("recon_1-20.hdf",0)  #reads the first image from the stack recon_1-20.hdf
    display(data)  # view the image using e2display
    data.get_attr("minimum") # print min value of image
    data.get_attr("maximum") # max
    data.get_attr("mean")  #mean value of image
    data.get_attr("sigma")  # std dev
    data.get_attr("nx") # x-size of image -- use ny nz for other dims
    data2 = data * 5 #make new image with 5X intensities of original
    data2.write_image("out.hdf",0)  # write image data to file, hdf5 format
    

  • stack info
    nimages = EMUtil.get_image_count("recon_1-20.hdf")
    

  • make a mask
    mask = model_circle(r,nx,ny)  # makes a model image of size nx by ny with filled circle (density 1) of radius r
    

  • normalize an image: goal is to mask out particle, then get mean and std deviation of corners of box. Norm_image = (Image-BKG_mean)/(BKG_sd)
  • this way background has mean 0 and sd 1
data=EMData()  #create an object to hold the image
data.read_image("raw.hdf",0)  #reads the first image from the stack
nx = data.get_attr("nx")
ny=nx # image should be square of course
r=nx/2 # this will mask only the corners of the image
mask=model_circle(r,nx,ny)
square=model_blank(nx,ny,bckg=1)
inv_mask = square-mask  # can do math on images!
back_1d = Util.compress_image_mask(data,inv_mask)  # converts all image data under the mask to a 1D image -- for getting the stats of the corner data
mean = back_1d.get_attr("mean")
sd = back_1d.get_attr("sigma")
norm = (data - mean) / sd  # can also do scalar math on images!
norm.write_image("normalised.hdf",0)
 
  • a script to do this on an entire stack, rather than one file, is in /cryem/script/normalise_stack.py
Changed:
<
<
>
>
  • get all attribues from an image:
Added:
>
>
all_alltrib=data.get_attr_dict()
 
  • Set ALLOWTOPICVIEW =

-- BillRice - 17 Feb 2011

 
Copyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding this intranet, Send feedback