Massachusetts Institute of Technology

Media Lab

Magnetic Field Imaging using CT Techniques



This web page describes a project done for Spring 2008 MAS.836, Sensor Systems for Interactive Environments.

The goal of this project was to build a device to image magnetic fields. The device built here is based on the device described in the paper Magnetic Field Imaging Using CT Technique -- ROI Reconstruction System by Hideo Saito, Ken'ichi Fujita, and Masato Makajima, which can be found in the journal Systems and Computers in Japan, Vol. 24, No. 5, 1993.


The goal of this project was to develop a system capable of imaging static magnetic fields. The device built here is based on the device described in the Saito paper (above). The sensing portion of the devices is a semi-circular wire array, which is translated laterally through the magnetic field to be imaged. The Lorentz Force exerts a force on the charges in each of the wire elements of the sensor, creating a current that is proportional to the strength of the magnetic field, and the velocity of the sensor through the field.

The total current induced along a wire in the sensor is proportional to the line integral through the magnetic field along the wire. In this way, projections through the magnetic field along each wire are obtained via measurements of the current in each wire. In order to use backprojection to obtain an image, projections through the field must be obtained from many angles. To accomplish this, the stage supporting the magnetic target is rotated, and another measurement is taken. By iterating this process, projections through an arbitrarily large number of angles can be taken.

A transimpedance amplifier is used to detect the current induced in the wire sensors. The values are digitized and sent to a computer, where they are run through a noise-reducing algorithm (described below) and backprojected to form an image.



The stand for the device was designed in inkscape, and cut out of 1/8th inch acrylic using the lab's laser cutter. The geared tracks and gear were cut from 1/4th inch acrylic. Shaded regions indicate rastering at half the depth of the part. The basic layout looks like this:

Parts Layout

The above graphic is intended only for demonstration purposes. In order to cut this out using the laser cutter the inkscape source is required, and can be found here.


The primary insight in the Saito paper is the design of the sensing element. According to the paper:

When the CT algorithm is applied, the total sum of the physical variables contained in the circular region of reconstruction covered in common by the projection data should be equal to the total sum of the physical variables contained in the projection data along each direction. [When using a rectangular wire array], however, the projection data are acquired including the magnetic field outside the region of reconstruction.

In order to overcome this limitation, the paper proposes a semi-circular wire array, so that upon rotation of the target, each sensing wire element sums only the field within the circular region of reconstruction (ROI).

The construction of the sensor must be accurate and not deform with vibration, as the sensor must be moved through the magnetic field in order to sense it. Toward these goals, the Modela milling machine was used to mill the sensor out of a copper clad substrate rather than use actual wires. The template shown below was used as input to the Modela (using the CBA software).

Sensor Layout

This image was rendered at 500dpi. The diameter of the semi-circle is 64mm, and the width of each wire is 0.2mm.

Though the sensor here was modeled after the sensor described in the Saito paper, and has a total of 20 wires, only 8 of those wires were used in the device. In the Saito paper, 64 projections (32 wires) were used. To obtain this large number of projections with fewer wires, the authors measured the sensor multiple times per wire, while the sensor was in locations other than directly under the stage. This effectively allows them to take measurements in between the wires on the board. In this way they were able to take projections at intervals smaller than it is possible to fit wires into the semicircular geometry, using a single sided board.

This technique is only used with the long wires towards the end of the semi-circular region. In this region, the length of the wires increases little with each consecutive wire, so using every second or every fourth wire to represent wires in between is a reasonable approximation. Towards the beginning of the semi-circular region, where the length of each consecutive wire changes significantly, there is space to place sufficient return wires so that all the wires may be routed.

Since the system designed here had problems with timing as it is, only 8 wires (16 projections) were used. This has the benefit of not requiring the precise timing needed to measure "in between" wires, but limits the resolution of the reconstruction.


In this design the stage holding the magnetic object is rotated manually for simplicity. There are gradations on the stage that align with an arrow on stand to help the operator make consistent adjustments.

A parallax servo motor is used to drive the sensor back and forth under the stage. The motor is driven at full speed, and runs at approximately 5Hz.

The device, fully assembled, looks like this:

Assembled Device

In this image there are two permanent magnets on the stage.

This is a more detailed picture of the stage, with the sensor visible beneath it.

Target Stage


The amplifiers designed to measure the currents generated in each of the sensing wires consist of operational amplifiers in a simple transimpedance amplifier configuration. The value of the resistor used for this design was 1.5 K-Ohms. The amplifiers used were Linear Technologies LT1179s, which had a low current noise that was good for this purpose, but had a fairly large voltage bias. An individual amplifier was designed for each wire, as the current is too small to be measured if it is passed un-amplified through an analog multiplexer.

The data from the amplifiers were multiplexed via a CD4051 into an Analog Devices AD7862 ADC. The ADC was controlled from, and read into, the parallel port of a standard PC, running Fedora Linux through HEF4050B hex buffers.

The servo motor was controlled using a parallax serial servo motor controller, via the serial port of the same PC. An Analog Devices ADM-203 RS232 Level Converter was used to get CMOS signal voltages for the servo motor controller.

The electronics design for this devices was straightforward. The only caveats were related to reducing noise. This amounted to applying good shielding to the signal wires between the sensor and the amplifiers (seen in the picture above, and liberal use of capacitors to decouple the circuit from the power supply of the prototyping board used.

The following is a pictorial overview of the electronics.

Electronics Overview

This is a detail shot of the transimpedance amplifier stage.

Transimpedance Amplifier


The software used with this device consists of two parts. There is C code that runs in real time, operates the servo motor to control the position of the sensor, and reads the values back into the computer using the analog to digital converter via the parallel port. The C code uses the Parapin library to send data in and out of the parallel port. The runct.c program is provided here , under the GPL V2.0.

The analysis portion of the software is written in the form of a matlab .m file. This file contains code to de-noise the data captured from the sensor, and run an inverse radon transform, which is implemented by using filtered backprojection, to generate an image of the magnetic field. That code (reconstruct.m) is posted here. This code is also provided under the GPL V2.0.

C Code Analysis

The C code is responsible for controlling every aspect of the operation of the device, and reading the data that are generated into the PC for storage for later analysis.

The analog to digital converter is connected to the parallel port of the PC. When new values are ready on the ADC, they are read into the parallel port. The parallel port is also connected to the CS and RD pins of the ADC, in order to clock out the values read from the A and B ports of the ADC. The serial port RTS pin is also connected to the ADC's CONVST pin, and is used to trigger new values to be converted by the ADC.

The serial port is used to control the servo motor through the servo motor controller board. A simple command syntax, outlined in the servo motor controller board manual, directs the motor to a specific position. The C code drives the motor forward and backward, at least once for each wire for each view. The program then asks the user to turn the stage a fixed amount in order to measure the next view. The code can be configured to collect redundant views to help reduce noise in the final result.

The C code is also responsible for selecting the correct sensor wire to be measured using three pins of the parallel port, which are fed into the analog multiplexer.

The program is designed to continuously collect data from the ADC for the entire stroke of the sensor. Since Linux is not a real-time operating system, the sample rate obtained is not exact, and the sample spacing is not always the same. However, an average sample rate of approximately 60kHz is achieved.

Because of the instability of the sample clock, each sample is written into a file along with an accurate time stamp indicating when the sample was taken. Time stamps are obtained using the rdtsc assembly instruction.

The program, as provided, is configured to take three redundant strokes for each wire/view combination. A separate data output file is written for each stroke, wire, and view. In this way, if 10 views are requested, using 8 sensor wires, with 3 redundant measurements, 240 data files will be produced. Each data file will contain a series of voltage measurements and their corresponding time stamps. Data files are human-readable ascii text files.

Before each view is taken, the program also records offset data. As discussed in the Electronics section, there is a voltage bias in the LT1179 op-amp used in the device. When configured as a transimpedance amplifier, the voltage bias produces an offset in the output of the amplifier. Another source of output offset is the strength of the electric field incident on the sensor wire. These sources combine to produce an offset that fluctuates (from empirical observation). In order to calibrate this offset out of the measurements, the value of the offset must be recorded. Because the head does not have to move for the offset to be recorded, a large number (1000) measurements are taken and then averaged. The result is recorded to an output data file.

One offset output file will be recorded for each view recorded. The offset file will have one entry for each sensor wire used.

M Code Analysis

The matlab script code is responsible for reconstructing images from the data collected by the C code. There are three basic steps to reconstructing an image from the data. The first is taking the large number of recorded measurements and reducing them to a single value for each wire for each view, in such a way as to reduce the noise in the signal. The data is recorded as 360 degrees of parallel projections through half of the ROI to be imaged. The second logical step is to reorganize the data into 180 degrees of parallel projections through the entire ROI. The final step is to perform a filtered backprojection to obtain an image.

The trickiest aspect of the design presented here is determining which measurements correspond to the time when the sensing head is aligned with the stage containing the permanent magnets generating the field to be measured. Using a measurement from another point in time will have the effect of taking the wrong projection through the magnetic field. This will lead to inconsistent data for backprojection, which will in turn create artifacts in the final images produced.

Furthermore, the alignment of the projections in time cannot be relative. The projections must be absolutely aligned to the center of rotation of the stage. If the projections are not aligned properly, it will have the effect of rotating the magnetic field around a point outside the center of the reconstruction ROI, which will produce a circular artifact in the center of the final images.

The de-noising algorithm used in the matlab script is to perform a linear fit to the collected data. Because the data are not captured with a predictable sample spacing, traditional filtering is more difficult. A window is applied to the collected data sequence to isolate data points that were collected in a time window centered about the moment that the center of the sensor crosses the center of the stage. When multiple passes were taken, the windowed data points from each of the passes are considered together. These points are then treated as a cloud of X-Y points, to which a linear fit is obtained.

The fit function is then evaluated at the time when the center of the sensor crosses the center of the stage. The evaluated value is used as the value of the data point for the wire and view.

In order to generate 180 degrees of full view (called views here for short) from 360 degrees of half-views, the projections are folded so that the first half of the view is composed of to the projections from one half-view, and the second half of the view is composed of projections from a half-view 180 degrees away, with the order of the projection reversed.

The actual backprojection is performed using the matlab function iradon. A shape-preserving piecewise cubic interpolation is used in the backprojection to obtain a smooth looking result. Speed is not an issue here, due to the small number of projections. Also, the Ram-Lak filter of filtered backprojection is multiplied by a Hamming window, which gives a good tradeoff between resolution and ripple seen in the result.


Images were obtained for three datasets using the device and the software described. An example of the raw data for a series of sensor movements is shown below:

Raw Data

This plot shows forward and backward strokes for two orientations of the stage, while the stage contains two circular permanent magnets placed with opposite polarity on either side of the stage.

The forward and backward movement of the head is visible in the positive and negative spikes seen on the plot. Also visible are gaps in the measurements caused by process preemption on the computer. Notably, these occur at around 1 second and again at around 3 seconds. An approximate 0.4 volt bias is also apparent upon inspection of the graph.

This first image is created with 10 half-views, using 8 wires (or projections). The target on the stage was a configuration of two permanent disk magnets placed with opposite polarity on opposite sides of the stage. It is apparent from the image that the placement of the magnets is not exact (they are somewhat above center). The image has an approximate resolution of 9mm.

Results from two magnet configuration with 10 half-views

Note that although the source image is only 64 pixels, it is being interpolated to a large size by your browser so that it can be seen. Much of the area shown in the image corresponds to a region outside the ROI for which data were taken.

This next image is created with 60 half-views, using the same configuration of the target. It has the same resolution as the 10 half-view image.

Results from two magnet configuration with 60 half-views

It is somewhat helpful to see this image in false color. Here is the same image using matlab's cool color scheme:

Results from two magnet configuration with 60 half-views in false color

The final image shown here was also created with 60 half-views. The target this time is three stacks of disk magnets. The configuration consists of one stack of a single disk magnet placed diametrically opposite a stack of two disk magnets with the same polarity. A third singleton disk magnet is placed at 90 degrees from the first two stacks in the opposite polarity.

Results from three magnet configuration with 60 half-views

This image shows signs of data inconsistency. Specifically, the image appears to suffer from a circular artifact caused by measuring projections at the wrong time (when the sensor head is in the wrong position). However, for this set of data, the artifact could not be removed by changing the timing of the measurement. There may be additional inconsistencies in the data that are unaccounted for.

This project demonstrates a low cost method of imaging magnetic fields. Improvements to the timing system used, such as employing a dedicated microcontroller to run the system and read the results, or using a realtime operating system on a PC, would improve the results obtained here. It should also be possible to build a motorized stage (rather than the manual version used now) in order to increase the speed of the measurement. Finally, if the stage were capable of moving vertically as well as rotating, it would be possible to image a volume of the magnetic field, rather than just a slice, as is presented here.

Videos of the project will be posted soon.


Thanks to Mark Feldmeier, the TA for MAS.836 for Spring 2008. Thanks also to Tom Baran and Adam Wilson, for answers to de-noising and op-amp questions, respectively.

Last updated on June 13, 2008.
Please send comments to mhirsch [at] media [dot] mit [dot] edu.
Style by Tom Baran of DSPG.

Valid HTML 4.01 Transitional