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')