Friday, December 9, 2016

Power analysis in A/B Tests

I recently wrote a very basic jupyter notebook demonstrating how to calculate the sample sizes necessary to detect a minimum effect size given desired false positive and false negative rates. I used a web site A/B test as an example, but the technique is generally applicable.

Thursday, June 2, 2016

Using Inkscape and FreeCad with Epilog Laser cutters

Our 75 watt Epilog Helix 24 is a tremendously useful piece of laboratory equipment for quickly prototyping or fabricating parts. Using it to cut out parts designed in Solidworks is fairly simple, but I was interested to see if it can be used with open source alternatives. Happily, the answer is yes!

Inkscape

First of all, because laser cutting is essentially a 2-dimensional process, I wanted to be able to cut out designs produced in Inkscape, the premier open-source 2D drawing application. Because our Epilog has a 24"x18" cutting surface, I created a 24"x18" document, and then I drew the lines I wished to have cut. Now, to have the lines cut (instead of raster engraved) it is necessary to make all the line widths sufficiently small (under Fill and Stroke>Stroke style>Width). I chose .001 px. Unfortunately this makes them smaller than a pixel on most screens, but don't worry, they are still there. To actually send the file to the laser cutter, in Inkscape Windows Version 0.91, choose Extensions>Export>Win32 Vector Print. This brings up the Epilog print screen. Make sure the height and width match the document, and you are ready to cut!

Laser cutting with Inkscape

FreeCad

Although Inkscape is great for quick 2D designs, for more complicated parts full 3D design software is necessary. FreeCad is starting to reach the point where it is ready for real use. After designing a part, it is easy to save an orthographic view to an svg file, then use the laser cutter to cut it out: First, select the part and go to the Drawing Workbench. From there you can create a new drawing, and add the orthographic projection. Finally, click the save drawing icon:

Exporting from FreeCad to svg to cut on a Epilog laser cutter
The drawing is saved as an svg file. I had some trouble cutting designs from these files directly, but if you open the document we first created in Inkscape, then import the FreeCad file, it seems to work. After importing the part drawing, it is apparently necessary to select all the elements and convert them to paths:  go to Path>Object to Path. (I discovered this necessity because my part contained many circles, which were not getting cut by the laser cutter.) Now make sure your line widths are .001 pixels, and follow the directions above!

Monday, April 4, 2016

Photoreceptor paper accepted!

Our paper on polarization processing by photoreceptors is out in the Journal of Neuroscience! Here is some supplementary information that describes our process for mounting flies for simultaneous functional imaging and behavioral experiments.

Wednesday, February 10, 2016

Have gravitational waves been observed?

They certainly seem to be trending on Google searches:

Tune in tomorrow morning at 7:30 AM to hear an announcement from Caltech, MIT and the Laser Interferometer Gravitational-wave Observatory (LIGO): www.caltech.edu.

Monday, February 8, 2016

Changing font in matplotlib

In order to change the font of text in a matplotlib figure, I needed a list of the available fonts. It took me a frustratingly long time to find this stack exchange answer, so I thought I would record the solution here.

import matplotlib.font_manager
{f.name for f in matplotlib.font_manager.fontManager.ttflist}

Then just choose a name from the set and insert it into a text command, e.g.

import matplotlib.pyplot as plt
plt.ion()
plt.title('title', fontname='FreeSans')

Wednesday, December 2, 2015

Programming new Reiser panels (G3)

I think I've mentioned the 'panels' that Michael Reiser developed while he was in Michael Dickinson's lab. These are widely used, but programming them can be a bit difficult and tedious. (By program, I mean upload the firmware to the panels themselves, not simply changing the address, which can be done easily over serial.) Will Dickson at iorodeo.com recently wrote a great little collection of shell scripts to make this process easier.

You will need a panel controller box, the panels you want to program, and an avrisp mkII.

First, plug the mkII usb into your computer and the female header side into the six-pin header on the front of the controller box:


Make sure to align the small arrow on the avrisp mkII with the arrow on the header:


Next, plug a panel face-up into the female header:



Now, download and unzip the scripts from Will's bitbucket site. In a terminal, cd into the iorodeo-panels_prog_avrdude/program directory. Finally, run

./program_panel <address>


(The first time, this might require your password.)
Note <address> is the panel address you want to assign to the panel in HEX. That's right, you need to convert to hex from decimal. To do this conversion, I use an interactive python prompt and the following:

import numpy as np
np.set_printoptions(formatter={'int':lambda x:hex(int(x))})
print <address in decimal>


Friday, October 9, 2015

Fractal life

This week's special issue of Current Biology, especially Nicholas Butterfield's article on the Neoproterozoic, got me thinking about my favorite pre-Cambrian life form, Charnia. This organism is believed to have developed according to rigidly recursive rules, and I thought it would be fun to play with a terrific Python plotting library, pyqtgraph, in this context. I started with the discussion of recursion in this book. This animate gif is the result:


I think the result is kind of pretty. The (somewhat sloppy) code that produced the images is here: