Pascal Schulthess

The only true voyage of discovery, the only fountain of Eternal Youth, would be not to visit strange lands but to possess other eyes, to behold the universe through the eyes of another, of a hundred others, to behold the hundred universes that each of them beholds, that each of them is.

Arrrr

Now I remember this one very specific feeling when you find an error in one of the scripts. Not in some random script, noooo, this would be to easy. But rather in one of the most central algorithms I developed over the last year. One of the algorithms that is the basis for so many other scripts and results and figures and and and. Arrr. That’s exactly the way I want to start the weekend. NOT!

Call for Papers

PHD Comics: Call for Papers

PHD Comics are just hilarious!

Science on an Android

Yesterday I received my new HTC Desire Android phone, and I have to say I pretty psyched to discover its possibilities. Of course I first had to look for any science apps. Sadly I found only three worth mentioning:

  • Detexify: Just paint a symbol for which you want to know the LaTeX code on the screen and let there be magic.
  • HandyCalc: Best calculator out there. Let’s you even solve and plot equations and functions.
  • PubMed Mobile: Search PubMed with using a browser.

Deconvolution of nested cell arrays in Matlab

Recently, I faced the problem of getting heavily nested cell arrays, and since there’s no built-in function to deconvolve such cell array, I had to find another solution.

If you have a nested array nestedArray which is defined as

nestedArray = {{'a','b'},'c'};

and you want to flatten it in way that it looks like

flatArray = {'a','b','c'};

you need to write a short function which looks like

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function flatArray = flattenCell(nestedArray)
  error(nargchk(1,1,nargin));
  if ~iscell(nestedArray),
    error('Must be a cell array.');
  end
  flatArray{1} = [];
  for i=1:numel(nestedArray),
    if iscell(nestedArray{i}),
      y = flattenCell(nestedArray{i});
      [flatArray{end+1:end+length(y)}] = deal(y{:});
    else
      flatArray{end+1} = nestedArray{i};
  end
end
flatArray(1) = [];

I found this beautiful piece of code in this post in the Matlab Usenet Group.

Get excited and make things

Get excited and make things
It’s tough learning the ropes in such a complex field. There are hundreds of papers to read, thousands of terms to understand and dozen of experimental methods to a least recognize. The last couple of days and weeks I spend time with reading papers which where mostly describing experiments. Note, that I’m a theoretician and that I had no idea what Western Blots etc. are. Now I’m a teeny-weeny bit more familiar with all that experimental stuff, although I’ve read at least ten papers about it.
But, now it’s about time to get things started. One theoretical paper later, there are multiple ideas buzzing around, which could easily result in more than month of programming, analyzing and interpreting.

I’m excited and look forward to make things.

[Image by moleitau]

First snow

It was quite nice today. Sitting in the cafeteria, looking outside and witnessing the first snow of this winter falling down on Berlin. That was the second time I realized that I will feel at ease with living in Berlin and working at the university. Even in the winter, although everybody says that Berlin’s not nice during this gray and cold time of the year. But I like returning home from the university in the dark, walking through the rain and a brightly lit streets, feeling the wind that always blows in the city.

[Image by Pink Dispatcher]

Papers – literature management

Papers LogoSo, what are the first things when you start a new job? Right, prepare your computer in a way that the upcoming work runs as smooth as possible. This process calls for even much more time if you have to get familiar with a totally new operating system. Fortunately, the operating systems coming from Apple are really really really easy to learn and understand. But, of cause, you need to “learn” new programs too. And if you’re lucky, these programs even do the job a little bit better than the ones you used to use. After a couple of weeks I really didn’t stumbled over outstanding Mac software. Ok, everything was a little more “stylish” than on my Ubuntu machine, but that’s pretty much it. In fact, Ubuntu is in many ways much more geek-friendly.
But, the exception proves the rule. For every researcher, the program for managing papers and other literature is quite important. I was used to the way, the ordinary bibliography managing tool has be operated. First you have to search for a paper via Google Scholar or PubMed. Secondly you either have to insert all the meta data of an article by hand or copy the BibTeX code in your program. At this point you haven’t downloaded the paper yet.
But this whole procedure changes and consumes much less time now with the incredible Papers. I really haven’t seen a piece of software which does the job so well. In the following I’d like to list a few of its features.

  • Search article repositories and download articles without leaving Papers
  • Papers lets you view, browse and search your library, iTunes style
  • Ease the pain of organizing and naming files on your hard drive with Papers’ automatic management
  • Collect your articles together or create smart groups that are always up to date
  • Browse your library by author or journal, and check for recent articles you don’t yet have

Well, if you’d like to use Papers you have to pay a couple of bugs but it’s definitely worth it. By automating nearly every process in literature management, you gain time to actually read all the stuff. And there’s even an iPhone/iPod Touch App to take your literature with you wherever you go.

Papers – Website

No, I wasn’t paid from anybody to write this post. I only wanted to share my happiness that there actually is quite good software out there for literature management.

Logarithmic Plot with two y-axes in Mathematica

Since there is no built-in Mathematica 6.0 function to generate a plot with two linear y-axes and a logarithmic x-axis, I found the following method which fulfilled my needs.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
TwoAxisListLogPlot[f_List, g_List, frange_, grange_, color1_, color2_,
   opts___?OptionQ] := 
 Module[{old, new, scale, fm, fM, gm, gM, newg}, {fm, fM} = frange;
  {gm, gM} = grange;
  scale[var_] := ((var - gm) (fM - fm))/(gM - gm) + fm;
  old = AbsoluteOptions[
     ListPlot[g, Frame -> True, PlotRange -> grange, 
      DisplayFunction -> Identity], FrameTicks][[1, 2, 2]];
  new = (Prepend[Rest[#1], scale[First[#1]]] &) /@ old;
  newg = 
   Transpose[{Transpose[g][[1]], 
     Map[scale, Transpose[g][[2]], {1, 2}]}];
  ListLogLinearPlot[{f, newg}, Frame -> True, 
   FrameTicks -> {Automatic, Automatic, None, new}, 
   PlotStyle -> {{color1}, {color2}}, 
   FrameStyle -> {{}, {color1}, {}, {color2}}, 
   PlotRange -> frange*(1 + .00 (fM - fm)), opts]]

This defines the new function TwoAxisListLogPlot. The usage of this new function is:

18
19
20
21
22
23
24
25
26
Labeled[Labeled[
  TwoAxisListPlot[data1, data2, {5, 8.3}, {450, 460}, Red, Blue, 
   Axes -> False, Joined -> {True, False}, 
   PlotMarkers -> {Style[\[EmptyCircle], Red, Medium, 
      Background -> White], 
     Style[\[FilledUpTriangle], Blue, Medium]}], {Style["X", 
    FontFamily -> Times], 
   Style["Y", Red, FontFamily -> Times]}, {Bottom, Left}], 
 Style["Y-alt", Blue, FontFamily -> Times], Right]

where data1 and data2 represent the two datasets, obviously. The resulting plot looks like this:
ListLogLinearPlot with two y-axes

It is also possible to do a double logarithmic plot by changing ListLogLinearPlot in line 13 into ListLogLogPlot.
A running Mathematica example can be found in the repository.

Inkscape and textext: Deprecation Warning

I just came across the following error of textext in Inkscape.

~/.inkscape/extensions/textext.py:55: DeprecationWarning: 
the md5 module is deprecated; use hashlib instead
import os, sys, tempfile, traceback, glob, re, md5, copy

This error arises for textext 0.4.4., Inkscape 0.46 and Python 2.6.2. Fortunately I found a solution at bitbucket. But since I had some problems understanding how to change the python file, I will help you out with a detailed how-to.

Open the textext.py file mentioned in the error message with an editor of your choice. Now change the the lines

54
55
56
import inkex
import os, sys, tempfile, traceback, glob, re, md5, copy
from lxml import etree

into

54
55
56
57
import inkex
import os, sys, tempfile, traceback, glob, re, copy
import hashlib
from lxml import etree

Furthermore change

868
869
870
871
872
873
874
875
876
877
878
    def __init__(self, document):
        PdfConverterBase.__init__(self, document)
        self.hash = None
 
    def convert(self, *a, **kw):
        # compute hash for generating unique ids for sub-elements
        self.hash = md5.new('%s%s' % (a, kw)).hexdigest()[:8]
        return PdfConverterBase.convert(self, *a, **kw)
 
    def pdf_to_svg(self):
        exec_command(['pdf2svg', self.tmp('pdf'), self.tmp('svg'), '1'])

into

868
869
870
871
872
873
874
875
876
877
878
879
880
881
    def __init__(self, document):
        PdfConverterBase.__init__(self, document)
        self.hash = None
        USE_GTK = False
 
    def convert(self, *a, **kw):
        # compute hash for generating unique ids for sub-elements
        m = hashlib.md5()
        m.update('%s%s' % (a, kw))
        self.hash = m.hexdigest()[:8]
        return PdfConverterBase.convert(self, *a, **kw)
 
    def pdf_to_svg(self):
        exec_command(['pdf2svg', self.tmp('pdf'), self.tmp('svg'), '1'])

That’s it. Restart Inkscape and you’re done.

Happy TeXing