The great Matlab to Python Bridge

8.23.09

Currently Matlab is undergoing some major changes. While it slept for the past 5 years other programming languages have stepped up to take its place. Python, C++, Java amongst others have become as easy to use and as efficient as Matlab. The current  problem, however, is that not all projects and libraries exist in all these languages. So what happens when you have a great program in Matlab and a great program in Python and you want to tie the two together? Here is my experience this weekend:

Day 1: This will be great. I’ll use the Python C API to call python from Matlab. I’ll save the Python state as a Matlab variable and I can always start up my Python session where I left off.

Day 2: Alright.. maybe not. But let’s just try calling Python from C, I just want to make it work, not have it running efficiently.

Day 3: Ok, clearly Python has a crappy API. Moving to the client/server socket communication approach. Phew.. must it be this hard?

Matlab and movies

8.10.09

Animations of how 2D matrixes change over time can sometimes be helpful in detecting trends. Bellow is a small bit of code, very trivial, that converts a set of 2D matrixes to a avi movie.

% Images = set of 2D matrixes that we want to convert to a movie (values range from 0-255)
% Frames = Pseudo RGB version Frames
% Mov = Matlab structure that holds the movie
Width = 48; Height = 48;
NumberOfFrames = size(Images, 2);
Frames = zeros([Width, Height, 3, NumberOfFrames]);
for i=1:NumberOfFrames,
Frames(:,:,1,i) = Images{i};
Frames(:,:,2,i) = Images{i};
Frames(:,:,3,i) = Images{i};
end
Mov = immovie(Frames);
movie2avi(Mov, 'movie.avi');

Illusionary API’s

6.30.09

A long time ago, before Facebook was “open,” I devised the first API to extract data from the site for visualization and scientific inquery. More significant than the fact that the API was the first of its kind, it was a signal to the blogging world that Facebook and other social media websites had to become more open. At the time TechCrunch and others quickly picked up on my efforts and questioned why our data was being locked inside these sites. The effort was fairly successful for about two years an API/framework was released into the wild, officially this time.

While Facebook’s API is fairly good, giving access to all of your information, it is very restrictive on the other information that can be seen on the site about your friends. A perfect example is pictures. While you can see all of your friends pictures, through the API you can only see your own. While partially understandable, it places an incredible hindrance on what can be done with the API. What possibly useful tool can one make with just your own information? Visualize my address? Show the pictures that I took myself? Tell me how I can be reached?

Despite the hype of Facebook applications none are actually useful or pertain to the data that can be extracted with the API (except perhaps your name and the list of friends you have so they can be spammed to join the app). This is a trend that can be seen in all social media API’s. When was the last Twitter or Digg API that actually did something novel with the vast amount of data that these sites generate? Probably the worst part about it is that there is no list of restrictions that these API’s have. Yesterday I spent an entire day developing an application that became entirely useless after finding out that I could not see other people’s pictures. Was this piece of information on the API’s documentation, no.