Scientists have come up with a theory for why time flies when you are having fun - and drags when you are bored.

Scans have shown that patterns of activity in the brain change depending on how we focus on a task.

Concentrating on time passing, as we do when bored, will trigger brain activity which will make it seem as though the clock is ticking more slowly.

The research, by the French Laboratory of Neurobiology and Cognition, is published in the magazine Science.

In the study, 12 volunteers watched an image while researchers monitored their brain activity using MRI scans.

Volunteers were given a variety of tasks. In one they were told to concentrate simply on the duration of an image, in another they were asked to focus on the colour, and in a third they were asked to concentrate on both duration and colour.

The results showed that a network of brain regions called the cortico-striatal loop was activated the more subjects paid attention to duration.

Sole attention

It is thought that if the brain is busy focusing on many aspects of a task, then it has to spread its resources thinly, and pays less heed to time passing.

Therefore, time passes without us really noticing it, and seems to go quickly.

However, if the brain is not stimulated in this way, it concentrates its full energies on monitoring the passing of time.

This may make time seem to drag, but in fact it is probably a more accurate perception of reality.

Indeed, the researchers found that the more volunteers concentrated on the duration of the images, the more accurate were their estimates of its duration.

Lead researcher Dr Jennifer Coull told BBC News Online that many of the areas of the brain involved in estimating time were the same that played a key role in controlling movement, and preparing for action.

She said this overlap suggests that the brain may make sense of time as intervals between movements, in much the same way as a musician marks time with his foot, or an athlete anticipates the sound of a starter's pistol.

Professor Tonmoy Sharma, director of the Clinical Neuroscience Research Centre, told BBC News Online the research was "interesting neuroscience".

"It is interesting that the same parts of the brain that are involved in motor function are also involved time perception."

Professor Sharma said there was growing evidence that specific functions were not controlled exclusively by individual areas of the brain, but by complex networks within the organ.