Sebastian Littin^{1}, Feng Jia^{1}, and Maxim Zaitsev^{1}

^{1}Department of Radiology, Medical Physics, University of Freiburg, University Medical Center, Freiburg, Germany

The design of gradient coils is sometimes perceived as complex. However, the relation between a current density and a stream function is a simple differentiation. Here we present an intuitive open source code collection to derive gradient coil designs from current densities. Stream functions are derived directly and indirectly from the current distribution. The aim of this work is to provide a simple tool for educational purposes. The code collection which is available on GitHub enables for straight-forward coil designs on simple surface geometries.

An inverse problem to get a current density for a given target field can be stated by deploying the pseudoinverse S

The gradient of this current distribution may be used to display equally spaced iso-contours, usually denoted as stream function representation. Because the resulting stream lines derived from the current density might not be realizable as closed loops, an additional constraint may be added to ensure that the sum of currents along z is zero.

Another part of this code collection enables to derive a sensitivity matrix in the stream function domain. By combining neighboring thin wires along z, such that they carry the same current in opposite directions, a basic cell is formed from two neighboring wires. This can be simply done by combining two of the previously obtained sensitivity matrices S

Additionally included are plotting functions to display current distributions, stream functions and stream lines in 2D and 3D. The code was written in MATLAB (The MathWorks, Natick, MA, USA). However, the code runs in Octave, as well. The code is available on github:

However the current implementation works only with simple, continuous surface geometries. Additionally, only the z-component of the magnetic field (B

Except for the 3D plotting functions no problems could be observed while running it in Octave. The code is open source and available on GitHub [3]

[1] github.com/gBringout/CoilDesign

[2] G Bringout, IEEE Transactions on Magnetics 2015, 51(2): 5300604

[3] github.com/Sebastian-MR/GradStreamFigure 1: Each pixel represents a discrete thin-wire which is oriented orthogonal to z. The regularized current density depicted in a) may not be transformed to a coil design which is realizable with closed loops. The addition of a constraint, that the sum of currents along z equals 0 leads to a completely different current density as shown in b). The spatial derivative of this current density represents a stream function, shown in c). Iso-contours of such a stream function may be used to approximate the current density from b) by deploying discrete wires.

Figure 2: 3D representation of the stream function and iso-contours from Fig.1.

Figure 3: By combining neighboring thin-wires to one cell, a stream function basis may be formed. This enables to directly calculate the spatial derivative of the current density in the stream function domain. It can be seen from the unregularized stream function depicted in a) that this mathematical problem is ill-posed. A regularized design solved in the stream function domain is shown in b).

Figure 4: Depiction of iso-contours from the solution in the stream function domain a) and the combination of iso-contours and the stream function b) in a 3D representation