A digital lab notebook. Topics range from scientific computing using Python to neurobiology of Drosophila.
Thursday, December 6, 2012
Plotting strokelitude wing tracking data on fmf frames
Load strokelitude data from .bag file into Python
Tuesday, December 4, 2012
Using Github for Windows
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
or
git pull
depending on if you are trying to upload (push) or download (pull) changes from github.com 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
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
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
http://hplipopensource.com/hplip-web/install/install/index.html
I think the version of hp-setup that was already installed in my system was old.
Tuesday, October 30, 2012
Ubuntu 12.04 boot times on solid state vs. regular hard drive
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
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
Wednesday, October 17, 2012
Thursday, October 4, 2012
Mounting an external hard drive in Ubuntu
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
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.)
ipython
from neo import io
It looks like it worked!
Thursday, August 23, 2012
Cool tool for converting rst to html
http://www.tele3.cz/jbar/rest/rest.html
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 http://www.ubuntu.com/download/ubuntu/download
- 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 http://code.astraw.com/projects/motmot/download.html
sudo add-apt-repository ppa:astraw/ppa sudo wget --output-document=/etc/apt/sources.list.d/astraw.list http://debs.astraw.com/sources.list.d/astraw-$(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://github.com/astraw/remote_traits.git cd remote_traits/ sudo python setup.py install cd .. git clone git://github.com/motmot/strokelitude.git cd strokelitude/ sudo python setup.py 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 http://www.ros.org/wiki/electric/Installation/Ubuntu . Briefly, you need to do the following. In a terminal, type:
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu lucid main" > /etc/apt/sources.list.d/ros-latest.list' wget http://packages.ros.org/ros.key -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 http://www.ros.org/wiki/ROS/Tutorials/InstallingandConfiguringROSEnvironment ). 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 setup.sh:
#!/bin/sh 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 . setup.sh
To make this change permanent, assuming the setup.sh file is in your home directory, add to the bottom of your .bashrc file:
source ~/src/ros_workspace/setup.sh
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://github.com/motmot/strokelitude_ros.git rospack profile rosmake strokelitude_ros rosdep install rxtools rosmake roscpp_tutorials rospy_tutorials rxtools roscore
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') leftWingRad=list() rightWingRad=list() for topic, msg, t in bag.read_messages(): leftWingRad.append(msg.left_wing_angle_radians) rightWingRad.append(msg.right_wing_angle_radians)
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://github.com/motmot/strokelitude-jfi-emulator.git cd strokelitude-jfi-emulator sudo python setup.py install
Good high power IR LED
SFH 4230 Golden Dragon Package, half angle ±60°, 850nm, typ. 440 mW at 1A dc.
http://catalog.osram-os.com/catalogue/catalogue.do?favOid=00000000000207c000ed0023&act=showBookmark
Arduino control of polarization switcher
Setting up Simple Step
Using synaptic, install gcc-avr, avr-libc, and dfu-programmer.
cd src
mkdir MyUSB
cd MyUSB
Download MyUSB v 1.4.1 from http://www.fourwalledcubicle.com/LUFA.php and extract it to MyUSB
make all
cd ~/src
hg clone https://bitbucket.org/willdickson/simple_step
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 ..
make
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>
Reboot
Install pylibusb
cd simple_step/api/python
sudo python setup.py install
Setting up Python PControl
Install mercurial via synaptic
cd src
hg clone https://bitbucket.org/willdickson/panel_comm
cd panel_comm
sudo python setup.py install
Setting up Arduino in Ubuntu
sudo apt-get install gcc-avr avr-libc
Download newest release from http://arduino.cc/en/Main/Software 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
Thursday, July 26, 2012
Superscript, subscript, and padding (margins) for text boxes in Illustrator CS5
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
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 > { "," * } 'skip$ if$ t "others" = { " et~al." * } { " and " * t * }to
{ namesleft #1 > { ", " * t * } { t "others" = { " et~al." * } { ", and " * t * }After this we might need to run the command
sudo texhashIn Lyx, click on bibliography, browse to new (apalike2.bst) style file.
Changing Submitted to Defended date in CIT thesis title page
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
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 setup.py develop
When formatting a new drive use NTFS
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
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
pylab.ion()
import numpy as np
pylab.plot(np.arange(10),np.arange(10)**2)
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 http://www.virtualenv.org/en/latest/index.html). 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 http://www.riverbankcomputing.co.uk/software/sip/download and http://www.riverbankcomputing.co.uk/software/pyqt/download.
cd ~/Downloads/sip-4.13.3/
python configure.py
make
sudo make install
cd ../PyQt-x11-gpl-4.9.3/
python configure.py
make
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 http://wxpython.org/download.php#stable
Following these instructions (http://wxpython.org/BUILD.html I did this:
cd ~/Downloads/wxPython-src-2.9.3.1/wxPython
sudo apt-get install gtk+3
sudo apt-get install gstreamer0.10
This takes a LONG time
python build-wxpython.py --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: http://codersbuffet.blogspot.com/2009/09/wxpython-in-virtualenv.html
might try it later...
Or possibly something like this:
http://wiki.wxpython.org/wxPythonVirtualenvOnMac
Monday, June 25, 2012
Using Elyxer to convert from Lyx to html
- Download Elyxer from here. (The current version when I downloaded it was 1.2.3)
- In a terminal, run
cd elyxer-1.2.3/ sudo ./install.py
- If you used \emph{<species name>} in your .bib file, see NOTE below.
- 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).
- In a terminal, run
elyxer.py --destdirectory "htmlImages" --title "<title of html page>" document.lyx <name of the output>.html
- Move the html file to the destination directory.
- Double click the html file to view a nicely formatted and linked version of your lyx file!
- Download the plugin for regular expression search and replace using gedit from here:
- Download and extract the files (found here).
- 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 ./
- Close gedit
- 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.
- open your bibtex file(s), and save a new copy (this will mess up the pdf output of your lyx document).
- In the regular expression search box, search for \\emph\{([a-zA-Z_1-9 ]*)(\}) and replace with <i>\1</i>
- 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.)
- 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
Getting Lyx to work with Caltech thesis
- install Lyx using Synaptic
- From http://www.work.caltech.edu/~ling/tips/cit_thesis.html download
- cit_thesis.cls
- cit_logo.eps*
- cit_logo.pdf*
- cit_ntheorem.std
- 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
- open Lyx
- run Tools>Reconfigure
- close Lyx
- reopen Lyx
- run File>New from Template
- choose cit_thesis.lyx
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
Strategy 1.
Paste snippets to http://www.smipple.net, 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 https://code.google.com/p/google-code-prettify/. I just embedded the following code after the meta tag of the html of this blog's template<link href='http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css' rel='stylesheet' type='text/css'/> <script src='http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js' type='text/javascript'/>and this in the script tag
prettyPrint();
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; </pre>
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 np.ma.isMaskedArray(alpha) and alpha.mask.shape!=(): N = np.sum(~alpha.mask,axis) else: if axis is None: N = alpha.size else: 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...