Helmholtz coil – Animated 3D Magnetic field simulation

Today I’ve just been playing with my software to render this 3D animation of the magnetic field generated by a Helmholtz coil. The objective was to observe how the magnetic homogeneity varies with respect to the distance between coils.

As you can see, we find the maximum homogeneity when the distance between coils equals the radius (70mm). The total central magnetic field is also decreasing as the coils spread apart. In each of the 300 simulations to generate this animation, the central magnetic field is calculated and plotted to the left graph, and then only the 3D vectors fitting the 100ppm volume are shown. The homogeneity is also plotted below the central magnetic field graph, and the maximum variability shown in the right color scale in nT.

Enjoy!

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 😛