Category: Technology

Programming, gadgets (reviews thereof) and computers

Medical ultrasound imaging

Scan1Alert readers will remember that I am in the process of becoming a father, and that the occasion of this announcement was the "dating scan" (Codename Beetle). In the UK, at least, this is an ultrasound scan targeted to take place at about 12 weeks pregnancy with a view to getting a more precise estimate of birth date from the size of the fetus, measured from “crown” to “rump”. Alongside this a nuchal fold measurement may be made to help test for Down’s Syndrome, it turns out this requires a cooperative fetus willing to assume just the right posture, Beetle wasn’t!

From a scientific point of view this is all really interesting: you can see inside people! In this instance, my wife.

The inside of a human is largely squidgy but different parts have different squidginess, in particular there is a nice contrast between the muscular wall of the womb and the liquid contents and again between the liquid contents of the womb and the fetus. Ultrasound is reflected when there are interfaces between things of different squidginess. There’s a direct analogy between this squidginess and the “impedance” of electrical components in things like hifi equipment, and the transmission of sound waves and the transmission of radio waves.

The scan starts off with the operator squirting generous quantities of lubricant onto the wife’s belly (in a hospital environment this gives me flashbacks to the Unexpected Prostate Examination Incident). The lubricant is to give good “impedance matching” between the ultrasound scanner and the swollen belly of the wife, without it the sound bouncing off the skin surface would be all you heard.

To build up an ultrasound image we listen for echoes. The ultrasound probe lets out a squeak and waits for echoes, the time taken for the echo to arrive tells you how far away the thing that created the echo. This is really obvious in the earliest ultrasound devices which worked in what is know as “A-mode”: sending out a single beam of sound in one direction and recording the sound that came back as a function of time. Typical data* shown below.

A_scan

The echo marked A represents a structure closer to the surface than the echo marked B.

You can build up a proper image by scanning your beam of sound backwards and forwards to map out a fan, this is known as “B-mode” and is the type of imaging you will be most familiar  with, the image at the top of the page is an example. It shows a vertical fan-shaped slice into the body, with features at the bottom of the scan further from the surface than those at the top.

In the old days moving the beam backwards and forwards was a mechanical process but modern scanners do it electronically with no moving parts. This is done with a “phased array” similar to those used in radar systems; a line of transmitters is fed signals with different phases (the sinusoidal sound waves are offset in time by different amounts) the result of this is a sound beam that can be steered backwards and forwards without physically moving any parts.

Kamryn Thinking Cropped_mediumThese days you can even get “4D” scans done. These use a square (2D) array of emitters to scan rapidly over an area, getting the third dimensions from the echo time and a fourth (time) dimension by being able to repeat the process rapidly. These scans are converted to a moving 3D surface (or “baby”) by thresholding the 3D data set and using computer graphics techniques to produce nice graphics. I must admit I find these images a bit creepy (the one on the right is not Beetle). Given my experience of image analysis, extracting a neat surface from the noisy data, in real time, is pretty tricky.

   

Voluson 730 Pro BT03If I’d been paying attention I could probably have read the name of the particular ultrasound scanner used on my wife, but I had other things on my mind. As it was I could identify it because there’s an interesting looking coding on the sonograph (RAB-4-8L/0B) which turns out to be the serial number of a detector for the General Electric Voluson 730 devices. A quick bit of googling reveals a convincing looking image of the scanner, they cost something in the range £20k-£40k.

Ultrasound imaging utilises sound in the frequency range 2-18MHz although for the probe used for Mrs S’s scan the range is 4-8MHz wavelengths for such waves are 0.2-0.3mm which will be the maximum achievable spatial resolution. The lowest of these ultrasound frequencies is 100 times higher than the upper limit of human hearing at 20kHz, and 10 times higher than those used by bats and dolphins.

The velocity of sound waves in water is 1540m/s, for the purposes of this calculation humans are approximately water, the raster rate (speed at which the sound beam goes backwards and forwards) appears to have been 18Hz or once every 1/18th of a second). Given the speed of sound in Mrs S, we could actually image many metres into her – if required. This suggests that the speed sound is not a limiting factor in how fast we can do scans: the noise in the signal is the limiting factor. That’s to say the strength of the echoes we get back is rather weak and looking at the images they are mixed with a lot of noise.

Ultrasound machines are really rather high technology bits of kit, containing lots of interesting physics. I must admit having read up a bit – I want one to play with!

*”Typical data”, in scientific terms means “I’m going to claim this is typical but actually this is the best we collected”.

Book review: The Lunar Men by Jenny Uglow

LunarMenI read “The Lunar Men” by Jenny Uglow a few years ago, this was in a time before blogging so I’d forgotten the contents. I’ve recently reread it, my interest reawakened by my recent reading of the King-Hele biography of Erasmus Darwin. Darwin was a key member of the group of industrialists, inventors, doctors and experimenters based in the West Midlands which finally became the Lunar Society.

Uglow lists the principal Lunar men as John Whitehurst (1713-1788), Matthew Boulton (1728-1809), Josiah Wedgewood (1730-1795), Erasmus Darwin (1731-1802), Joseph Priestley (1733-1804), William Small (1734-1775), James Keir (1735-1820), James Watt (1736-1819), William Withering (1741-1799), Richard Lovell Edgeworth (1744-1817), Thomas Day (1748-1789), Samuel Galton (1753-1789).

It’s notable how many of the Lunar Men were Scots, in the mid-18th century England had two universities, Scotland had five.

It’s not until 1775 some 15 or so years after the core group had originally met that the Lunar Society is formalised. At the time arranging events to coincide with the full moon was not uncommon. Alongside the Royal Society there were numerous other local “Philosophical Societies” although I’m not clear of the details of these other groups it seems there was nothing exceptional about the Lunar Society in terms of the mix of people but they were rather exceptional people. They were proactive in seeking out new members, for example Withering was recruited on the death of William Small. As gradually the founding members died, the group dissolved in 1813.

Matthew Boulton, owner with John Fothergill of the Soho Manufactory, started as a maker of “toys” (which in this case means any number of small metal items) and non-ceramic ornaments but he collaborated with James Watt to make stream engines. He was later to set up the Soho Mint, which used patented pressing equipment to make high quality coins and medals in bulk.

James Watt made his first breakthrough in the design of steam engines in 1765 but it wasn’t until 1775 that they received a 25 year extension of the key patent and in 1776 they install their first engine in Cornwall. The revenue from these engines came in the form of a fee related to the cost savings on coal which the more efficient design of the Watt engine provided compared to the Newcomen atmospheric engines, introduced in the early 1700s. The protection and creation of patents was an important part of the Watt and Boulton business plan, they even supported Richard Arkwright, with whom they did not see eye to eye, in the protection of his patents for the cotton processing equipment at the heart of his factory. Patents are one route to deriving income from intellectual property, the newly formed Society of Arts offered another route: prizes, or premiums, for named topics which centred around manufacture.

On the face of it the presence of Josiah Wedgewood, a potter, in the group seems odd but reading the book it becomes obvious just how high-tech an industry the potteries were. Clay is not simply dug up from any old patch of ground and flung on a wheel – the correct raw materials must be selected and once this is done they must be processed properly before they can be formed into shapes. Even then it isn’t over: the process of applying glazes and firing the ceramics is far from straightforward. The ceramic industry was one of the high tech industries of its time, an 18th century Silicon Valley.

Boulton and Wedgewood were both in the business of mass producing desirable consumer goods and marketing them to the middle classes. They recruited excellent artists to produce designs, often based on classical themes and objects. Initially selling them to the very wealthy but with a view to mass production and the use of their aristocratic clients as promotional material. For Wedgwood the culmination of this was the creation of replicas of the Portland Vase.

Alongside the factories growing up in the Midlands came the canals with which the Lunar Men were heavily involved. The canals brought freight costs down from 10d per mile to 1.5d per mile. They started to replace the turnpike roads and river navigations, both enabled by acts of parliament which gave rights to maintain roads and rivers to corporation – along with the right to raise tolls. This previous incarnation of transport seems to have been initiated around 1650. By the mid-19th century a full-scale rail network was in place, replacing in turn the canals. The canals meant that raw materials could be moved around more cheaply, and that expensive (and delicate) manufactured goods could be shipped out.

The Lunar Men had a range of political views, although Uglow comments that scientific experimentation was more associated with Whigs than Tories. The manufacturers, Boulton and Wedgwood, were notably less radical most likely with an eye to maintaining the political support required to keep their businesses running, although Boulton in particular was pretty progressive in the treatment of his workforce. Many of the group were supportive of the French Revolution, American independence and the abolition of slavery. Priestley was a Dissenting preacher, and when the backlash against all manner of radical thought came his house was one of 30 or so properties singled out for attack during the 1791 Birmingham Riots, Withering’s house was also attacked.

The scientific context is quite different compared to today: public demonstrations of cutting edge science including electrical demonstrations were common and a group of educated gentlemen could make valuable contributions to science as amateurs doing the work in their spare time. Withering and Darwin fought over the discovery of digitalis as a well-defined medical material. Priestley was probably the most impactful “scientist” of the group being one of several who played a key role in the discovery of oxygen and it’s properties. Darwin was largely a “scientist” who suffered from having ideas before his time particularly with regard to evolution but also his ideas on meteorology were in advance of his time. Others in the group such as Watt and Keir were clearly entirely competent in scientific areas.

Strangely I found the King-Hele biography of Erasmus Darwin pretty much as informative on the Lunar men as this book and more readable – perhaps because it’s more difficult to write a compelling narrative around a, sometimes loose collective, compared to an individual. I am now intrigued about the evolution of factories in the 18th century and, more disturbingly, 18th century intellectual property rights.

Photovoltaic solar power – one year on

This time last year we had a photovoltaic solar power system installed, a few years after we had a thermal solar system installed. This post is an update on how we’ve got on with the photovoltaic solar system. This is facilitated by my weekly collection of electric, solar and gas meter readings – I suspect this data collection is a bit of a minority sport. A couple of months ago the company that the installed the system did offer me a fancy monitoring system… which cost about £1500!

As my earlier blog post highlights the calculated output for our system, given the latitude and orientation of our roof and the peak capacity of our system is 1393kwh per year. The first meter reading was on 28th August 2010, as of 25th August 2011 the reading is 1362.9kwh. So the measured output is 98.5% of the predicted output – not bad at all! Our import from the grid for the same period was 1896.2kwh compared with an annual consumption of 2397.5kwh in the previous year. So a 20% reduction in consumption and generation of 57% of our pre-installation level. The difference here is because our peak generation (mid-late morning) does not match our peak usage (early evening), since we can’t store any electricity the excess goes onto the grid. These figures are illustrated graphically below:

consumption

We receive the feed-in tariff and payments for exported electricity from our supplier, npower. This seems to be a small scale operation since to set this up you interact with named individuals who don’t change! So far we’ve received two cheques from them for £105.29 for the period 16/9/10-04/03/11 and £174.38 for the period 4/3/11-21/5/11. I should probably go prod them about whether they want another meter reading.

We can dig a little deeper into the data, below I show our monthly electricity consumption (red/green lines) from the grid for the last few years along with the last year of solar generation (the blue line).

monthlyconsumptionOur electricity consumption has been fairly constant through the year with a hint of an increase during the deep winter months due to the shortening days and an increased use of electric lighting. Since about March this year our electricity consumption has been significantly reduced compared to previous years, offset by our solar generation. This pattern wasn’t maintained in the September / October / November last year – I think because I was at home (using electricity) for an extended period following an operation.

The amount of solar generation varies smoothly through the winter months but seems to plateau during the summer. We did have a week of zero generation when the panels were covered in snow. I suspect in principle that the average power generation will vary sinusoidally through the year, since the variation in day length is sinusoidal, but that this can disturbed by “weather”, in particular the figure for May includes the very sunny Easter period without this boost the curve would have varied smoothly through the summer rather than plateauing.

In summary: we’ve generated almost exactly the amount of solar electricity we anticipated which amounts to nearly 60% of our annual consumption of electricity.

Living in code

Eric Schmidt, chairman of Google is in the news with his comments at the MacTaggart Lecture at the Edinburgh International Television Festival. The headline is a general criticism of the UK education system but what he actually said was more focussed on technology and in particular IT education: bemoaning the fact that computer science was not compulsory and what of it that there was about the use of software packages rather than how to code.

I was born in 1970, and learnt to program sometime in the early 80s. I can’t remember exactly where but I suspect it was in part at the after-school computer club my school ran. A clear memory I have is of an odd man who’d brought in a TRS-80 explaining that a FOR-NEXT loop was an instruction for a computer to “go look up its bottom” – this was at a time before CRB checks. My first computer was a Commodore VIC-20, Clive Sinclair having failed to deliver a ZX81 and the BBC Micros being rather more expensive proposition than my parents were willing to afford.

Many children of the early 80s cut their teeth programming by typing in programs from computer magazines; a tedious exercise which trained you in accurate transcription and debugging. Even at that time the focus of Computer Studies lessons was on using applications rather than teaching us to program although I do remember watching the BBC programmes on programming which went alongside the BBC Micro. As I have mentioned before, programming is in my blood – both my parents were programmers in the 60s.

About 10 years ago I was teaching programming to undergraduate physicists, from a class of 50 only 2 had any previous programming experience. The same is true in my workplace, a research lab where only a small minority of us can code.

Knowing how to code gives you a different mindset when approaching computer systems. Recently I have been experimenting with my company reports database. The reports are stored as PDF files; I was told the text inside them was not accessible – now to me that sounds like a challenge! After a bit of hacking I’d worked out how to extract the full text of reports out of the PDF files but then code that once worked stopped working. This puzzled me, so I checked the text that my program was pulling from the database and instead of being a PDF file, it was a message saying “Please don’t do that"!

At the moment I’m writing a program that takes an address list file, checks to see if the addressees have a mobile phone number and if they do uploads it to an SMS service, spitting out into a separate file those that do not have a mobile phone number. To me this is a problem that has an obvious programming solution, for the people who generate the address list it’s a bit like black magic.

These days we are surrounding by technology bearing code, just about every piece of electrical equipment in my house has code in it, but it seems that ever fewer of us have been inducted into the magic of writing our own code. These days there’s just so much more fun to be had from programming: there are endless online data sources and our phones and computers have so many programmable facilities built into them.

At what age can I teach my child Python?

Lead mining in the Yorkshire Dales

Bunting level: building, level entrance and hush

Bunting level: building, level entrance and hush

On a recent trip to the Yorkshire Dales we came across the remnants of lead mining; as with many things in the field these are blank discoveries with no indication of what they mean at the site. A very long time ago I did an OA level in geology, and I seem to have inherited an interest in industrial archaeology, so I resolved to find out more…

The majority of the mine workings we saw were in Gunnerside Gill, which extends north from Swaledale shown on the map below. On the ground we found rock strewn gullies and heaps of gravel, still devoid of vegetation. There were also ruined mine buildings, the occasional opening into the hillside and the odd bit of rusting ironwork. The most distinctive elements of the remains are the “bouse teams”, these are sets of bunkers – just the dividing walls remain – which were used to store the ore (or bouse). Quite a few of the stone surfaces are covered in a reddish deposit; elsewhere this has been identified as a lichen, but I believe it’s lead oxide. The workings are named by the “level” or horizontal tunnel which they served, the photos here are taken around the Bunting (or Bunton) level.

 

Lead mining, bouse teams

Lead mining: bouse teams at Bunting Level

Further down the Gill, closer to Gunnerside, are the Sir Francis Level workings; although these are less extensive at ground level, they turn out to have quite fantastic remains underground. Intrepid cavers have been down and taken some impressive photos, and you can read more about the Sir Francis Level workings in this report , here and here too. These were the most recent workings in Gunnerside Gill and were in operation from 1864 until 1891.

Lead mining has been carried out in the Yorkshire Dales since Roman times, the workings at Gunnerside Gill started in the 16th century but the majority of the visible surface remains are from the 19th century. The Bunting (or Bunton) level where the photos were taken was opened in 1802 and closed in 1898.

Lead mining: entrance to Bunting level

Lead mining: entrance to Bunting level

The Yorkshire Dales are substantially formed from limestone and gritstone outcrops laid down in the Carboniferous Period some 320 million years ago1. The lead ore occurs in veins which were deposited hydrothermally: hot pressurised liquids containing a range of minerals were forced through cracks in the native rock and deposited what they carried when the pressure and/or temperature dropped. The minerals are not conveniently deposited by type but mixed together. The veins are quite narrow – typically only a metre wide – but stretch deep underground.

This is reflected in the manner in which they are mined: initially vertical shafts were mined down to follow the veins. Later horizontal “levels” were mined to meet up with these vertical shafts which made the extraction of both ore and water easier – water will drain out of a level but puddle in the bottom of a shaft. In addition to this type of mining “hushing” was also used: this involves sluicing large quantities of water down the line of the vein to erode out the rock. This process was used in the Gunnerside Gill area from the 1780s to 1820s, and is what has left a large part of the surface remains. These are marked on the map as “hushes”. The extent of the workings can be seen quite clearly in Google Earth images (here).

The particular mineral in which the lead occurred is galena (lead sulphide), it is relatively dense and this property was used to separate out the galena from other minerals using a process akin to panning for gold. The ore containing rock is broken up into pieces and as far as possible the galena rich chunks are picked out and chipped off using hammers – this is known as dressing. This ore is then further broken up into smaller pieces. Earlier, this would have been done manually but later it was done using a water-powered mills, and still later it was done by steam-powered machines. These smaller pieces of ore are then buddled in troughs or hotching tubs – basically this simply means add water then shake, this separates out the material by density.

Lead mining, mill culvert

Lead mining: mill culvert at Bunting Level

Stonebreaker, with Sharon in background

Stonebreaker above Bunting Level with Sharon in background

Once reasonably well-separated ore is obtained it is converted to metal in two chemical steps. First the ore is roasted to drive off the sulphur and convert it to lead oxide, then the oxide is smelted with carbon which removes the oxygen from the lead to produce the metal. There were smelting mills in Gunnerside Gill but ore was also transported underground to the next valley and smelted in the Old Gang Smelting Mills. We didn’t visit these but they had flues extending up the hillside a distance of hundreds of metres. The reason for this was two-fold: firstly, the gases driven off the ore during smelting were pretty noxious and secondly, the long flue allows soot to condense back out as it cools and this soot can be contain high concentrations of minerals.

Life for the miners sounds pretty grim; they were expected to work for 6 hours a day underground and the mine workings were often inaccessible without accommodation so their days may well have started with an hour or so walking simply to get to work. The Swaledale Museum, in Reeth, as well has having a great deal of other information on lead mining has some mining company rules, dated 1872. One of them states: “Children aged 12-16years only allowed to work 54 hours per week, or 10 hours per day.”

Footnotes

1. See p13-22 of this report by the North Yorkshire Geodiversity Partnership for more geology.

2. Related is this report on the Peak District Lead Mining Industry

3. English Heritage scheduled monument report