Finn Årup Nielsen’s posterous

 

Decorators: Python nisse functions.

As we are entering the yule it might be time to give an example of the Python programming language equivalent of a yule-nisse: a decorator. A nisse might playfully tease others. Below the "nisse" decorator teases the "add" function and change its behavior:

class nisse(object):
def __init__(self, f):
pass
def __call__(self, x, y):
print 'hæhæ'
return x+y+1

def add(x,y):
return x+y

add(2,2)

@nisse
def add(x,y):
return x+y

add(2,2)

When "add(2,2)" is called the first time the result will be 4. The next time with the "nisse" the result will be 5.

Loading mentions Retweet
Filed under  //   Python  

Comments [0]

23 year in coma and then in headlines.

Rom Houben was thought to have been in coma for around 20 years but then Steven Laureys brain scanned him with positron emission tomography and found that he was minimally conscious. From a German news article it gets into English news and further even to the front page of a Danish tabloid. And the news media had citations from Rom himself: So he can communicate with complete sentences! That is something of a story.

I heard of this story and found that it already was on Wikipedia, where on Rom Houben's page one could read a section called "controversy". A video was linked from the Wikipedia page and it clearly showed Rom communicating via Facilitated Communication (FC) (på dansk: staveplade). Now FC has exceptionally low standing in the scientific community, and immediately that would call the whole story into question. I heard Steven Laureys in one scientific conference and he seemed to me to be an ok guy---not one that would start using FC. But this story could undermine his credibility. Anibal from Spain, that I follow on Twitter, pointed me to the an entry in Neurologica Blog where commentors were also very sceptical. But one---presumably Flemish speaking---commentor pointed to a recent Belgian news article where Steven Laureys had spoken. The commentor translated it to English, and according to this Steven Laureys says:

That (FC) is a debate that troubles me much more. I myself am sceptical, and that kind of facilitated communication still has a bad reputation, and rightly so. I'm not part of that, and have never suggested using it.

So it seems the news media made this story big by not being critical about the FC. And Wikipedia is more credible?

Loading mentions Retweet

Comments [0]

Twitter text mining for sentiment analysis of COP15

In the project Responsible Business in the Blogosphere between Copenhagen Business School and Technical University of Denmark we will try to use text mining on blogs for computerized analysis of so-called corporate social responsibility (CSR). Twitter provides a convenient interface for downloading the tweets on its site and as a start on the project I tried to see how this microblogging service could be used in sentiment and topic analyses. A prototype is now running from the rb.imm.dtu.dk/base Web server, and even a rudimentary sentiment analysis seems to find that for example the company Novo Nordisk has more positive tweets than for example Pfizer has.

As of ultimo November 2009 I have put a sentiment analysis of tweets relating to (United Nations Climate Change Conference (COP15) on the main page. It shows a "barometer" reflecting the ratio of positive and negative tweets. The negative tweets may for example be from twitters pessimistic about how we can solve negative consequences of human impact or they may be from twitters hostile to the COP15 meeting. Positive tweets may for example be from twitters excited about going to Copenhagen or from twitters expressing hope.

A positive example (slightly edited):

Barack Obama to attend Copenhagen climate summit. Ah, that's better news - hope he brings good US stance

A negative one (also slightly edited):

I Hate Al Gore » Global Warming Fraud Exposed as Copenhagen Approaches

It will be interesting to see the development of sentiment related to COP15, especially during the conference days 7 December to 18 December 2009.

Loading mentions Retweet

Comments [0]

Using Google Web-service to keep track of scientific citations to me

Google Scholar allows me to see which scientific papers cite my scientific papers. However, it does not order them according to date so I cannot easily identify the most recent papers with cite to me.

One way to somehow identify recent citations is to use the "as_ylo" parameter available in the advanced search. With as_ylo=2009 only the papers published in 2009 are shown to the given query. Combining that with a negative 'author:' query gets you some of the way, e.g., with "Nielsen FA" -author:"FA Nielsen" (included as_ylo=2009) I find papers from 2009 mentioning 'Nielsen FA' that are not authored by me.

To get a higher retrieval rate I list some of the different variations of my name in the query. The real query is then (abbreviated) "Nielsen FA" OR ... -author:"FA Nielsen" ...!

As the year progresses one gets more and more citations and it becomes difficult to identify the new ones. Using the real-time search in the standard Google Web search one may try an alternative way. Restricting the search to PDF files and real-time search for past month data may result in newer data, - but probably also lacking papers from publishers letter Google Scholar in but Google Web out: "Nielsen FA" OR ... filetype:pdf

It is possible that Google Alerts also can help.

Loading mentions Retweet
Filed under  //   citations   Google   Google Scholar  

Comments [0]

On-the-fly creation of CC-by-sa maps with OpenStreetMap

I think I first heard of OpenStreetMap at the conference Wikimania 2008 in Alexandria, Egypt. Essentially it is a Wikipedia for maps: "The free wiki world map". And they are quite far. But you still can make some contribution before the entire world is mapped.

I now discovered that there is a toolserver that enables on-the-fly creation of maps. This URL will return a JPEG image file with the central of Kongens Lyngby rendered (see also image):

http://tah.openstreetmap.org/MapOf/?lat=55.77&long=12.5&z=15&w=600&h=400&format=jpeg

A MediaWiki extension called Simple image MediaWiki Extension seems to allow one to include images of this kind in MediaWiki wikis.

The main site of OpenStreetMap makes quite good renderings. Whereas some commercial interactive Internet maps do not quite like my Ubuntu and Debian Konqueror Web browser the OpenStreetMap suffers no such problems. And that goes for printing as well.

Not all of the world is well-mapped. The village of Ørum misses several streets. However, Kongens Lyngby is detailed mapped. I guess the nerd density is higher in Kongens Lyngby with the Technical University of Denmark nearby: With sufficient zoom one can see street numbers, cafés, sushi restaurants, and the small path between Sorgenfrivej and Baune Alle with all its staircases, - no small footpath missing!

While it is easy to view, it is not so straightforward to edit. I got myself an account and tried to edit around Ørum, following the instruction on a wiki page. For example, I tried to label the school in Ørum. Although, I can see the changes in the edit interface, they do not appear in the map, and I cannot find the 'save' button...

Loading mentions Retweet
Filed under  //   map   OpenStreetMap  

Comments [0]

Usability study on our refrigerator

Software is often accused of having bad usability. However, many household items with far less functionality may also suffer. Video tape recorders are usually pretty bad, but even refrigerators can be silly. There are only a few features in the standard human-refrigerator interaction: The door and its handle, the light, the fruit boxes, the shelves and the regulator. The door and adjustable shelves and the boxes are quite straightforward and the light that switches on when the door opens is a marvelous invention. It leaves the regulator. Our old refrigerator has a min-max regulation. But what is min? Temperature or effect? Well, probably temperature, but a more informative marking would say cold-hot or display blue-red markings.

Loading mentions Retweet
Filed under  //   usability  

Comments [1]

Debian upgrade still a bit of a nerdish headache

I upgraded Debian on an old desktop computer from oldstable (etch/Debian 4.0) to stable (lenny/Debian 5.0). Upgrading is still a bit of a headache. It runs ok with "aptitude dist-upgrade". It takes quite a while, - while you are watching "Running udpmap-sys. This may take some time": Yes, it indeed does! Then comes the reboot. It now sometimes can't mount and stops in the middle of the booting. I wonder if the old computer suffers from SCSI hardware problems or if it is a new kernel issue. Then comes X. First it didn't start. After the introduction of magic in /etc/X11/xorg.conf X would come, but now my GL capabilities have been lost somewhere between nvidia binary, nvidia legacy binary and nvidia standard driver. I could probably spend some time looking at this issue, but I would like to use my time better than for these nerdish problems. Hmmm...

Loading mentions Retweet
Filed under  //   Debian   etch   lenny   nvidia   upgrade  

Comments [0]

A Nobel prize in imaging?

Thomson Reuters has announced their prediction for the 2009 Nobel prize. Among them is Seiji Ogawa. He is indeed a good guess as the pioneer for functional magnetic resonance imaging, that is now much used in cognitive neuroscience. Ogawa was not the first how did functional neuroimaging. Niels A. Lassen and David Ingvar were quite earlier - almost too earlier for their technique to have impact on other laboratories. Much of initial functional imaging (some 10-15 years) was performed with positron emission tomography (PET). Whereas there have been Nobel Prizes for MRI and CT scanning, there haven't - as far as I recall - been a Nobel Prize for PET - or SPECT for that matter. Another development that could deserve recognition is Fludeoxyglucose (FDG). Whereas fMRI is still a bit of a toy for scientists the combination of PET and FDG is dead serious forming the work horse for advanced cancer imaging. I am not too much into the history of FDG but Alfred P. Wolf and Louis Sokoloff seem to have been important contributors. For PET David Kuhl and Michael Phelps are often mentioned. Since PET predates fMRI and PET is used much in oncology - not just cognitive neuroscience - it might be that the Nobel goes to PET instead of fMRI, - if a Nobel Prize in Physiology or Medicine is awarded for imaging at all.

Loading mentions Retweet
Filed under  //   fMRI   imaging   neuroimaging   PET   SPECT  

Comments [0]

Generating pie chart with Python and Google Chart API

I recently discovered Google Chart API. From URLs it is able to generate image files with plots of different sorts, e.g., line plots, pie charts or even QR codes. The pie chart here was generated with the following code:

 
du -sk /usr/* > stats.txt
python -c "d = open('stats.txt').read().split();
s = sum(map(float, d[0::2]));
print('http://chart.apis.google.com/chart?cht=p&chd=t:' +
','.join(map(lambda x : str(int(float(x)/s*100)),d[0::2])) +
'&chs=600x300&chl=' + '|'.join(d[1::2]));"

Copy and pasting the returned URL into a Web-browser will show the Google-generated pie chart as PNG. Alternatively one could let Python download the file by modifying the code to use 'urllib.urlretrieve()'.

For the data in the 'chd' parameter it seems that one needs to indicate the percentage.

There is also a module called pycha, which I haven't tried.

Loading mentions Retweet
Filed under  //   Google   plot   Python  

Comments [0]

1000 total pages in the Brede Wiki

The MediaWiki page counter for my Brede Wiki now tells me that it has passed the 1000 "total pages" mark. Pages include, e.g., comments with data on scientific articles, pages for brain regions and pages for "topics" such as neuroticism. The Brede Wiki is presently open for anonymous edits and wiki spammers are quite interested in the article on Hidehiko Takahashi. I wonder if they are communicating something via the cryptic comment fields. Disregarding the spammers the article on Richard S. J. Frackowiak seems to be the most popular article after posterior cingulate gyrus.

Loading mentions Retweet
Filed under  //   mediawiki   neuroinformatics   wiki   wiki spam  

Comments [0]