Linux Fu: C On Jupyter

If you are a Pythonista or a data scientist, you’ve probably used Jupyter. If you haven’t, it is an interesting way to work with Python by placing it in a Markdown document in a web browser. Part spreadsheet, part web page, part Python program, you create notebooks that can contain data, programs, graphics, and widgets. You can run it locally and attach to it via a local port with a browser or, of course, run it in the cloud if you like. But you don’t have to use Python.

You can, however, use things with Jupyter other than Python with varying degrees of success. If you are brave enough, you can use C. And if you look at this list, you’ll see you can use things ranging from Javascript, APL, Fortran, Bash, Rust, Smalltalk, and even MicroPython.

Continue reading “Linux Fu: C On Jupyter”

A Crash Course On How MRI Machines Work

Of all the high-tech medical gadgets we read about often, the Magnetic Resonance Imaging (MRI) machine is possibly the most mysterious of all. The ability to peer inside a living body, in a minimally invasive manner whilst differentiating tissue types, in near real-time was the stuff of science fiction not too many years ago. Now it’s commonplace. But how does the machine actually work? Real Engineering on YouTube presents the Insane Engineering of MRI Machines to help us along this learning curve, at least in a little way.

Both types of gradient coil are stacked around the subject inside the main field coil

The basic principle of operation is to align the spin ‘axis’ of all the subject’s hydrogen nuclei using an enormous magnetic field produced by a liquid-helium-cooled superconducting electromagnet. The spins are then perturbed with a carefully tuned radio frequency pulse delivered via a large drive coil.

After a short time, the spins revert back to align with the magnetic field, remitting a radio pulse at the same frequency. Every single hydrogen nucleus (just a proton!) responds at roughly the same time, with the combined signal being detected by the receive coil (often the same physical coil as the driver.)

Time taken for the perturbed spin to return to magnetic alignment

There are two main issues to solve. Obviously, the whole body section is ‘transmitting’ this radio signal all in one big pulse, so how do you identify the different areas of 3D space (i.e. the different body structures) and how do you differentiate (referred to as contrast) different tissue types, such as determine if something is bone or fat?

By looking at the decay envelope of the return pulse, two separate measures with different periods can be determined; T1, the spin relaxation period, and T2, the total spin relaxation period. The first one is a measure of how long it takes the spin to realign, and the second measures the total period needed for all the individual interactions between different atoms in the subject to settle down. The values of T1 and T2 are programmed into the machine to adjust the pulse rate and observation time to favor the detection of one or the other effect, effectively selecting the type of tissue to be resolved.

Time taken for the relative phasing inside a tissue locality to settle down to the same average spin alignment

The second issue is more complex. Spatial resolution is achieved by first selecting a plane to virtually slice the body into a 2D image. Because the frequency of the RF pulse needed to knock the proton spin out of alignment is dependent upon the magnetic field strength, overlaying a second magnetic field via a gradient coil allows the local magnetic field to be tuned along the axis of the machine and with a corresponding tweak to the RF frequency an entire body slice can be selected.

All RF emissions from the subject emanate from just the selected slice reducing the 3D resolution problem to a 2D problem. Finally, a similar trick is applied orthogonally, with another set of gradient coils that adjust the relative phase of the spins of stripes of atoms through the slice. This enables the use of a 2D inverse Fourier transform of multiple phase and frequency combinations to image the slice from every angle, and a 2D image of the subject can then be reconstructed and sent to the display computer for the operator to observe.

See? It’s easy.

We cover MRI technology from time to time, here’s a little update on state-of-the-art resolution for those wishing the dig a little deeper.

Continue reading “A Crash Course On How MRI Machines Work”

OScope Advert From 1987 Rocks It

We can’t remember ever seeing a late-night TV ad for oscilloscopes before but, for some reason, Tektronix did produce a video ad in 1987. You can see it below and enjoy the glorious music and video production standards of the 1980s.

We assume this was made to show at some trade show or the like. Even if there was a Home Shopping Network in 1987, we doubt many of these would have been sold despite the assertion they were “low cost” — clearly a relative term in this case.

You’ve got to wonder if the narrator understood what he was saying or if he was just reading from a script. Pretty impressive either way. We loved these old scopes, although we also like having very capable scopes that don’t strain our backs to lift.

On the bright side, these scopes today are pretty affordable on the used market if you can find one that doesn’t need a repair with an exotic part. For example, we found several 2221s or 2221As for under $200 without looking hard. The shipping, of course, could potentially almost double the price.

While you can get a modern scope for $200, it probably isn’t the same quality as a Tektronix. Then again, the new scope won’t have CRTs and exotic Tektronix parts to wear out, either. Picking a scope is a pretty personal affair, though, so one person’s great scope might be another person’s piece of junk.

Continue reading “OScope Advert From 1987 Rocks It”