| META TOPICPARENT | name="CemITApplications" |
Contents
Install
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
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
- 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
|