Stereo Figures

From PyMOLWiki
Redirect page
Jump to navigation Jump to search

Redirect to:

This page has been obsoleted by the stereo setting. The information here is still relevant, but the new option makes stereo viewing much, much easier.


ray angle=-3
png image1.png
ray angle=3
png image2.png

This is superior to using the Cmd turn command because it also rotates the light source. That way shadows will look right.

To make even more beautiful stereo images, use a program like Illustrator or Canvas to add the stereo/depth cued labels. This is a little tricky to describe, but I'll give it my best shot. Place the two images side by side with their centers separated by 6.0 - 6.5 cm, and aligned horizontally. Now add all your labels on the LEFT figure. select all of your labels and duplicate them. Move the duplicated labels to the RIGHT side. For clarity sake let's assume we have 3 labels on the LEFT side (a,b, and c -- we will call then aL and aR for the left and right labels, respectively). Place aL near a recognizable feature of the LEFT figure that you are trying to label. Now horizontilly align aR with aL. Now using only the L/R arrow keys move the aR label until the identical portion of the actual label (let's say the lower right hand tip of the 'a') is vertically aligned with the identical portion of your model (let's say where the C alpha-C beta bond leaves the ribbon backbone) on both the LEFT and RIGHT images. Repeat these steps for each pair of labels. This is a nice method for adding stereo labels because it does not require looking at your computer screen in wall-eyed stereo for 2 hours in order to get proper placement of labels.

By assuring that the labels are positioned in the LEFT and RIGHT images at positions that are identical with respect to the part of the model that is being labeled you automatically are also placing them so they are at the proper depth when the figure is finally viewed in stereo.

The following script will assist with creating stereo labels. It is a bit of a cludge but has been used successfully for publications

  #   Copyright 2004 Stephen Graham <s_graham_au AT hotmail DOT com>
  #   This program is free software; you can redistribute it and/or modify it
  #   under the terms of the GNU Lesser General Public License as published by
  #   the Free Software Foundation; either version 2.1 of the License, or (at your
  #   option) any later version.
  #   This program is distributed in the hope that it will be useful,
  #   but WITHOUT ANY WARRANTY; without even the implied warranty of
  #   GNU General Public License for more details.
  #   You should have received a copy of the GNU Lesser General Public License
  #   along with this program; if not, write to the Free Software
  #   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  from pymol import cmd
  import os
  def ray_stereo_labels( base_name, separation=3 ):
    print "Storing the state"
    cmd.scene( "_ray_stereo_labels", "store" )
    print "Ray tracing images" "ray angle=%d" % (separation) )
    cmd.png( base_name+"_ray_plus.png" ) "ray angle=%d" % (-1*separation) )
    cmd.png( base_name+"_ray_minus.png" )
    print "Setting orthoscopic view"
    cmd.set( "orthoscopic", 1 )
    print "Creating labels file"
    cmd.hide( "everything" ) "labels" )
    cmd.turn( "y", separation )
    cmd.png( base_name+"_label_plus.png" )
    cmd.turn( "y", -2*separation )
    cmd.png( base_name+"_label_minus.png" )
    print "Merging labels and ray-traced images"
    plus_string = '"composite -compose Multiply %s_ray_plus.png %s_label_plus.png %s_plus.png"' % (base_name, base_name, base_name )
    minus_string = '"composite -compose Multiply %s_ray_minus.png %s_label_minus.png %s_minus.png"' % (base_name, base_name, base_name )
    exec( "os.system("+plus_string+")" )
    exec( "os.system("+minus_string+")" )
    print "Restoring the state"
    cmd.scene( "_ray_stereo_labels", "recall" ) "labels" ) # For some reason recalling the scene does not
                         # get the labels back
    print "Done!"
  cmd.extend( "ray_stereo_labels", ray_stereo_labels )

To use the script, run the command 'run' and then run the command 'ray_stereo_labels <filename> <separation>' from a pymol window once you have annotated your scene. Note that this command MUST be run from an interactive window since it draws the OpenGL labels (and since OpenGL does not have an offscreen drawing context you need to window open). Additionally, the ImageMagick set of tools must be in your path (for the composite command to work).