Sunday, 8 November 2015

Ergodic Analysis

My review paper about ergodic analysis came out on Thursday. Does ergodic analysis sound terrifying? It's actually quite a simple concept and it is a powerful method for extracting information about the dynamics of a cell division cycle from a single snapshot of cells at random stages of the cell cycle.

Ergodic analysis is particularly useful if a time-lapse video is impossible, for example if the cells swim or you want to do an analysis that kills the cells.

Does this sound interesting for your research? Drop me a message: @Zephyris.

Software used:
Autodesk Sketchbook Pro: Drawing the cells.
Inkscape: Page layout.

Monday, 1 June 2015

Pebbling in colour

The Pebble Time is finally out! This fantastically simple, yet massively functional, little smartwatch is now shipping to the Kickstarter backers who pledged their renewed support to the company that produced the original Pebble.

I've been lucky enough to be beta testing a developer preview model of the Pebble Time, and have had it on my wrist for the last few weeks. I used this time to put together some animated watchfaces which make the most of the colour screen, and learn some C programming along the way!

An elegant animated watchface, with each digit built from curving paths. Animated minute transitions, and tap-triggered animation to improve readability under low light. Animations, line widths and colours can be customised.

Inspired by the watchface shown on the red Pebble Time Steel advertising images:

A fun, animated, easy to read watchface. Every minute the bubbles in the background pop, and a set of new ones appear (by default) in a new colour. Alternatively you can customsise the colour of the bubbles. Tapping or shaking the watch also triggers the animation.

Inspired by the watchface shown on the red Pebble Time advertising images:

A colourful interpretation of the classic arc watchface design, with a Pebble Time-style loading animation and dynamic colour schemes. Colour schemes and whether or not to show the second hand can be customised.

A colourful interpretation of the classic pixel array digital watchface design, with loading animations, animated minute transitions and dynamic colour schemes. Colour schemes, pixel styles and animations can be customised.

Software used:
CloudPebble: Watchface programming. CloudPebble is an online IDE for Pebble watchfaces and apps.
Notepad++: Server side HTML/Javascript for the watchface settings.

Friday, 17 April 2015

Light-Years of DNA

Light-year, and DNA. Not two scientific terms you expect to see on the same page, but over your lifetime your body will produce around one light-year of DNA! That is about one trillion kilometres. Don't believe me? Let's do some maths:

Every cell in your body has two copies of your genome, held in 23 pairs of chromosomes. The human genome is approximately three billion (3×109) base pairs of DNA.

The famous double helix of DNA has about 10 base pairs per twist, and each twist is 3.4 nanometers long (3.4×10-9 metres, the same as roughly 20 carbon-carbon bonds).

This means that the total length of DNA contained in every cell of your body is approximately 2 meters (3×109 base pairs multiplied by 0.34×10-9 metres per base pair, doubled because of the two copies).

Your body has about ten trillion (1×1013) cells (excluding red blood cells), and this remains roughly constant through your life. There is a huge turnover of these cells though, as your body replaces cells to maintain itself.

Every time a cell is replaced its 2 metres of DNA must be produced. In most tissues the cells are replaced in a couple of months, and in many they are replaced in just a couple of days. Even cells in bones are replaced every few years.

The average lifetime of a cell is probably one or two months, so if you live to 80 then your cells are replaced about 500 times throughout the course of your life.

This means that the total length of DNA your body produces in your lifetime is approximately 1×1016 metres (2 metres multiplied by 1×1013 cells, multiplied by 500 replacements). 1×1016 metres (ten thousand trillion metres) is about one light-year (0.946×1016 metres)! Most amazingly it would not be a light-year of random DNA sequence, but ten thousand trillion identical copies of your DNA, faithfully replicated by your cells.

An estimation of the number of cells in the human body
How quickly do different cells in the body replace themselves?
Thanks to Rob Phillips for making me think about this!

Wednesday, 28 January 2015

Smooth Videos - AKA Correcting NASA

What makes a video look smooth? Your eye is extremely sensitive to problems with videos, and for any video to look smooth it has to have:

  • A high frame rate
  • A steady camera
  • Roughly even brightness each frame

Normally these are easy to get. Any modern camera will give a decent frame rate, and the exposure time for each shot will be accurate, giving an even brightness of images each frame. Camera steadiness is more difficult, but a basic tripod will solve that.

This is a lot harder in space! For a NASA space probe floating through deep space, keeping a steady orientation is a challenge. Spacecraft can do this well quite well, using thrusters and reaction wheels. They still make some small mistakes though. Getting an even exposure time for each frame of a video is also harder in deep space, especially as it might take minutes or hours for radio commands to reach the space probe so you have to trust its autoexposure. Luckily, given ok starting material, correcting camera shake and frame brightness problems by image processing is quite easy.

NASA's Dawn space probe is currently approaching Ceres, getting sharper pictures of this dwarf planet than ever before. A series of these pictures even shows this tiny world rotating. Unfortunately, they didn't correct the shake or brightness problems in the video released to the press:

A quick fix in ImageJ to remove the shake and even out the frame brightness makes a (dwarf) world of difference:

As the probe gets closer and closer to Ceres its shots are getting more and more spectacular, but the videos still need shake and brightness correction.

Interested in improving some NASA videos? I did the corrections using the free scientific image editing software ImageJ, and these are two handy macro scripts for video corrections in ImageJ:

Image stabilisation
//Stabilise based on signal intensity centroid (centre of gravity)
//Stabilises using translation only, using frame 1 as the reference location
//This method is suitable for stabilising videos of bright objects on a dark background
for (z=0; z<nSlices(); z++) {
 //For each slice
 //Do a weighted sum of signal for centroid determination
 for (x=0; x<getWidth(); x++) {
  for (y=0; y<getHeight(); y++) {
   v=getPixel(x, y);
 //Calculate the centroid location
 if (z==0) {
  //If the first slice, record as the reference location
  print(rcx, rcy);
 } else {
  //Otherwise calculate the image shift and correct
  print(dx, dy);
  makeRectangle(0, 0, getWidth(), getHeight());
  makeRectangle(-dx, -dy, getWidth(), getHeight());
Brightness normalisation
//Normalise image brightness to reduce video flicker
//Scales intensity based on the mean and standard deviation, using frame 1 as the reference frame
//This method is suitable for reducing flicker in most videos
for (z=0; z<nSlices(); z++) {
 //For each slice
 //Find the signal mean and standard deviation
 run("Select All");
 getRawStatistics(area, mean, min, max, stdev);
 if (z==0) {
  //If the first slice, record as the reference signal mean and stdev
  print(rmean, rstdev);
 } else {
  //Otherwise calculate the brightness and scaling correction
  run("Macro...", "code=v="+rmean+"+"+rstdev+"*(v-"+mean+")/"+stdev);
  print(mean, stdev);

Software used:
ImageJ: Image corrections
GIMP: Animated gif file size optimisation

Thursday, 22 January 2015

Tengwar - Transliterating Font

This blog post is about a Tengwar font I designed. It automatically converts text as you type into accurate Elvish script. You can download it for free here.  Just make sure you enable ligatures, contextual alternates and kerning for best results!

While writing his Middle Earth books, JRR Tolkein invented an entire alphabet for the elves called Tengwar. His attention to detail was incredible, Tengwar is a fully functioning writing system. This is the famous Elvish writing seen all through Lord of The Rings and the Hobbit.

Tengwar is an alphabet, not a language, and can be used to write many languages. This is like, for example, Latin and Greek alphabets; the word English word “ring” is normally written in the Latin alphabet but could also be written in the Greek alphabet as “ρινγ”. The two sound the same, it is just a different way of writing the sounds of the word “ring”. The process of transferring a word between two different alphabets is called transliteration.

In Middle Earth, Tengwar is one of the major ways of writing. Many languages were written in Tengwar: two Elvish languages called Sindarin and Quenya, the Black Speech of Mordor (on the One Ring), and the language of men (English). Tolkein gave detailed notes on how to write English in the Tengwar alphabet. In Tengwar “ring” is written:

Writing in Tengwar follows simple rules but quickly gets complicated, so I designed a font that does it automatically! You can download it for free here.  As far as I know this font is unique, all other Tengwar fonts are just collections of symbols you have to manually mix and match.

To use this font you just need to download and install it. Once it is installed, just select it as the font and start typing as normal. The font will automatically transliterate the text you type into accurate Tengwar, based on Tolkein’s rules about writing English in Tengwar.

To make sure the font is working accurately you need to make sure three settings are enabled: kerning, contextual alternates and ligatures. For example, in Microsoft Word you can do this through the advanced font settings:

So how does it work? Basic Tengwar is similar to the Latin alphabet, with two classes of symbols representing the sounds of different consonants and different vowels. At the simplest level, to write the word “ring” the font just selects the four symbols for “r”, “i”, “n” and “g”:

Unlike the Latin alphabet, there are special rules for how vowels are written. Instead of always being a separate letter, if a vowel comes immediately before a consonant it is written as an accent on that consonant. In “ring” the “i” comes immediately before the “n” so the font writes it as an accent on the “n”:

There are some special rules to use for some consonants, depending on where they are in a word. “r” is one of these letters. If it is followed by a vowel then it should have a different symbol, which the font automatically selects:

Finally, some common combinations of consonants that have a single sound (like “th” as in “the”, “ch” as in “church” and “gh” as in “ghost”) have their own single symbol. “ng” is one of these pairs and, again, the font automatically makes this substitution:

And that is how the font automatically writes “ring” in Tengwar. These are not the only rules though, there are also other ones built into the font that involve double vowels, double consonants, the letter “n” preceding another consonant, whether a “y” is used as a vowel or a consonant, whether an “e” is voiced in a word or is silent at the end of a word, etc.

The key feature of my font is that it takes all of these rules into account automatically and lets you simply type away as normal and get an accurate, readable result in Tengwar. You can also just select an existing chunk of text and apply the font to it to transliterate it to Tengwar, but make sure the text is all lower case for best effect. It does make a few very small mistakes, but Tolkein would understand it!

Tengwar is a beautiful and concise alphabet. The way vowels, double letters and letter pairs combine make many words very short and elegant:

The overall flow of a paragraph is also excellent, with the letters falling into self-symmetric curves and alignments.

(This is the first paragraph of Lord of The Rings, converted to Tengwar by just changing the font to my Tengwar Transliteral font.)

If you are interested in playing with Tengwar text for any kind of design please consider downloading the italic and script versions of the font here. These cost a few pounds/dollars/euros.

If you are interested in reading Tengwar, or manually translating it, then the excellent “Tengwar Textbook” Chris McKay is available online for free: Tengwar Textbook.

There are also excellent simple guides on writing in Tengwar (like this one), but why do that when you could just download my font and type your name?

Software used:
Inkscape: Glyph design
Fontforge: Font design

Wednesday, 7 January 2015

Trypanosome Lego

Trypanosomes and Leishmania are the two tropical parasites that I do most of my research on. These cells seem to have a lot of modularity in controlling their shape, and have quite a lot of flexibility in reshuffling where particular structures (made up of many organelles) sit within the cell.

The base of the flagellum, the whip-like tail which the cell uses to swim, is also the site where the cell takes up material from its environment (essentially its mouth) and is linked with the Golgi apparatus (an important organelle in protein processing) and the mitochondrion (the powerhouse of the cell) and links to the mitochondrial DNA. It turns out reducing the level of just one protein in the cell can cause this entire complex structure to shift its position.

Cells are not quite as flexible as Lego, but it is still impressive that a single protein can have such a large effect on the organisation of a cell.