HackMIT: Polyglass

I attended HackMIT 2013 and had an absolute blast! Kartik Talwar, Spencer Hewett and I make a fantastic team.

Photo by Kevin Yiming Chen © Copyright 2013 Kevin Yiming Chen

In the turmoil that followed the hackathon (taking a weekend off of schoolwork and research has consequences), it slipped my mind to post our project!

We created Polyglass. A Google Glass application that analyzes the video in slow motion using the Eulerian magnification algorithm to calculate the human pulse from a video frame in quasi-real-time. Using video alone, we achieve the same functionality as a polygraph.

The picture below is a demo of our project; it compares the original video frame to the frame processed by Eulerian Magnification. This processing is an implementation of the Eulerian Magnification framework published by MIT.

Portions of our source are on Kartik’s github.

Braille Cell with VPython

The internet went down at my house, and I decided to play with vpython again!

#type individual brl cell using numkeys
from visual import sphere
R = 0.2 #filled dot radius
r = 0.1 #empty dot radius
#corresponds to numkeys
dotdict = {
'7': [1,3], #dot 1 
'4': [1,2], #dot 2
'1': [1,1], #dot 3
'8': [2,3], #dot 4
'5': [2,2], #dot 5
'2': [2,1] #dot 6
}
fulldot = dotdict.keys()
def draw(dots):
 [sphere(pos=dotdict[dot], radius=r) for dot in fulldot] #create empty dot matrix to represent empty cell
 [sphere(pos=dotdict[dot], radius=R) for dot in dots] #fill appropriate dots
print "Please enter stringn7t8n4t5n1t2n: "
string = raw_input()
if string.isdigit(): draw(str(string))

Let’s see it in action! The letter “j” (or “just” in G2):

The Engineer-Musician

There is a connection between engineering and music. For the sake of simplicity, I will shorten “math, physics, computer science, mechanical & electrical engineering” to “engineering.”

Let’s start with the general question:
Are engineering and music the same?

My immediate thought was that these fields constitute a gradient of knowledge and defining boxes that constitute each field is limiting to the solving of problems and the mastering of skills. I then realized that my immediate thought was an oversimplification and the question was too general to answer meaningfully, thus I refined the question slightly:

Are engineering and music two ways to look at the same thing?

I answer with a vague hypothesis: these fields are connected by general principles applied in different contexts.

As we know, one can’t prove that something is true purely by example; however, finding examples of these connections is exciting and interesting to think about. An example of evidence that supports this hypothesis is number theory. Number theory is deeply connected to the theory of harmonics. Using mathematics to prove that there exists a deep connection between the structures of engineering and music is almost cheating. Modern math becomes increasingly abstract. Each major concept works with many diverse objects, all sharing some common property. An abstract theory is born from the consequences of this property, which may then be applied to any of the diverse objects.

This led me to think about the connection of general thoughts and actions between the fields, rather than the underlying principles themselves. For example: the connection between completing projects in engineering and playing a musical instrument. Both activities are never-ending fountains of entertainment and learning; there is always room to improve yourself in your understanding and implementation of your knowledge in both cases.

The application of these knowledge bases involve a similar level of 3D spatial reasoning and abstract thinking. These subjects are built on modules and components. The understanding of each piece of the puzzle and how said piece connects and interweaves with the whole picture (which itself is another puzzle piece) is integral to both completing a project on time and understanding a piece of sheet music (especially if it is in an orchestral context).

I will attempt to demonstrate this connection with two specific examples:
learning a complex piece <= learning an instrument
learning to code <= learning a programming language.

(1) Before one learns and reliably performs a piece, they understand the language of music, whether that understanding is purely by ear or complemented by reading sheet music. They learn to play an instrument (in my case, the trombone). This learning forms a dictionary of muscle memory that consists of sheet music/sounds as keys and embouchure/hand position as corresponding entries. After practicing consistently over a long period of time, I began to feel the instrument as an extension of myself, as a voice to communicate with. To learn a complex piece, I practice each measure, and then practice weaving the measures together.

(2) Before one becomes a good programmer, they understand the basics of computer science (what it means to compile/interpret a program, how to create efficient programs, how to write general instead of hardcoded source, how to use existing libraries in your project, the practices of writing readable source/how to document code). They learn the basics of coding: variables and data types, strong vs weak typed languages, assignment vs. equality. They learn the syntax and lexicon of a programming language, and they learn to create code to execute their ideas. This new lexicon leads to a new way of thought, it includes the structures and semantics at a level of abstraction above the basic syntax of the language, this includes the concepts such as instantiation, monads, and verification. Enough practice leads to thinking in code, and intuitively recognizing how to compose an elegant and efficient solution to a computationally intensive problem.

Similarly, I find that composing orchestral music and creating/working on original research use similar structural thought and insight. Enough examples, I think you’ve got the point!

Although I am not a master of engineering nor music, I consider myself an engineer/scientist and an amateur trombonist. I enjoy learning and developing myself in both areas. I personally think of both music and engineering (especially mathematics, programming, and robotics) as collections of 3D structures to play with and put together whilst keeping in mind various properties and limitations.

Doodling at Dinner

While at dinner and conversing with friends, I took out my notebook and began to doodle (~2 hours).

As I answered questions about my method of drawing/deciding what to draw, my friend pointed out that this drawing style (doodling whatever comes to mind) translates to somewhat surrealist pieces.

The classification of my drawing style isn’t something I’d previously considered, so I found this realization interesting.

Braille System Font

I mentioned that I set my system font to Braille in a previous post. This tutorial generalizes to any font you can find in a .ttf format!

Download the Braille TrueType Fonts.

sudo apt-get unity-tweak-tools
sudo apt-get myunity

Extract the .ttf files, click the file you desire and “Install Font.”

Open myunity, go to the font tab, and adjust as you please! An example of this font in action, which will spill across my navigation menus for the sake of resolution:

Simple Cubic Lattice

Today, let’s have some fun playing with perspective rendering in Python! My graphics package of choice is VPython:

sudo apt-get install python-visual

Suppose we want to represent a simple cubic lattice: Using the visual package, we can create a collection of spheres at positions \((i,j,k)\) with \(i,j,k = -L…L\).

from visual import sphere
L = 5
R = 0.3
for i in range(-L,L+1):
 for j in range(-L,L+1):
  for k in range(-L,L+1):
   sphere(pos=[i,j,k],radius=R)

Resulting in this beautiful rendering:

But what if we want to change the color? Simply alter the last line:

sphere(pos=[i,j,k],radius=R).color = color.blue

Less atoms? Alter the value of L.

L = 1

Same number of atoms with smaller radii? Alter the value of R.

R = 0.2

Want more advanced computational physics with Python?

Coupled Oscillator Love

Disclaimer: This informal post assumes you are familiar with basic photonics and applied chaos theory.

Unfortunately, “chaos” has become a buzz word. Instead of using chaos as an umbrella term, I will use chaos to mean chaotic parameter driving (because that’s the cool stuff)! There is synchronized chaos.

Lasers are nonlinear oscillators – their behavior can be periodic or chaotic. You can sync two lasers operating in a chaotic state!

Coupled_oscillators
Source

If we place two lasers such that their beams are parallel and separated by a small distance \(dx\), the beams themselves will not overlap. For a small enough \(dx\), their electric fields do! This direct physical coupling of the two lasers is enough to induce sync!

You can also sync a bunch of different electronic circuits with linear error feedback coupling. Chua’s circuit is a freaking sweet combination of a chaotic electronic circuit and an optoelectronic chaotic oscillator. You can couple Chua’s circuit with a plasma discharge tube (Chua’s circuit produces the HV DC current require to power/sync with the discharge tube). Even though the systems are physically different they couple anyway! And that, my friends, is a wonderful demonstration of the beauty of math.

Unschärferelation

Konzepte der Quantenmechanik durch den dunklen Nebel der Unwissenheit aufgefressen. Lass mich den Nebel eines verbreiteten Missverständnisses aufheben. Lass mich deine gegenwärtige Meinung ändern.

Angenommen haben wir einen Straßentunnel. Und woher sollen wir wissen, dass ein Auto in dem Tunnel ist? Klar können wir das, ohne es anzuschauen. Wir bestimmen “experimentell”, ob sich ein Auto im Tunnel befindet, oder nicht.

Wir schaffen ein autonomes Roboterauto (und addieren die Zündschlossüberbrückung). Wir lassen das Auto den Tunnel geradeaus durchfahren und hören, ob es einen Zusammenstoß gibt.

Wenn wir einen Zusammenstoß hören, dann wissen wir, dass ein Auto in dem Tunnel ist. Das Ende des Tunnels ist nicht in Sicht! Aber, Messung verändert den Zustand (oder Form?) des Autos.

Das ist ein makroskopisches Beispiel der Unschärferelation.

Wir messen eine Eigenschaft der Elektronen, indem wir diese mit einem Partikel von ähnlicher Größe (Photon) ändern. Dies verändert andere Eigenschaften der Elektronen.

Die Elektronen sind tot. Die Partikel “weis” überhaupt nicht, was hier vor sich geht. Du weist genauso gut wie ich, dass Partikel keine fühlenden Wesen sind.

Carolin Zöbelein, danke für die Korrektur meiner Sprachfehler.