Magnetic field homogeneity using a permanent magnet approach

I’ve started writing this blog with some experiments already done. I will usually post what I’m going to do from now on, but it seems interesting to show you the results of my first attempt with permanent magnets.

It’s very tempting to have a powerless magnetic field rather than several kgs of copper dissipating heat. I knew I was trying to achieve a very unlikely achievement, but I wanted to give it a try since I already had the magnets from another project and a nice 3D printer to get the structure. A decent homogeneous magnetic field is possible on paper, but one of the main problems is the way the manufacturers magnetize the magnets. The homogeneity along the surface is not quite good, and the dispersion among the magnets is even worse.

Here I show the main idea designed and rendered using Solidworks. It consists of 26 magnets with the resultant magnetic field aligned with the X-Y plane. Each bar magnet measures 100x10x3mm, and the internal diameter of the structure, 80mm:

Bar magnet structure to get a central homogeneous magnetic field
Bar magnet circular array to get a high central homogeneous magnetic field

Here the 3D magnetic simulation, showing a slide in the YZ plane:

Magnetic field simulation in the central plane
Magnetic field simulation in the central plane

The central magnetic field is quite high (about 64mT) since I chose the highest grade of neodymium material for this simulation. In practice, I measured a much lower strength, who knows the characteristics of my magnets which I had there for a long time with no specs available.

Well, simulations are pretty nice, but as already said, in the real world each magnet is different. That’s why I made a map of each magnet to select the most homogeneous ones. To do so, I attached a 3D digital hall effect sensor (TLV493D) to the head of my 3D printer. Then, using a custom software done with C# and Visual Studio, I was able to control the 3D printer through USB and sweep the sensor around the magnet. In this way I was able to get the 3D magnetic field vectors at each point. All the magnets were labeled, and the acquired data saved in a CSV file to post-process using Matlab. Here the results:

Magnetic field measurement of 44 neodymium bar magnets
Measured magnetic field of all the 44 magnets I had available

As you can see on the right side of the plot, there are at least 2 magnets that are quite inhomogeneous. From all these 44 magnets, I applied an algorithm to select the 26 most homogeneous and similar ones. I didn’t spend a lot of effort here, because I couldn’t do a miracle by just having 44 magnets available. After the selection, I processed again the data to get this plot:

Magnetic field measurement of the 26 most homogeneous ones

Having into account the previous magnetic field simulation, I decided to arrange the magnets within the 3D printed structure so that the strongest magnet was placed at the top/bottom and decreasing in strength in the measure I was getting closer to the center. Once assembled, I used the same previous C# software to sweep the hall effect sensor inside the structure and measure the real magnetic field. To save some time, instead of sweeping in the whole inner volume I just swept along 2 planes, here the XY plane:

XY Magnetic field inside the permanent magnet structure

The magnetic hall sensor gives 12 bit of data and a usable full scale of ±130mT. I say “usable” because if you make the math it doesn’t fit with the resolution, which is 98μT. Well, it’s a good sensor, but not good enough for our purpose. That’s why each point was highly averaged with 256 samples per point. If we suppose we have a gaussian noise, then we get 1 extra bit of resolution per x4 acquisitions, which leaves us with 12+4=16 bits of effective resolution, or what’s the same, 6.1μT. Now we are OK.

The plot data took about 1h30 to be acquired. Unfortunately, looking at the vertical axis (the magnetic strength), it’s quite obvious there would be a lot of effort to make this magnetic field homogeneous enough. Just to make me an idea, I filtered the data to know which effective volume of homogeneity we could get in the most homogeneous part. The central spot is 30.7mT, and only the data within 400ppm (12.3μT) is shown:

Central homogeneity for the permanent magnet structure - 400ppm
Central homogeneity for the permanent magnet structure – 400ppm

About 5x2mm of quite low homogeneous field sounds horrible, but getting a resonance of 30.7mT*42MHz/T=1.3MHz, I guess that using a small diameter glass pipe filled with water and a small diameter coil (which produces strong magnetic fields) we might have been able to measure some signal. But hey, I want much more volume! After all, I’m trying to generate an image… 😛 My conclusion, despite there are MRIs in the market which use a permanent magnet approach, is that I don’t want to waste more time with this knowing that I can get a high homogeneous field using coils and spending some time in a good design.

Stay tuned!

RF Coils

The RF coils design is also one of the main essential parts to get a decent result. By means of these coils we will excite the spins, as well as read the signal back.

First of all clarify the term “RF”, since it might cause confusion. We are not dealing with electromagnetism or radio-frequency here, just with the same kind of magnetism found in a magnet. This term is just used for historical reasons.

We already saw the main magnetic field B0 homogeneity is crucial to get some signal, but the magnetic field generated by the RF coils must also be as homogeneous as possible (not in the parts-per-million range though). The reason has to do with the flip angle, as explained below.

RF magnetic field homogeneity

As you probably know, the spins will flip its angle depending on the strength of the applied magnetic field as well as the excitation time. For example, if your spins flip 90 degrees by applying a magnetic field of B µT for t ms, you will get the same 90 degrees flip angle by applying a magnetic field of 2·B for t/2.

The whole sample is exposed to the generated magnetic field for the same amount of time, so I guess you see the problem: if for the same time t some volume in our sample is exposed to twice the magnetic field strength, instead of flipping the spins 90º they will flip 180º, and we will receive no signal at all from that volume.

Clinical MRI usually uses birdcage coils. That’s because, at 1.5T and 64MHz, the LC resonant frequency is so high that the inductance must be quite low. As low as the inductance of a single loop of wire. And it’s not helping that the geometry has to be very large to fit a human being inside, since the higher the loop area, the higher the inductance. Sometimes, the single loop is even split into smaller loops by adding capacitors in series.

Fortunately for us, we are not working at such high frequencies nor volumes. At 5mT and a resonant frequency of about 210kHz, our inductance can be much larger. Furthermore, the smaller volume also allows us to get a smaller coil, which means we can increase the number of turns. In fact, we want to have as many turns as possible in order to get as much signal as we can, as already described in Faraday’s law of induction.

Because of its well-know homogeneity, I will use a saddle coil geometry approach. Furthermore, since we are dealing with a rotating magnetic field, I will use 2 of them in quadrature, which will give us some SNR improvement. There are two factors in this SNR improvement:

1) Having more coil turns means having more signal
2) We are dealing with a non-shielded design with some external noise coupled to the coils. So the idea is to use the quadrature to get a differential signal, in this way all the common mode noise will be canceled out

This last idea is shown here:

Noise reduction in differential quadrature

In both S1 and S2 signals the external noise is the same, that’s why when subtracted we get rid of it. We are not canceling out the NMR signal though, because the coils are oriented with an angle of 90º, which means we will get a sine in S1 and a cosine in S2. In other words, the resultant signal S1-S2 will be S \cdot \sqrt{2}.

In order to totally cancel the noise out, the problem is that the external noise must be exactly coupled to all the coils. But it’s not possible with the saddle coil geometry, because it would imply to have one coil pair larger in diameter than the other one; otherwise, they would physically overlap. And having a larger coil means more area, which in turn means more external induced noise in that coil. Furthermore, it’s also important to have the same coil parameters for all of them, like inductance, series equivalent resistance, and stray capacitance. In other words, the Q factor and the self-resonant frequency. Well, everything invites us to make a design as symmetric as possible, regardless of the saddle approach. I’m going to use a modified one, like the one you can see here:

This is nice, because all the four coils are exactly the same now. The drawback is that the geometry is different, and so we have to run some more simulations to figure out what’s going on.

In order to achieve the best homogeneity, the saddle coil geometry is defined to have 120º between arms of the same coil with respect to the axis. To figure out which angle is the optimum one for our modified design, I’m going to sweep the saddle angle while monitoring the resultant total homogeneity using my C# program simulator. I modeled the coil geometry programmatically, because it would take me a lot of time to write another software to translate a 3D model to a list of 3D vectors used in my software. The nice thing doing it this way is that I also could program the coil geometry parameters, like the angle to sweep, which wouldn’t be possible using a “static” model approach (e.g. like importing an STL). Here I show the results:

And the same simulation looking from the side view:

It’s interesting to see how the homogeneity peaks at 142º. We have our magic angle, and it’s not 1.1º like the graphene one! 😛

Since I’ve come this far, I wanted to make one last simulation. The previous simulations show the homogeneity at 0º or 180º, but not with both coil pair working together in any angle, which is our real case when we get the rotating magnetic field. That’s what is shown in that last simulation:

At the bottom-left side you can see how the homogeneity fluctuates over time. The magnetic field is only constant at the central point, so, for a real and accurate result, I should have integrated each voxel with the exposed magnetic field over one entire turn. That’s how I would know the total energy received by each water molecule and so the real flip angle. Despite this, I didn’t want to waste more time here since I see quite good results in the central slice. Furthermore, I wouldn’t know how to improve this design further, I’ve done my best at this point.

I haven’t mention it, but I’ve dimensioned the coils to have a diameter as small as possible, but containing as much as B0 homogeneous magnetic field as possible. That’s how I pretend to get a maximum filling factor.

Mechanical design

Once the coil geometry is clear, I’ve designed the custom coil former, which I 3D printed. Here you can see a 3D render animation:

This design makes the coil winding process quite hard and slow, because of its closed design which forces me to wind it like a toroid inductor. Furthermore, after winding one coil, I saw it was difficult to get a good symmetry, because of the half-open concept which keeps one sector more squeezed than the other. That’s why I designed a more sophisticated system, where each coil can be wound individually, and then fixed altogether using nylon screws:

Which is the composition of 4 exactly equal and symmetric coil formers like this one:

Electrical parameters

I wound a single coil to get a rough idea of the coil’s main parameters. The thing is that I could calculate the resultant inductance and series resistance using the Solidworks plugin, which gives you that information taking into account the coil geometry, number of turns, and wire diameter. But I couldn’t get the stray capacitance, which I have no means/knowledge to calculate it. Furthermore, it’s very dependent on the way the coil is wound: it’s not the same to have some overall initial coil section overlapped with some final section, than to have a perfect wound vertical section for each turn around the whole coil. After winding one coil I saw it’s hard to get that perfect vertical section, because the radial force toward the center in the curved plane makes that the wires spread on the surface. That’s why in my redesign I’ve given a bit more space in the axial direction. Now the coil should fit much better without overlapping at the final turns, and now I clearly see it’s almost impossible to calculate the stray capacitance.

That stray capacitance is a very important factor because, together with the coil inductance, it produces a self-resonant frequency. If that self-resonance is close to the nuclear magnetic resonance, we will have no room for the input impedance of our signal amplifier. The worst-case would be that the self-resonance became lower than the NMR frequency, in this case we could get no measure at all.

Summarizing: given a maximum copper volume defined for our coil former, this design is a trade-off between self-capacitance and series resistance while trying to keep the maximum number of turns.

I used 110 turns of 2x 0.2mmØ joined together. The thing is I needed 0.3mm copper wire but I didn’t have any reel available. Just mention that at 210kHz the skin effect for a 0.3mmØ wire begins to be perceptible, but not enough to justify the use of Litz wire. I used my NanoVNA device to get the parameters:

Which in this setup are:

  • Resonant frequency: 715kHz
  • Inductance: 1.5mH
  • Stray capacitance: 33pF
  • Series resistance: 7ohm

This is not the exact final design, but it is telling me I’m on the right way. Given the previous parameters, the Q factor at 210kHz is 283, quite good! 🙂 Putting it all together, my conclusion is that I will use few more turns when winding the 0.3mmØ copper wire in my final coil former. Adding more turns will increase the Q factor because the inductance increases quadratically with the number of turns while the resistance only linearly. But the self-resonant frequency will be lowered at a much faster rate as well, since apart from the inductance, also the stray capacitance increases. As far as we keep the self-resonant frequency with a good margin above the desired NMR frequency, we should wind as many turns as possible to maximize the NMR signal.

Another useful parameter derived from the above data is the A_L of our air core coil former, which is of about 1.24\cdot10^{-7}H/N^{2}. So I can calculate the inductance for any number of turns, e.g. for 130 turns, L=1.24\cdot10^{-7}\cdot130^{2}=2.1mH. In this last case, the resistance would increase from 7Ω to 8.7Ω, but the Q factor would increase from 283 to 318. I have no idea about the stray capacitance in this new case, but supposing no capacitance variation, we would have a self-resonant frequency of about 600kHz (which will be lower due to the real higher stray-capacitance). I guess I will try with about 150 turns if the coil former allows me to fit all of them.

More results coming soon!

Gradient coils

If we stop now, in the best case we would get a nice NMR coming from the sample, but we would just get a single frequency peak at resonance. To get an image, we need the gradient coils to generate controlled frequency shifts.

I haven’t invented anything new here, there are some geometries which already work and that can be applied in our design. Despite this, I had to figure out some methods to create them.

The complex coil shape makes it difficult to use Solidworks for its design. That’s why I’m going to use an X-Y parametric equation driven curve, and to design it, I’m again going to use Matlab.

Script

First we need to calculate the X and Y with respect to the driven variable, which in my case will be ‘t‘, ranging from 0 to 1. Generating a circle is simple, just using a sine for X and cosine for Y, sweeping t from 0 to 2·π. To generate a spiral with N spires, it’s quite the same, but ranging from 0 to N·2·π, and adding an offset per turn, like multiplying it by ‘t’. But if we want a squared shape, we need to add some harmonics, like what happens in a square signal, defined as:

y = sin(t) + sin(3*t)/3 + sin(5*t)/5 + sin(7*t)/7 + sin(9*t)/9 + ...

The more the harmonics, the more the squared shape we get. I’m just going to use the first 2 harmonics for X, and only the second harmonic for Y. This is the final script:

t=linspace(0, 1, 5000);

TotalTurns = 25;
CentralInitialWidth = 0.8;
Width = 50;
AsymmetricWidthCorrection = 0.035;
Width_FirstHarmonic = 4;
Width_SecondHarmonic = 1;
HorizontalDisplacement = 9;
x = (CentralInitialWidth + Width.*t).*cos(TotalTurns*2*pi.*t) .*(1 + AsymmetricWidthCorrection.*sin(TotalTurns*2*pi.*t));
x = x - Width_FirstHarmonic.*t.*cos(3*TotalTurns*2*pi.*t);
x = x - Width_SecondHarmonic.*t.*cos(5*TotalTurns*2*pi.*t);
x = x + HorizontalDisplacement.*t;

CentralInitialHeight = 20;
Height = 75;
Height_SecondHarmonic = 6;
VerticalOffset = 1;
y = (CentralInitialHeight + Height.*t).*sin(TotalTurns*2*pi.*t);
y = y - Height_SecondHarmonic.*t.*sin(5*TotalTurns*2*pi.*t);
y = y + VerticalOffset;

plot(x,y);
radius=60;
axis([-42 60 -pi/2*radius pi/2*radius]);
pbaspect([1 1 1]);

Which generates that plot:

You can play with the script by changing the values, you will understand it better than if I try to explain the purpose of each one. You can use the online version of Octave.

The parameters to define the shape, though, are not random ones. It’s the result of several iterations using my C# software to achieve the most linear gradient. There are 2 main parameters we want to optimize, which I’m going to explain using the X gradient coils as an example:

  • Gradient linearity: The magnetic field in the central Y-Z plane should never change when we apply the X gradient, it should always be the B0 one. But in the measure we move away from the axis towards the X direction, the magnetic field should linearly decrease to one side or increase to the other. The non-linearities here will result in a wrong signal location when trying to map the position of the voxels. Although I guess some calibration can be applied if the gradient has a positive slope without flat zones.
  • Homogeneity: We want the maximum homogeneity along the Y-axis in the X-Y plane. The worst case is found at the edge, closer to the coils where the magnetic field is at the highest level.

These concepts can be better understood in the following simulations.

Magnetic simulation

Having the X-Y equation which describes the electric current path, it was quite easy to integrate it to the C# simulator to generate the geometry using a 3DVector list. All the parameters of the script were also coded, so I could modify it to optimize the resultant magnetic field. I also had to add the curvature of the radius to the flat coil resulting from the previous script, since we want it projected over a cylinder. It was done by adding a sine/cosine transformation with respect to the vertical direction of the script result.

The grid is 1mm, so we have 60×60 resultant magnetic field vectors in this simulation, there is a pretty large area with good linearity and homogeneity:

X-Gradient coil

As you can observe in the simulation result, the left side vectors of the slice are pointing towards you, while the right side ones are pointing into the screen with the same magnitude but opposite direction. That’s why the gradient at the central point is zero.

The left-bottom plot shows the horizontal gradient along the X-axis (the green axis). It doesn’t perfectly fit a straight line, so the linearity could be improved, but it will be enough. We probably won’t be able to get that much resolution to worry about these tiny improvements. I have hidden 3 of the 4 coils to get better visibility, I will show the final design in a while.

The plot above the previously described is the vertical inhomogeneity along the Y-axis direction (the blue axis), but measured at the zone with the highest magnetic field (the left and right side of the slice, the same by symmetry). The difference is just 3μT with respect to the total 165μT, which is really good.

This geometry, as seen in the script, describes 4 loops of 25 turns. The simulation was run with a conductor current of 1A, which produces a maximum magnetic field of 165μT. This magnetic field will be added or subtracted to the main B0 magnetic field. That’s how we will locate the voxels along the X-axis, with a B0 of 5mT (213kHz) we will get a spin resonance of 206kHz at x=-30mm, and a resonance of 220kHz at x=30mm. Great! 🙂 An FFT of 1024 points at 213kHz has a resolution of 208Hz, which means a voxel resolution of 7·2kHz/208Hz=67 x 67 voxels. I’m just making some rude numbers, I will think about how to do this when the time comes.

This is how the whole X-gradient geometry looks like when zoomed out:

And the render once designed in Solidworks:

A small detail that might worsen the performance is the short copper wire which will bring the current to the center of each coil. Generally speaking, all currents in this design will be transported up and down using twisted-pair cables to prevent generating magnetic interferences. But in this described case it’s not possible. I thought about doubling the number of turns by adding a second layer which would return the current to the same origin, but I don’t want to lose more time with this adding even more complexity. If I solder a short cable from the center of the coil to the extreme, and kept parallel to the Z-axis, the induced error should be quite low, and once there I will be able to solder a twisted pair cable as it should be.

The Y-gradient coils geometry is exactly the same, but with a slightly larger diameter, so that they can physically coexist without collision. Then, rotated 90 degrees along the Z-axis, so that we can generate the gradient along the Y-axis.

Physical coil implementation

The shape is hard to design by hand, that’s why I will use my laser cutter. Of course it has not enough power to cut copper, but it can cut Kapton tape. The idea is to coat a copper sheet with a layer of Kapton, and then vaporize it using laser sublimation at the zones where we want the copper to be removed. Then, add this copper sheet to a tray with etching acid which will remove that part of the copper. Some kind of PCB manufacturing process but without the substrate.

The Matlab script, as well as the C# simulation, uses the parametric equation driven curve as the path where the current flows. But we don’t want to cut by this line, we need to cut by the center of 2 consecutive lines. In this way, we ensure the current will flow by the desired path. Well, it might not be totally true, since it depends on the current density through the copper section, which in turn depends on the lowest resistance path. But anyway, using the said method is a good approximation. So I modified the parameters of Matlab script to get that second line where to cut (red line):

More results coming soon!

Assembly and Testing

In the following video, I show the 3D printing process of the RF coil formers, the result of the windings in 2 pieces, and the final assembly by joining the 4 pieces using non-magnetic nylon screws.

To observe the rotating magnetic field effect, I use a neodymium magnet diametrically polarized. From both coil pairs assembled in quadrature, a sinusoidal current is applied to the first one (using a function generator), and the same current dephased 90º is applied at the second pair, as can be observed in the screen.

The 300mHz generates a complete magnet turn approximately every 3 seconds, although, in the MRI, we will use 213kHz at 5mT.

Since motors don’t care about homogeneity, it probably is the most homogeneous magnetic field motor in the world right now 😛

Schematics, schematics, schematics…

Working hard on the electronic schematics these days! I’m done with the main B0 current source, finally with less than 3µVPP of noise from 0.1 to 10Hz and 0.4µV of resolution. The voltage-to-current conversion will depend on the shunt resistor, where the worst case is when using a 0R47: the noise and resolution will be of 6µAPP and 0.8µA. I need that much resolution to get the required magnetic field trimming.

I’m also using an NTC close to the current sense resistors, thermally coupled among them and chosen with the same size and PPM/ºC, to compensate by firmware the resistor variations due to self-heating.

I’m using a DC/DC controlled by the microcontroller to adjust the voltage in the MOSFET drain, and let it work in the linear region. I need the DC/DC because too much voltage across the MOSFET implies too much dissipated power. The main microcontroller will initially perform a calibration:

  • 1. Set a current of let’s say 100mA using the 16-bit DAC
  • 2. Start increasing the duty cycle of the PWM to rise the I_OUT voltage
  • 3. While increasing, keep checking the OA_SAT pin. Right now it will be 3.3V because the small I_OUT voltage makes few current to flow through the coil, and the MOSFET will be in the saturation region. But when the OA_SAT pin becomes <3.3V will mean that we just left the saturation region, so we just need to increase about 0.5V more to give the MOSFET some margin to work properly in the ohmic region without dissipating too much power

A better way would be to connect the I_IN voltage to an ADC input, but it should have to be done through an operational amplifier with low bias current, or the shunt resistor would measure the sum of both currents and the precision would be lost.

A 100µH seems a pretty high value for the DC/DC, but we want the ripple current to be as low as possible. With a so large inductor, we don’t need large capacitors, but what is really important is that they have a low ESR, since that’s the main source of ripple noise. In this case, it’s MUCH better to have a total of 40µF using ceramic capacitors than 470µF using an electrolytic one.

Finally, about the high frequency control loop compensation network. It was added there because we are using a current source to control the current of a VERY large inductor (the one which generates the main B0 magnetic field). Without that network, the operational amplifier would be unstable and it would oscillate.

Let’s keep moving on!