Phytoplankton are colorful

A few summers ago I had the chance to work at Mote Marine Laboratory, in the Phytoplankton Ecology Group lead by Dr. Gary Kirkpatrick. This was the first time that I really considered doing research outside of traditional physics (in high school I had always imagined that my research career would consist of aligning lasers and soldering circuit boards), and so it was a really eye-opening experience that showed me how elegant the intersections between biology, computer science, and physics can really be.

The image at the head of this post is a scalogram. It’s the result of performing a mathematical operation called a wavelet transform on a one-dimensional data set. This particular data set was an absorption spectrum from a sample of live phytoplankton (spectrum shown below), which shows the amount of light that a sample of plankton absorbs as a function of the wavelength of that light. This is essentially a really precise way to determine the color of  the plankton, a useful metric because different species of phytoplankton tend to absorb different colors. Part of the reason for this is because different species of plankton inhabit different depths in the ocean, and the color of sunlight (and thus the wavelength at which maximal photosynthesis occurs) changes with depth due to dispersion of short-wavelength light by seawater.

Absorption spectrum

The absorption spectrum of a mixed sample of phytoplankton. Each peak comprising the spectrum is the result of a single pigment with a Gaussian absorption spectrum, and the observed overall spectrum is a linear combination of the spectra of these individual pigments.

The scalogram is the result of taking short sections of the spectrum, and comparing them to short pieces of a  reference function called a wavelet, here represented by a normal distribution that’s been truncated outside of some interval (more generally, any finite section of a smooth function will work as a wavelet—it just happens that a bell-shaped distribution is a convenient first choice in many problems). A large similarity between the wavelet and the section of the spectrum results in a dark color being shown on the plot—this indicates that that portion of the spectrum was shaped like the wavelet. As one moves along the vertical axis of the plot, the width of the wavelet is gradually widened and the transform is repeated, resulting in a plot with two explanatory variables (the width of the wavelet and the location in the spectrum), and one response variable (how much that part of the spectrum matched the shape of a wavelet of that size).

Why are scalograms interesting? The plot shows where the data had peaks (corresponding to pigments absorbing colors), but it also shows the characteristic scale of those peaks. Most plankton spectra have the large feature in the right hand side of this plot, which corresponds to the absorption of light by Chlorophyll A (the primary photosynthetic pigment found in most species of phytoplankton). The vertical axis allows one to see that Chlorophyll A absorption peaks also have a characteristic width of 6 (arbitrary units), identified by where the tree-trunk like shape was darkest. The advantage of looking at a plot that separates both the width and location of absorption peaks is that one can also identify more subtle features (like the faint, wide patterns at the top of the plot) which would be almost impossible to identify by looking at the absorption spectrum alone. Scalograms are thus used to increase the information that one can extract from a spectrum, by allowing features in the data to be identified by both their characteristic absorption color (the location of the peak) and their characteristic width. For a sample of water containing many different species of plankton, the added information conferred by taking a wavelet transform can be used to better separate out the many species that can be contributing the overall observed spectrum.

Diamond nanowires

Here is an SEM picture of some 1-um-tall nanowires I made in diamond last summer. I learned how to make these while working for the Loncar group, who are generally interested in using nanofabrication techniques  to develop novel photonic (as opposed to electronic) devices that exploit nanoscopic phenomena like Casimir forces, quantum entanglement, and optomechanics. While these phenomena have been extensively characterized in the past, the group is working to actually use them to develop new technologies, such as single-shot spectroscopy, high-precision magnetometry, and even quantum computing

The subgroup that I worked in focused on nitrogen vacancy (NV) centers, which are point defects in diamonds that form when a single carbon atom in the lattice is replaced by a nitrogen atom, usually by bombarding the diamond with a high-energy beam of nitrogen ions. If the diamond is then annealed (heated up to a temperature below its melting point, but still sufficiently high that individual atoms can migrate through the lattice), the now-mobile nitrogen atoms will tend to seek out positions in the lattice that are adjacent to gap defects, or locations in the lattice where carbon atoms are missing. The intuition behind this behavior is that nitrogen, unlike carbon, prefers to form three bonds (it has a lone pair of two electrons that usually don’t form bonds). These lone electrons prefer to spread out due to their mutual repulsions, and so it is energetically favorable for the nitrogen to sit next to a vacancy in the lattice, where there will be less electromagnetic repulsion due to electrons in neighboring carbon atoms. The resulting two-point imperfection in the diamond, consisting of a nitrogen atom an an adjacent vacancy, is a very unique quantum system that many groups worldwide are now exploring for applications ranging from quantum computing to magnetometry.

A nitrogen vacancy center embedded in a diamond unit cell.

A nitrogen vacancy center embedded in a diamond unit cell.


The reason that NV centers are so exciting is that they act like fluorophores—you can shine a green laser onto them, and they will re-fluoresce red light. This means that incident light and absorbed light can be easily separated using color filters, making them immediately useful in many applications where synthetic quantum dots are used for similar effect. But a further advantage of NV centers is that they  natively have two possible ground states for their electrons, but when there is a magnetic field present the these two states “split” and one becomes more energetically favorable than the other. When an electron excited by green laser light relaxes into the now-less-likely ground state, it tends not to emit a red photon due to other mechanisms that spirit the energy away instead. The net result of this unique quantum structure is that the relative intensity of red florescence from an NV center can be used to infer the magnitude (and even direction) of local magnetic fields. All-optical measurement of magnetic fields using NV centers is currently being explored for biological applications (in which an electronic magnetometer would be too bulky or imprecise), but many groups are also exploring the use of NV centers for quantum computing applications, in which time-varying magnetic fields are used to flip a “bit” represented by the two possible ground states of the NV center, and the intensity of fluorescence from the NV center is used to read and write the state of the bit.

The energy level diagram of a nitrogen vacancy center. Yellow indicates non-radiative transitions.

The energy level diagram of a nitrogen vacancy center. Yellow indicates non-radiative transitions.

The wires shown here are usually built on diamonds that are known to contain a relatively high density of NV centers, so that it is very likely that each wire will contain at least one center. The wires essentially act as fiber optic cables: because the red light emitted by the NV centers can be emitted in several possible directions, but the optical setup used to measure fluorescence can only detect emission in one direction, the cylindrical wires are essentially used to channel the emitted light towards the top face of the wire, which is where the detection optics are then focused. The eventual goal of this research would be to use arrays of these wires to map magnetic fields of small objects like cells, allowing spatial resolution of magnetic fields in addition to precision measurement.

Computer tricks I use for research

My research involves a combination of coding, bench work, and pencil-and-paper equation solving, and there are a couple of programs and tricks that I find myself constantly using to make my life easier when storing and manipulating data:

1. Mathematica + Dropbox. One of the more annoying features of Mathematica is its lack of a simple “undo” feature for typing errors—if you accidentally delete a cell containing an important code snippet, it is pretty much gone forever. A really cool workaround I found here involves storing all of my Mathematica notebooks in a Dropbox folder that has automatic versioning activated. I’ve inserted the snippet SetOptions[SelectedNotebook[], NotebookAutoSave -> True] into the preamble of all of my notebooks (that is, the evaluation block that I always run before I begin working on the notebook, which does stuff like set the colors of plots and control the scope of new variables). This just tells Mathematica to perform a Save every time I evaluate some portion of my code, which Dropbox in turn sees as an opportunity to create a new version of the notebook online. I found that this method was much simpler to use than the options for Mathematica and GitHub (since it really just consists of remembering to dump all of my notebooks into Dropbox), and so I use this trick almost every day.

2. NameChanger. There are a number of ways to change the names of a large batch of files using native utilities on OSX—you can create a smart folder, write a Python script, or use Automator. NameChanger is a simple, open-source Python program that allows you to change the names of hundreds of files using regular expressions and a GUI.

3. Caffeine. This is a great utility for Keynote presentations and running long SSH sessions. All that this program does is prevent OSX from going to sleep for some user-specified amount of time.

4. Illustrator+Photoshop files into Keynote+InDesign. Whenever I’m designing a talk or a poster, I make of all my figures and diagrams using Illustrator and Photoshop. It turns out that you can embed links to these files into Keynote presentations or InDesign files (I use InDesign for all my posters), and if you update the original source files, you can set the host files to automatically update the poster or talk to have the newest figures. This is very helpful for when your supervisor reminds you that you forgot scale bars on all your plots, since after modifying the images you won’t have to re-export all your figures and then re-import them into your presentation or poster.

5. IFTTT (if this then that). This is a high-level web app and smartphone app that allows me to pass data and actions between common websites, like most major social networks, my Google docs account, and my email. The design is pretty similar to Yahoo Pipes, in that it doesn’t serve a specific purpose so much as it allows people to perform a lot of actions that otherwise would require programming web scrapers. For example, I use a script (the site calls them “recipes”) that records my GPS coordinates to a Google Document every time I send an email from my smartphone. This data is part of an ongoing machine learning project I’ve been working on. There are also scripts that do a lot of common tasks, like transferring all tagged Facebook photos to a Dropbox folder, or mirroring flickr collections in a 500 px account. I haven’t yet exhausted the range of functions accessible with this site, but I can see it coming in handy for performing little tasks that would otherwise require programming a custom Python script that accesses the API of two different web applications. IFTTT has essentially made a high-level wrapper for accessing API, allowing simple data transfers and operations to be performed.

6. iPython Notebooks. These are what convinced me to switch to Python over MATLAB. The killer feature of the cell interface is that it allows you to only run or re-run portions of a script, making it competitive with MATLAB’s own cell-mode interface for scripting. But unlike MATLAB, importing new functions and packaging functions is really painless. However, I still prefer using Mathematica notebooks for symbolic math over iPython+SymPy, since the former has special syntax for typing symbolic expressions where it formats things like fractions/square roots as you type, making it easier to make sure you are typing the formula correctly.