Thursday, December 6, 2012

Plotting strokelitude wing tracking data on fmf frames

I have been working on a Python script to save movies in which strokelitude wingstroke tracking data are plotted on original frames from an .fmf movie. My current version is below.

Load strokelitude data from .bag file into Python

Here is a script I've been using to load the strokelitude data contained in a .bag file. It should be easy to convert it to load data from other ros topics.

Tuesday, December 4, 2012

Using Github for Windows

I have started using the Github Windows GUI for using git on Windows, and so far I am very impressed. Github has made it very easy to download (clone) an entire directory tree of code files to a new computer, something I have to do more often that I would like. Git is an incredibly powerful tool for version control, and I really do not scratch the surface of its functionality. An important thing to remember for a novice user is that it is best to make sure you are working with the newest version of the repository before you start making edits on any given computer. Otherwise merging the edits from different computers (or users) can be hard. This can be accomplished by opening the github GUI before editing any files and clicking 'sync.'

Note: If, when setting up your repository, you accidentally included files that you did not want to have git follow, you can use this command:
git rm --cached <filename> 
by going to tools>open a shell here in the github GUI. You may also have to include a new line in your .gitignore file...

When you inevitably (in my experience) get an error message along the lines of "failed to sync this branch" with options to "open shell to debug" or "cancel," choose the former, and typing
git push
git pull 
depending on if you are trying to upload (push) or download (pull) changes from will sometimes work.

Sunday, November 18, 2012

How to convert a white mutant (white-eyed) Gal4 driver line into a white-plus (red-eyed) background

With Drosophila melanogaster becoming an increasingly popular model organism for neuroscience, many of us are finding it necessary to become more familiar with basic genetic techniques. The popular Gal4/UAS system is often used to express a particular useful gene (sometimes called an effector) in a specific set of cells (provided by a driver line). The problem is that sometimes the driver lines or effector lines have unwanted other mutant genes that were used in creating the line to begin with. For instance, I am currently doing experiments on a driver line (which expresses Gal4 in an interesting set of neurons) that has mutant eye color. That is, not only does it have a transgene (Gal4) inserted into the third chromosome, but it is missing the gene, white, which is ordinarily on the first chromosome. The problem is that white does not only encode eye color, but it is important for development of the eye in general and has other functions in the nervous system. Anne Sustar explains: "The white mutant is a problem for behavioral assays because in addition to being important for production of pigment in the eye, it is an amine transporter that is also likely important for the production of neuromodulators in the brain. The mini-white that's on all transgenes uses an eye-specific promoter.  Thus it rescues eye color, but does not rescue the potential neural and behavioral defects.  More on this story here:" Kain and colleagues recently published a paper that confirms that white-eyed flies can phototax, but have other behavioral abnormalities: Phototactic personality in fruit flies and its suppression by serotonin and white. Kain JS, Stokes C, de Bivort BL. Proc Natl Acad Sci U S A. 2012 Nov 27;109(48):19834-9. doi: 10.1073/pnas.1211988109. Epub 2012 Nov 13.

Now this isn't necessarily a problem if the effector line I cross these flies to has a functional version of the white gene. But if the effector line is also mutant for white, my eyes will have abnormal vision, totally independent of any effects of the effector gene in my neurons of interest. In order to do experiments that involve vision (which is important for a large proportion of behaviors) I need to get my driver line to have a normal version of the white gene.

So, we have a Gal4 driver line with Gal4 on the third chromosome and white eyes. The males have a genotype something like this:

1. w-/Y;+/+;G/G

Where G is the Gal4 gene and promoter.

We want to cross this to a virgin female with wild-type, (i.e. white-plus, or red-colored) eyes (that is, a line with the wild-type allele for the gene white on the first chromosome. On the third chromosome we will need balancer chromosomes. This could be something like this:

2. w+/w+;+/+;Sb/Tb

Here Sb stands for stubble, a gene with a dominant phenotype of short bristles. Tb stands for tubby, a dominant phenotype for a short "tubby" pupal case and larval body shape. This line is stable because each of these genes are homozygous lethal: a fly homozygous for either one does not grow to adulthood. Hence, all the flies in this bottle have the above genotype.

When we cross these two flies, we can get two possible male genotypes in the offspring:

3. w+/Y;+/+;Sb/G
4. w+/Y;+/+;Tb/G

Both have red eyes. 3 are stubble (have stubble? are stubbly?). 4 are tubby. For our purpose we could use either 3 or 4. Let's say we pick 3--we select males that have stubble. We now cross these with a virgin female of genotype 2 (above).

The female offspring could be any of four possible genotypes:

5. w+/w+;+/+;Sb/Sb
6. w+/w+;+/+;Sb/G
7. w+/w+;+/+;Tb/G
8. w+/w+;+/+;Sb/Tb

Now, remember stubble is homozygous lethal, so there will actually be zero offspring with genotype 5. For our purposes, either 6 or 7 would do. Let's say we pick 6. We have to select flies with stubble but that are not tubby. Now we can either just leave those in a bottle together, and when we choose experimental flies down the line make sure to pick flies that do not have stubble. It is also possible that stubble will be eliminated on its own, through a slight fitness cost. In order to make a true homozygous stock, however, it would probably be best to cross some of genotype 6 together, then select flies that do not have stubble. These we can be sure have the genotype

9. w+/w+;+/+;G/G

which is homozygous for both white and our Gal4 gene and promoter.

Tuesday, November 13, 2012

Error first time starting WinEDR in Windows 7

I just installed WinEDR in a new installation of Windows 7 and I got the following error:

Application Error. Exception EOIeSysError in module WinEDR.exe at 0007C319. Error accessing the OLE registry.

By going to Computer\C:\WinEDR and right-clicking on WinEDR and then "Run as administrator" the problem seems to be solved. I don't know if this would also be required for WinWCP:

I think this may be a general fix for this type of exception based on a cursory Google search.

Monday, November 5, 2012

Setting up new printer in Ubuntu 10.04

Our lab just got a new printer, an HP LaserJet 500 color M551. It seems to work well once I downloaded the driver and followed the instructions here:

I think the version of hp-setup that was already installed in my system was old.

Tuesday, October 30, 2012

Script for importing data file from WinEDR to MATLAB

I put this script together a few years ago for importing data from WinEDR into MATLAB:

Ubuntu 12.04 boot times on solid state vs. regular hard drive

Comparing (almost) completely clean new installations of Ubuntu 12.04 on my home (an old hp Pentium 4) on

1) 1.0 TB Western Digital SATA 64MB Cache 3Gbps?
I got to the login screen about 37.5 seconds after pressing the power button, and to the desktop about 10.3 seconds later.

and 2) 80 Gb Intel SSD? (I already screwed it to the inside of the box...)
I got to the login screen about 30.5 seconds after pressing the power button, and to the desktop about 7 seconds later.

So, the SSD saves about 10 seconds per startup.

Saturday, October 20, 2012

Installing php and apache

In the spirit of logging changes I make to my new laptop: I'm setting up php and apache to test some little php scripts:

sudo apt-get install apache2
sudo apt-get install php5
sudo /etc/init.d/apache2 restart

And it seems to have worked.

Thursday, October 18, 2012

Plot binned mean and mean plus/minus std using python

python scripts to plot mean and mean plus/minus std for data in time bin:

Thursday, October 4, 2012

Mounting an external hard drive in Ubuntu

Lately Ubuntu hasn't been recognizing my external hard drives when I plug them into the USB ports. Here is a manual way to mount one named "weir17":

sudo mkdir /media/weir17
sudo mount /dev/disk/by-label/weir17 /media/weir17  

I'm not sure why this is not happening automatically, maybe something to do with them being formatted in NTFS?

Wednesday, September 5, 2012

Importing .wcp files (from WinWCP) into Python

Today I'm going to try to use neo to import .wcp files (the output of WinWCP) into a python analysis script. First, installation:

sudo apt-get install python-pip
sudo pip install quantities
sudo apt-get install cython
sudo pip install neo

(I'm following the instructions here, but skipping some things I already have installed.)

from neo import io

It looks like it worked!

Thursday, August 23, 2012

Cool tool for converting rst to html

This website will convert restructured text to html. I used it to convert a document I had written in rst to html for the last post on this blog.

Installing fview and Strokelitude from Scratch

Install Ubuntu

This step is not stictly necessary, but everything works in Lucid, so it may save time.

  • Download and install Ubuntu 10.04 (Lucid) from
  • Often the display will be improved by looking under System>Administration>Hardware Drivers for video card drivers.
  • Run the Update Manager (under System>Administration).

Install fview

Andrew Straw wrote fview, a general purpose video acquistion application. Strokelitude (also by Dr. Straw) is a plugin for fview.

  • Add the repositories, following the instructions at

    sudo add-apt-repository ppa:astraw/ppa
    sudo wget --output-document=/etc/apt/sources.list.d/astraw.list$(lsb_release -cs).list
    sudo apt-get update && sudo apt-get install astraw-keyring && sudo apt-get update
  • From synaptic (System>Administration>Synaptic Package Manager) install the following packages with all their dependencies:

    • camiface
    • python-motmot-fview
    • libhdf5-serial-1.8.4
    • hdf5-tools
    • python-tables
    • python-enthought-traits
    • python-enthought-traits-ui
    • python-chaco
    • python-pylibusb
    • pyro
    • python-motmot-fastimage
    • python-motmot-realtimeimageanalysis
    • python-motmot-fviewexttrig
    • git-core
  • Test fview by typing fview at a terminal (Applications>Accessories>Terminal) or going to Applications>Sound & Video>fview don't worry about error message:

    While attempting to open the plugin "fview_ext_trig",
    FView encountered an error. The error is:
    Cannot find device.
    (Perhaps run with environment
    variable REQUIRE_TRIGGER=0.)

    Initialize the camera by going to Camera>initialize camera...

  • Note: If you are using a firewire (1394) camera and you cannot initialize it, try running sudo fview instead. Also, run the following command in a terminal:

    sudo adduser $USER video
    sudo chown .video /dev/raw1394

    then log out and log back in.

Install strokelitude

Now we are ready to install the plugin, "strokelitude," that actually tracks the wing positions.

  • In a terminal, type:

    mkdir src
    cd src
    git clone git://
    cd remote_traits/
    sudo python install
    cd ..
    git clone git://
    cd strokelitude/
    sudo python install
  • Start fview, you should now see strokelitude as an option under Windows.

Install ROS (Electric)

The easiest way to save strokelitude data is to install ROS (Robot Operating System) and save the "topics" that strokelitude "publishes" in a .bag file. In order to do this, we install ROS, then start roscor before opening fview. We record using the rosbag record command.

  • Follow the instructions at . Briefly, you need to do the following. In a terminal, type:

    sudo sh -c 'echo "deb lucid main" > /etc/apt/sources.list.d/ros-latest.list'
    wget -O - | sudo apt-key add -
    sudo apt-get update
    sudo apt-get install ros-electric-desktop-full
    echo "source /opt/ros/electric/setup.bash" >> ~/.bashrc
    . ~/.bashrc

    The fourth line will take some time -- you are installing all of ROS.

  • Now we'll need to create a directory in which we can place ROS scripts (see ). In a terminal, type

    cd ~/src
    mkdir ros_workspace
    cd ros_workspace
  • We want to tell ROS that this directory will contain ROS scripts. Create a file named

    source /opt/ros/electric/setup.bash
    export ROS_ROOT=/opt/ros/electric/ros
    export PATH=$ROS_ROOT/bin:$PATH
    export PYTHONPATH=$ROS_ROOT/core/roslib/src:$PYTHONPATH
    export ROS_PACKAGE_PATH=~/src/ros_workspace:/opt/ros/electric/stacks:$ROS_PACKAGE_PATH

    then run the file using the command .

    To make this change permanent, assuming the file is in your home directory, add to the bottom of your .bashrc file:

    source  ~/src/ros_workspace/
  • Now we are ready to install the package that defines the message type strokelitude will publish in ROS. In a terminal type:

    git clone git://
    rospack profile
    rosmake strokelitude_ros
    rosdep install rxtools
    rosmake roscpp_tutorials rospy_tutorials rxtools

    then open fview by typing fview in a new terminal. Open the strokelitude window and click box next to 'Processing enabled'

  • In a new terminal type rxplot /strokelitude/left_wing_angle_radians /strokelitude/right_wing_angle_radians in order to view a realtime plot of the fview data

  • In new terminal, navigate to the directory where you want to record data, then type rosbag record -O data /strokelitude (this will save data in data.bag file)

  • To import your data into Python, do something like the following in a python script:

    import roslib
    roslib.load_manifest('rosbag') import rosbag
    bag = rosbag.Bag('data.bag')
    for topic, msg, t in bag.read_messages():

Install strokelitude-jfi-emulator

If you want to do closed-loop experiments using the Reiser panels, probably the simplest way is to use the mcc analog output board to output an analog voltage proportional to each wingstroke. In order to install this, follow these steps:

  • Using synaptic package manager, install libmcclibhid

  • Plug in the usb1208FS (this used to be called pmd1208FS and those work also) and test it by running the command sudo testusb1208FS in a terminal. Type 'b' to blink the LED.

  • Using synaptic, install python-wjul. This allows Python access to the usb1208FS.

  • install strokelitude-jfi-emulater by typing the following into a terminal:

    cd src
    git clone git://
    cd strokelitude-jfi-emulator
    sudo python install

Good high power IR LED

This is a good high power infrared LED:

SFH 4230 Golden Dragon Package, half angle ±60°, 850nm, typ. 440 mW at 1A dc. 



Arduino control of LED

Here is code to control the intensity of an LED using Arduino.

Arduino control of polarization switcher

Here is the code that I used in the Arduino box to control the polarization rotator (switcher). (I think...)

Setting up Simple Step

These are my notes on setting up Simple Step, a program by Will Dickson for controlling stepper motors.

Using synaptic, install gcc-avr, avr-libc, and dfu-programmer.

cd src
mkdir MyUSB
cd MyUSB

Download MyUSB v 1.4.1 from and extract it to MyUSB

make all

cd ~/src
hg clone
cd simple_step/firmware
gedit Makefile

Change line 24 to MYUSB_SRC_DIR = /home/<username>/src/MyUSB/MyUSB
Exit gedit

cd src
gedit Makefile

Change line 53 to MYUSB_SRC_DIR = /home/<username>/src/MyUSB/MyUSB

cd ..
cd ~/src/simple_step/firmware

Press the 'RST' and 'HWB' buttons on the atmel simultaneously, then release the 'RST' button, then the 'HWB' button.

sudo make program

cd ~/src/simple_step/firmware
sudo cp udev_rules/99-simple_step.rules /etc/udev/rules.d
sudo addgroup simple-step
sudo usermod -a -G simple-step <username>

Install pylibusb

cd simple_step/api/python
sudo python install

Setting up Python PControl

These are my notes on setting up Python PControl:

Install mercurial via synaptic

cd src
hg clone
cd panel_comm
sudo python install

Setting up Arduino in Ubuntu

These are my notes from setting up Arduino in Ubuntu Lucid 10.04:

sudo apt-get install gcc-avr avr-libc
Download newest release from and extract it to a convenient location.
Double clicking on the arduino file should start the program.

sudo usermod -aG dialout <myuser>

BEWARE: Serial.println in a loop can cause entire Java Arduino program to lock up because it locks up the serial ports, which are scanned every time you click the tools menu (upload a different sketch using windows or mac to fix the problem)

Tuesday, August 21, 2012

test strokelitude and ROS

This is useful: rxplot /strokelitude/left_wing_angle_radians

Thursday, July 26, 2012

Superscript, subscript, and padding (margins) for text boxes in Illustrator CS5

To change the empty space above, below, and to the sides of text, go to Type>Area Type Options...

and change the Inset Spacing (in the Offset box):

To make text superscript or subscript, go to character menu (on right toolbar), open menu in top-right:

Monday, July 23, 2012

Inserting a comma after first of two authors with apalike citation in Lyx

Using apalike style, when there are only two authors Lyx does not put a comma after the first author's initials (before the "and"), to fix this, I had to edit the .bst file:
cd /usr/share/texmf-texlive/bibtex/bst/apalike
sudo gedit apalike.bst

save as apalike2.bst
change lines 214-222
 { namesleft #1 >
     { ", " * t * }
     { numnames #2 >
  { "," * }
       t "others" =
  { " et~al." * }
  { " and " * t * }
 { namesleft #1 >
     { ", " * t * }
     { t "others" =
  { " et~al." * }
  { ", and " * t * }
After this we might need to run the command
 sudo texhash
In Lyx, click on bibliography, browse to new (apalike2.bst) style file.

Changing Submitted to Defended date in CIT thesis title page

To change the line on the cover page from, say, "(Submitted June 26, 2012)" to "(Defended June 1, 2012)" one needs to follow these steps:
Go to Document>Settings...
Under Document Class section, add the word "defended" to the line for Custom Class options.
At the beginning of the document (I put it right between Copy Year and TechReport #) insert a Date section (using dropdown menu in top left of toolbar) that contains the string you want to appear after "Defended" on the title page.

Sunday, July 1, 2012

gain and offset values in Panel_com

Using the default function value, the actual number of frames per second when using the command line interface (not the GUI) in open loop is given by: actual_speed = gain + 2.5*offset;

Wednesday, June 27, 2012

Pybtex - useful tool for dealing with bibliographies in Python

sudo apt-get install python-setuptools
sudo apt-get install bzr

(bazaar is a version control system like svn. Apparently the bzr branch in the most up-to-date and stable version of pybtex.)
cd Downloads/
bzr branch lp:pybtex cd pybtex sudo python develop

When formatting a new drive use NTFS

This format allows files over 4Gb, and allows for HDs over 137Gb.

Using master Boot Record (under ubuntu disk utility) seems to work well.

Tuesday, June 26, 2012

Setting up scientific computing using Python on Ubuntu 12.04

First day starting installation on my new Toshiba Z835 ultrabook! I already installed Ubuntu 12.04 on a partition using the windows installer (after creating a startup disk on a 16 Gb usb drive, 8 Gb is not enough.)

Setting up numpy, matplotlib, wxPython, ipython, etc.

I found dealing with virtual environments just too annoying (see below). I opted to reinstall ubuntu 12.04 fresh, and start the process over with no virtual environments. First thing, I ran update manager (click the icon at the top of the dock and type 'update manager.' To add the terminal to the dock, type 'terminal' and drag the icon to the dock, this is where we will type the following commands.) After all the updates, I restarted.
In a terminal, I typed:
sudo apt-get update
sudo apt-get install python-numpy

(This resulted in installing 1.6.1, which I am not thrilled about, since 1.6.2 is already out.)
sudo apt-get install python-scipy
sudo apt-get install python-matplotlib
sudo apt-get install python-wxtools
sudo apt-get install ipython

testing ipython, numpy, and pylab (matplotlib):
import pylab
import numpy as np

Looks good!
Wow, that was a lot easier than virtualenv.

Handy note:
use apt-cache show ipython to show package information about ipython (or any other package)
apt-cache depends ipython to show what packages ipython depends on.
apt-cache search ipython to search available packages for 'ipython'

Since I'm on a roll, I decided to install two new fancy tools that look cool:
sudo apt-get install ipython-qtconsole
sudo apt-get install ipython-notebook

Both of them work, and ipython notebook looks dope!

OLD: My first attempt, using virtualenv

I've decided to keep python packages compartmentalized from the system installation by using virtualenv, so my first step will be to install it (instructions at I'm going to use pip to download and install python packages inside the virtual environment, so I'll use easy_install to set up my virtualenv. This way, any pip installation I have should only reside inside a particular virtualenv (not sure this is true, but worth a try...)


Setting up a virtual environment

sudo apt-get install python-setuptools
Now I'll install virtualenv:
sudo easy_install virtualenv
OK, that appears to have worked.

mkdir ~/src/virtualEnvironments
cd ~/src/virtualEnvironments
virtualenv --no-site-packages firstEnv

It turns out that the --no-site-packages is deprecated, since this is now the default behavior, but it doesn't seem to have done any harm.
Now, to activate the virtualEnv, type source firstEnv/bin/activate. Typing pip now shows that it is installed. If I type deactivate, then type pip, we see that pip is only installed in the virtual environment, sweet!


Installing numpy in the virtual environment

Let's get down to the business of installing some packages in our virtual environment:
pip install numpy
Error! Looks like I first have to install python-dev:
sudo apt-get install python-dev trying to install numpy again: pip install numpy works!


Installing matplotlib in the virtual environment

Next let's install matplotlib. It has some non-python dependencies, so we'll install these with apt-get: sudo apt-get update
sudo apt-get install libpng-dev
sudo apt-get install libfreetype6-dev
sudo apt-get install libjpeg8-dev
sudo apt-get install g++

To be honest, I'm not sure if all of these are necessary, but the last one (g++) definitely is. Supposedly there can be problems if gcc and g++ are not the same version, which you can check by typing gcc --version and g++ --version.
Finally, we are ready to get matplotlib:
pip install matplotlib
So that is ready to go.


Installing ipython in the virtual environment

Final step, let's get ipython working.
sudo apt-get install libzmq-dev
pip install pyzmq
pip install ipython[zmq,qtconsole,notebook,test]
sudo apt-get install libqt4-*
(this probably installs more than we need, installation took a LONG time.)
Download SIP and PyQt from and
cd ~/Downloads/sip-4.13.3/
sudo make install
cd ../PyQt-x11-gpl-4.9.3/
sudo make install
at this point ipython, ipython qtconsole, and ipython notebook all seem to be working, but no windows show up for pylab plotting.
Trying this:

sudo apt-get install python-wxgtk2.8 python-wxtools wx2.8-i18n
But now wx is installed outside of virtual environment... Instead I will try to build it from source:
download the development (2.9) version wxPython-src from
Following these instructions ( I did this:
cd ~/Downloads/wxPython-src-
sudo apt-get install gtk+3
sudo apt-get install gstreamer0.10
This takes a LONG time
python --install --build_dir=~/src/wx --installdir=~/src/wx --wxpy_installdir=~/src/wx THIS DID NOT WORK.
This link contains some info to get it working:
might try it later...
Or possibly something like this:

Monday, June 25, 2012

Using Elyxer to convert from Lyx to html

To create a html version of my thesis, I found Elyxer to be extremely convenient. I believe the only steps were as follows:
  1. Download Elyxer from here. (The current version when I downloaded it was 1.2.3)
  2. In a terminal, run
    cd elyxer-1.2.3/
    sudo ./
  3. If you used \emph{<species name>} in your .bib file, see NOTE below.
  4. Go to the directory containing your lyx document (here I use "document.lyx") and create a subdirectory for elyxer to save output images (I used htmlImages).
  5. In a terminal, run --destdirectory "htmlImages" --title "<title of html page>" document.lyx <name of the output>.html
  6. Move the html file to the destination directory.
  7. Double click the html file to view a nicely formatted and linked version of your lyx file!
NOTE: Elyxer cannot handle \emph{...} in the bibtex bibliography files. It was a bit of a pain to fix this, as the output html file eliminates the second }, making searching and replacing with <i> and </i> tags impossible. To overcome this, I followed these steps:
  1. Download the plugin for regular expression search and replace using gedit from here:
    1. Download and extract the files (found here).
    2. Move those files to ~/.gnome2/gedit/plugins/ :
      cd .gnome2/gedit/
      mkdir plugins
      cd plugins/
      mv /home/peter/Downloads/regex_replace ./
      mv /home/peter/Downloads/regex_replace.gedit-plugin ./
    3. Close gedit
    4. Open gedit, choose Preferences from the Edit menu. On the plugins tab, you should see Regular Expression Replace in the list. Check to enable. Now, you should have a "Regular Expression" item in the Search menu.
  2. open your bibtex file(s), and save a new copy (this will mess up the pdf output of your lyx document).
  3. In the regular expression search box, search for \\emph\{([a-zA-Z_1-9 ]*)(\}) and replace with <i>\1</i>
  4. This will probably miss some cases of \emph{...}, so do a final search for \emph using gedit's search feature and fix them by hand. (The [a-zA-Z_1-9 ] term only finds those characters, so expressions with linebreaks or other odd characters get skipped. This could be fixed if it is too big of a problem.)
  5. Open your lyx document, save as a new copy (again, we don't want to screw up the working pdf output) and change the bibtex files to our new versions. (Click on BibTeX Generated Bibliography, delete the existing bibtex files, then add the new ones.)

Setting up a Lyx template to write a Caltech thesis

I wrote my thesis using Lyx, a wonderful Latex-based document processor that made organization and citations easy. I used Ling Li's Caltech thesis template. Here are the notes to myself I made while installing it:

Getting Lyx to work with Caltech thesis

  1. install Lyx using Synaptic
  2. From download
    1. cit_thesis.cls
    2. cit_logo.eps*
    3. cit_logo.pdf*
    4. cit_ntheorem.std
  3. Run
    sudo mkdir -p /usr/local/share/texmf/tex/latex
    sudo cp Downloads/cit_thesis.cls /usr/local/share/texmf/tex/latex/
    sudo cp Downloads/cit_logo.eps /usr/local/share/texmf/tex/latex/
    sudo cp Downloads/cit_logo.pdf /usr/local/share/texmf/tex/latex/
    sudo cp Downloads/cit_ntheorem.std /usr/local/share/texmf/tex/latex/
    sudo texhash
  4. open Lyx
  5. run Tools>Reconfigure
  6. close Lyx
  7. reopen Lyx
  8. run File>New from Template
  9. choose cit_thesis.lyx
*Later I actually removed these files and replaced them with the current preferred Caltech logo from Then I copied this into the latex directory:
sudo cp cit_logo.png /usr/local/share/texmf/tex/latex/
sudo texhash

I can't remember if I needed to change format to .png or not.

Sunday, June 24, 2012

Code snippets in blogger

I have been experimenting with ways to post code snippets to this blog. Here are two strategies that seem to work:

Strategy 1.

Paste snippets to, then embed them using the embed feature. You can log on to smipple using your google account.

Strategy 2.

Following the advice found here, I experimented with I just embedded the following code after the meta tag of the html of this blog's template

<link href='' rel='stylesheet' type='text/css'/>
<script src='' type='text/javascript'/>
and this in the script tag


I've been testing this as I go, and I see that those snippets are overflowing the intended area. After looking in the code from the example, I see that I need to also add this to the css part of the blog's template (I stuck it right after the closing bracket for the .post-body entry:

pre.prettyprint {
overflow: auto;

Now, to embed code I can just type something like this:

<pre class="prettyprint lang-py">var i = 2 + 4;

Using this system, our example snippet looks like this:

import numpy as np

def circmean(alpha,axis=None):
    mean_angle = np.arctan2(np.mean(np.sin(alpha),axis),np.mean(np.cos(alpha),axis))
    return mean_angle
def circvar(alpha,axis=None):
    if and alpha.mask.shape!=():
        N = np.sum(~alpha.mask,axis)
        if axis is None:
            N = alpha.size
            N = alpha.shape[axis]
    R = np.sqrt(np.sum(np.sin(alpha),axis)**2 + np.sum(np.cos(alpha),axis)**2)/N
    V = 1-R
    return V

Neither works perfectly. You must re-insert the code into the html template each time you change the blog's layout. Constantly switching between blogger and smipple doesn't seem great, either...

Strategy 3.

Andrew gave me the idea of using github gists. Here is a test: