Introduction
Filename extensions and starting SPIDER
WEB
Creating another test image in SPIDER
Filtering
Geometric and Algebraic operations
Correlation
Registers
Peak Search
Shift Alignment
Volumes
Document Files
Part II : SPIDER Batch files
Below is a brief introduction to SPIDER and WEB. The SPIDER Tutorial is a more detailed tour of many SPIDER operations. The SPIDER Manual of operations provides information on the specific options and choices of parameters for each SPIDER command. The User's guide covers issues relating to the syntax and conventions of SPIDER, including a section on writing and using procedures.
Filename extensions and starting SPIDER
SPIDER expects all files within a session to have the same filename extension.
For this lab, we will use the extension is "ext". In a Unix window, start SPIDER by typing at the Unix prompt:
spider extYou will see a start banner with the version number, followed by the prompt:
.OPERATION:SPIDER commands are entered at the .OPERATION: prompt. These in turn are followed by prompts asking for parameters specialized for that command, such as
.INPUT FILE:When in a SPIDER session, type all filenames without their extensions. In the exercises below, enter the provided text and numbers after each prompt. SPIDER prompts always start with a period (.) and end with a colon (:)
Create a simple image with the MO command:
.OPERATION: mo .OUTPUT FILE: circ001 .ENTER DIMENSIONS (NSAM,NROW): 75,75 .B/C/G/R/S/T/W: c .RADIUS (FLOATING POINT): 16 .OPERATION:You will see SPIDER echo the input, as well as print out additional information. Once the command has all the required arguments, it carries out the processing, and returns to the .OPERATION: prompt. View the image you have created in Web (below).
Web is often run simultaneously with a SPIDER session, allowing the user to view the output files. In another Unix window, type 'web' followed by the data extension, and an ampersand (&) to put it in the background:
web ext &Adjust the Web and SPIDER windows so that you can see both of them. When Web starts up, you will see a blank background screen, with menus at the top and a status window at the bottom.
Options listed under the main menu headings will be written as: Menu/Command
For example, when Web is first started, you may have to clear the screen with the option Commands/Clear
To view an image, use Commands/Image, and select the file to be viewed (circ001.ext). Web displays the image, and prints out some information (image size and range of the gray levels) in the status window at the bottom.
The size of the displayed image may be adjusted: select Options/Image, and enter -2 in the SIZE REDUCTION entry box. Positive numbers will decrease the size by the specified factor, while negative numbers will enlarge the displayed image. Use Commands/Image again to view circ001.ext. It should appear larger this time. All subsequently displayed images will also be enlarged, until SIZE REDUCTION is changed again. Remember, Web only displays a picture - it does not actually enlarge the original data file.
As you try out the SPIDER commands below, you will go back and forth between SPIDER and Web, performing image processing in SPIDER, and using Web to view the results.
Creating another test image in SPIDER
The PT command allows you to create geometric shapes. Here is another test image you can make using PT:
.OPERATION: pt .OUTPUT FILE: test001 .ENTER DIMENSIONS (NSAM,NROW): 75,75 .ENTER CODE (P,L,C,T,R,S): r .ENTER COORDINATES OF UPPER LEFT POINT: 18,12 .ENTER X & Y OFFSETS: 38,16 .CONTINUE? (Y/N): y .ENTER CODE (P,L,C,T,R,S): t .ENTER COORDINATES OF FIRST POINT: 18,33 .ENTER COORDINATES OF SECOND POINT: 56,36 .ENTER COORDINATES OF THIRD POINT: 32,66 .CONTINUE? (Y/N): NIn Web, view the resulting test file, test001.ext with Commands/Image. It doesn't show up in the Image file selection dialog? Every time you create a new image file, you need to press the 'Filter' button, so the program will reread the contents of the current directory.
SPIDER has a variety if filtering operations. The FQ NP command provides a set of filters to choose from. Filter your test image with FQ NP. NOTE: text after a semicolon (;) is a SPIDER comment. You DO NOT have to type the comment on the line prompting for FILTER TYPE!
.OPERATION: fq np .INPUT FILE: test001 .OUTPUT FILE: filt001 .FILTER TYPE (1-8): 3 ; selects Gaussian low-pass filter .FILTER RADIUS: 0.1View the result of the low-pass filter. Low-pass filters tend to blur the image, while high-pass filters emphasize the edges. You can experiment with a filter by adjusting the filter radius, or even try different filters.
Geometric and Algebraic operations
These include rotating (RT), shifting (SH), or resizing (IP) the image. Apply a shift operation to an image:
.OPERATION: sh .INPUT FILE: filt001 .OUTPUT FILE: shift001 .SHIFT COMPONENTS IN X-Y: 16.7, -7.2View the result, shift001.ext. For most operations, the origin of SPIDER coordinates is in the upper left corner, which is pixel 1,1 (not 0,0!). So a positive X shift moves the image to the right, a negative Y shift moves the image up. Note that the image may be shifted by non-integer values.
Images may be added (AD), subtracted (SU), or multipiled (MU) together. Subtract the image you just shifted from the original test image:
.OPERATION: su .INPUT FILE: test001 .SUBTRACTED FILE: shift001 .OUTPUT FILE: sub001 .SUBTRACTED FILE: *The SU operation allows you to subtract as many images as you want, so you must enter an asterisk (*) to terminate the command. View sub001.ext in Web. The two images were subtracted pixel-by-pixel. In the resulting 'difference image', positive areas (where test001 pixels > shift001 pixels) appear light, while negative areas are dark. Pixels where the two images were equal are zero, and appear as gray. Web always stretches the contrast so that the pixels with the smallest (or most negative) value are set to black, and the pixels with highest value are white. Note the range of this image is -1.0 ... 1.0. This means that for images with different ranges, their gray levels in Web are not comparable.
Cross correlation (CC) is a way to measure the similarity of 2 images. The 2 images are multiplied together, pixel by pixel, and the sum of these multiplications is stored at a location representing the position of image1 relative to image2. Then the images are shifted by one pixel, and multiplied again, with the resultant value stored at the next pixel. This is carried out by shifting image1 across all positions of image2 (the reference image). Pixels with high values ('peaks') in the cross correlation result show where the best matches were, while the amplitude of the peaks indicates the degree of similarity.
.OPERATION: cc .INPUT FILE: shift001 .REFERENCE FILE: filt001 .OUTPUT FILE: cc001View the cross correlation result in Web. There should be a bright spot indicating the location of the best match, or highest correlation. Select Options/Contrast. The sliders allow you to change the way the pixel intensities are displayed. Move the left slider rightward until the correlation result appears as nearly a single pixel. Next, set both sliders to the same intermediate value, e.g., 90. What happens to the images? They are binarized - all pixels above the threshold are white, pixels below the threshold are black. These contrast numbers refer the to actual pixels in the onscreen display, not to the floating point pixel intensities in the image files. When you are done, reset the contrast back to the original values (64,127).
SPIDER provides variables to hold temporary values. These variables are called 'registers' and are named X11, X12, ..., X99 (X01 through X10 are reserved). You can use registers anywhere you would normally enter a number in SPIDER. Registers can be used as a form of pocket calculator. At the prompt, type:
.OPERATION: x11 = 25 .OPERATION: x12 = x11 + 3.5Typing the register alone at the prompt returns its value:
.OPERATION: x11 25.000000 .OPERATION: x12 28.500000Peak search
A peak search is commonly applied after a correlation, to find the location of the best match - a 'peak' in the pixel intensities. The PK command prints its results to the screen, but it can also store these values in registers on the command line. In the following example, registers x11 and x12 are set to the X and Y coordinates of the highest peak found. Apply a peak search to the cross correlation result to find the coordinates of the bright spot:
.OPERATION: PK X11,X12 .INPUT FILE: cc001 .ENTER # OF PEAKS, CENTER ORIGIN OVERRIDE (0/1): 1,0Check the values of the registers:
.OPERATION: x11 17.000000 .OPERATION: x12 -7.0000000These numbers show the position of the highest peak (best match) relative to the image center. These are integers, but there is a way to get more accurate floating point values (see PK in the Operations Manual). To shift back to the center, we have to use the negative of these numbers. Put the negative values in other registers:
.OPERATION: x21 = -x11 .OPERATION: x22 = -x12Shift Alignment
Use the results from the peak search to align the shifted image to the original test image. For the X,Y shift components, use the negative of the numbers obtained from the peak search (i.e., -17 and 7). Since we have these numbers in registers, use registers x21 and x22 in place of the actual numbers.
.OPERATION: sh .INPUT FILE: shift001 .OUTPUT FILE: align001 .SHIFT COMPONENTS IN X-Y: x21, x22 ; instead of -17,7Compare the 'aligned' image with the original test image by subtracting them:
.OPERATION: su .INPUT FILE: test001 .SUBTRACTED FILE: align001 .OUTPUT FILE: sub002 .SUBTRACTED FILE: *How does the subtracted image sub002.ext appear? Compare to sub001.ext. The new difference image is zero (gray) everywhere, except around the edges of the shapes. This is because the edges were blurred in the filtered image, and therefore do not match the original sharp edges exactly.
Create a model volume with SPIDER's MO 3 command:
.OPERATION: MO 3
.OUTPUT FILE: sphere
.ENTER DIMENSIONS (NSAM,NROW): 75,75
.ENTER NUMBER OF SLICES (NSLICE): 75
.B/C/G/H/HA/NUM/R/S/SP/SPA/SPV/T/W: sp ;selects sphere from the menu
.GET COORDINATES FROM DOCUMENT FILE (Y/N): n
.ENTER MASS VALUE PER VOXEL (DEFAULT = 2.0): 2
.OUTER AND INNER RADII OF SPHERES: 19,14
.X,Y,Z: 38,38,38 ; the sphere's center
.X,Y,Z: 0,0,0 ; terminates the command
View the volume slice by slice in Web. Under Options/Image, set SIZE REDUCTION to 1. Under Commands/Image, select sphere.ext. If a volume is selected for display, Web pops up a dialog box that lets the user select which slices to display. Just click the 'Accept' button to view all slices. You should see a montage of all 75 slices from top to bottom of the sphere. You can see that it is hollow in the center, but some images contain circles as the volume is sliced.
If the ribosome volume 'ribosome.ext' is available, view it in Web:
Commands/Clear
Commands/Image
select ribosome.ext, click 'Accept'
You will see slices of the ribosome volume, with a dark intersubunit space in someof the central slices.
Now create a surface rendering of the volume.
Commands/Clear
Commands/Surface
select ribosome.ext
set Scale to 5.0, PHI to 50, THETA to 74, click 'Accept'
In this view, the small subunit is on the left, the large subunit on the right. The intersubunit space is visible as a cavity between the subunits. The stalk base is a protuberance in the center of this view.
Click the right mouse button to end the surface session.
Information obtained during a SPIDER session can be saved to document files (called doc files). Data is written to a doc file with the SD command, which writes one line at a time. The numbers to be stored are placed on the SD command line. The first number (here 1), is the key. This doc file can be read by other SPIDER commands; the key tells SPIDER which line to read.
.OPERATION: sd 1, x11, x12, x21, x22 .DOCUMENT FILE: doc001This writes the values of those four registers to the file doc001.ext. This file can be viewed in a text editor, or with the Unix 'cat' command (it may not be visible until the SPIDER session has ended).
The doc file has several entries:
;ext/ext 01-JUN-2002 AT 20:29:05 doc001.ext
1 4 17.000 -7.0000 -17.000 7.0000
The first line, starting with the semicolon, is a comment line with file creation information. The lines following the comment have the following format:
<key> <number of data items in this line> <data> <data> <data> <data>
End the SPIDER session:
.OPERATION: en d
Go on to Part II : SPIDER Batch files