B0-Shimming Methodology for Affordable and Compact Low-Field Magnetic Resonance Imaging Magnets

Low-field (B0 < 0.2 T) magnetic resonance imaging (MRI) is emerging as a low cost, point-of-care alternative to provide access to diagnostic imaging technology even in resource scarce environments. MRI magnets can be constructed based on permanent neodymium-iron-boron (NdFeB) magnets in discretized arrangements, leading to substantially lower mass and costs. A challenge with these designs is, however, a good B 0 field homogeneity, which is needed to produce high quality images free of distortions. In this work, we describe an iterative approach to build a low-field MR magnet based on a B 0 -shimming methodology using genetic algorithms. The methodology is tested by constructing a small bore (inner bore diameter = 130 mm) desktop MR magnet (<15 kg) at a field strength of B 0 = 0.1 T and a target volume of 4 cm in diameter. The configuration consists of a base magnet and shim inserts, which can be placed iteratively without modifying the base magnet assembly and without changing the inner dimensions of the bore or the outer dimensions of the MR magnet. Applying the shims, B 0 field inhomogeneity could be reduced by a factor 8 from 5,448 to 682 ppm in the target central slice of the magnet. Further improvements of these results can be achieved in a second or third iteration, using more sensitive magnetic field probes (e.g., nuclear magnetic resonance based magnetic field measurements). The presented methodology is scalable to bigger magnet designs. The MR magnet can be reproduced with off-the-shelf components and a 3D printer and no special tools are needed for construction. All design files and code to reproduce the results will be made available as open source hardware.


INTRODUCTION
In the last decades, magnetic resonance imaging (MRI) developed to one of the most useful medical imaging techniques allowing to depict the structure and function of tissue and organs in a quality, which is unmatched by other clinical imaging modalities. Despite this technological and clinical progress, machines and operation of these machines is still very expensive and restricted to a small portion of the global population of patients [1]. Current MRI magnets mostly rely on cryogenically cooled superconductors to reach high magnetic fields of typically B 0 1.5-3.0 T. These high fields drive the complexity and are mainly responsible for the high costs of an MRI [2]. Recently, several efforts emerged investigating the benefits of low field MRI (B 0 < 0.2 T) to provide a low cost, pointof-care alternative [2][3][4][5][6][7]. The MR magnet design benefits from reduced complexity and costs at lower fields. While in the past most low field MR magnets were based on permanently magnetized iron with a ferromagnetic yoke, more recently permanent magnet designs are based on a Halbach or Halbach type layout, where multiple small magnets are arranged in a specific way [8][9][10][11][12]. These designs have the advantage that less magnetic mass is utilized, making the magnets smaller, more mobile, and less costly. A challenge with these designs is, however, to achieve a good B 0 field homogeneity, which for commercial high field systems is typically below <10 ppm. One way to relax these requirements is to build in fixed gradients into the magnet design which are used for spatial encoding [7,[10][11][12][13]. Even for classical imaging applications using switched gradient coils along three dimensions, Halbach based low-field magnet designs were recently able to produce invivo imaging of the extremities, the brain [14] and implants [15], which benefits from lower specific absorption rate (SAR) and lower susceptibility artefacts compared to higher field systems. These encouraging results were acquired with a Halbach based permanent magnet that has an inhomogeneity of 2,400 ppm in the target field of view, demonstrating that the requirements on B 0 field homogeneity at low fields are less strict. Spin echo based imaging can be used to generate most contrasts and T 2 * based contrasts utilizing gradient echo imaging techniques that require higher field homogeneities, are much lower at lower fields. Nevertheless, the B 0 homogeneity over the target volume needs to be within the bandwidth of the RF excitation and a strong B 0 inhomogeneity might lead to image distortions.
Even though MR magnets can be designed very homogeneously in numerical simulations [9], translating these results into the practice is very challenging especially in a low-cost setting. The strengths of the magnetic field from neodymium-iron-boron (NdFeB) magnets may vary up to 5% due to material imperfections and the angular variation of the magnetization vector up to 0.9° [16]. The remanence of the magnetic material is sensitive to temperature changes and the positioning and orientation of the many magnets will deviate slightly from the simulated setting e.g., due to forces that are present between the magnets [17].
B 0 shimming work for low-field permanent magnets is so far mostly limited to simulation studies [18], two pole or C-shaped magnets [18,19] and/or for small shimming volumes focusing on the application of nuclear magnetic resonance (NMR) spectroscopy [20]. Recently low-field MR magnets are being constructed based on genetic algorithms using a dipole approximation to determine the position, orientation and material of the discrete magnets to reach a target field profile [9,11,12].
In this work an iterative approach in the design of a low-field MR magnet using Halbach arrays is investigated with the goal to improve B 0 homogeneity. The methodology is tested on a small bore (inner bore diameter 130 mm) MR magnet with a B 0 field strength of 0.1 T and a target field of view of ∼4 cm in diameter. The strategy is two-fold relying on a compact base magnet design, which consequently is shimmed using a genetic algorithm and shim inserts. The MR magnet can be reproduced with off-the-shelf components and a 3D printer and used e.g., for educational purposes in existing setups [21]. The evaluated shimming techniques improve B 0 homogeneity up to a factor of 8 in the first iteration and the applied methodology is scalable to bigger magnet designs. Design files and code from this work will be made available as open source hardware on opensourceimaging.org.

MATERIALS AND METHODS
The presented strategy to construct a homogeneous MR magnet consist of two parts: 1) The construction of a base magnetic field with the envisioned B 0 field strengths and inner bore diameter ( Figure 1). 2) Shimming of the base magnet using a genetic algorithm to calculate the sizes, locations, and orientations of the shimming magnets, which are inserted in the base magnet design ( Figure 2). A requirement of this shimming approach is that the inner or outer dimensions of the base magnet are not modified.
The proof of concept of this methodology is tested on a desktop MR magnet with a targeted inner bore diameter of 10 cm (including gradient coils). The size was chosen such that all components can be 3D printed with a standard sized 3D printer.

Simulation Environment and Mathematical Methods
For the base magnet, magnetostatic field simulations were conducted using COMSOL Multiphysics 5.4 (COMSOL AB, Stockholm, Sweden) utilizing the finite element method (FEM). The geometry of the magnets is assumed to be not chamfered. Inside the magnets, the remanent field is set to the appropriate strength, while outside it is assumed μ r ε r 1.
For the B 0 shimming algorithm, the dipole approximation was used to calculate the magnetic field distribution of each shim magnet [22]: with the permeability of vacuum μ 0 and the location r of the magnetic field with respect to the origin of the magnetic dipole moment (or shim magnet) m. For a shim magnet, the magnitude of the magnetic dipole moment m can be calculated by [23].
with the remanence B r and the magnet volume V. Only the z-component is considered, as the magnetic field to be shimmed is oriented along this axis.
Using the weighted orthogonal basis set of real (orthonormalized) spherical harmonic functions Y lm in spherical coordinates, the z-component of the magnetic field B z on a sphere with radius r, polar θ and azimutal ϕ angles is described as The spherical harmonic coefficients c lm , dependent on the degree l and order m, can be calculated with Using this representation, coefficients of higher order and degree, can be truncated reducing the number of parameters used to represent the field and subsequently reducing the computational time of the shimming algorithm. Note that the spherical harmonic coefficients used here are not implicitly dependent on the radius contrary to standard literature, as the field is considered on a sphere with constant radius [22]. The coefficients are calculated using the module SHTOOLS [24].

Base Magnet Design
The base magnet is made from octagonal (circumradius 11.64 mm, width 14 mm) NdFeB magnets (N50, Ningbo Zhaobao Magnet, Ningbo Shi, China), which are arranged in three times two rings of 20 magnets each (total of 120 magnets) in a Halbach array design [16,25] (Figure 1). Octagonal magnets were chosen over rectangular ones, because in terms of homogeneity they can better resemble an ideal Halbach array [16,26,27]. The base magnet was constructed of same sized magnets to facilitate reproducibility and the octagonal magnet size was limited to maintain reasonable forces enabling a relatively safe and easy construction by hand. Multiple dipolar Halbach magnet stacks or rings can improve field homogeneity by adjusting the distance between the rings [8]. While for two rings the distance can be determined analytically, for a higher number of stacked rings numerical calculations are required. A higher number of rings increases the overall magnet size, weight and costs substantially. Therefore, a three-ring setup is implemented in this work. Two stacks of octagonal magnets with 2 mm distance in x-direction are considered a single ring ( Figure 1). The central ring (Ring 2) generates a field of around 50 mT in the center and shows a concave B z profile along y-z direction ( Figure 3). Adjusting the distance of Ring 1 and Ring 3 generates a convex magnetic field profile along the same direction ( Figure 3). By adjusting the distance between ring 1 and ring 3, it is therefore possible to homogenize the field in the center of ring 2 to some extent ( Figure 3). More importantly this step can be performed based on measurements (including all material imperfections or positioning errors) and does not require simulations to determine the distance. Overall a B 0 of 103 mT is reached in the center of the base magnet. For the base magnet the octagonal magnets were not individually measured and sorted beforehand so that all material imperfections influence B 0 homogeneity of the base magnet.

Genetic Algorithm
For B 0 -shimming, shim magnet placement was restricted in between and at the end of the base magnet rings (Figure 4), thus not reducing inner bore diameter or increasing the outer magnet dimensions. Furthermore, as the magnetic field decreases with the power of three Eq. (1), placing shim magnets further away from the targeted field of view increases the magnetic mass of the shims and the overall magnet weight and costs.
After B 0 field measurements to determine the B 0 field distribution of the base magnet in the field of view, a genetic algorithm is used to determine the size, position, and orientation of the shim magnets [9,28]. Over other algorithms typically used in shimming as linear programming or the least square method this allows for a more flexible mathematical formulation of the optimization problem [29].
In the algorithm, a population (i.e., a collection of possible arrangements of shimming magnets) is evolved to find the best individual (i.e., best arrangement to homogenize the field). Each individual has a genome composed of genes (e.g., location of a shim magnet) describing the state (e.g., the orientation of the shim magnet) of the individual. As an underlying symmetry, the magnets are placed in a ring around the bore in Halbach or radial orientation. In total for each magnet five states were considered, four rotational deviations by 0°, 90°, 180°and 270°from the Halbach or respectively radial arrangement and the fifth state indicated no magnet placement.
The algorithm starts by creating 25,000 random individuals and calculates their cost function, which is a measure of inhomogeneity created by a given individual. The best individuals of the population are selected via tournament selection, where three individuals are chosen by random and the best is selected as a surviving individual. This process is repeated until the new population reaches the initial population size including redundant individuals. In the next step, the twopoint crossover is performed with a probability of 75%, which recombines two neighbouring individuals by interchanging one randomly chosen part of their genome. To further diversify the population, a 20% mutation chance was set. If an individual mutates, every gene of its genome is changed randomly with a 5% chance. All cost functions, which have been changed by previous procedures, are calculated and the algorithm starts again with the tournament selection. The chosen probabilities have been shown to work well within the class of problems [8,10]. A minimum of 300 iterations is performed, the algorithm converges when the last 20% of iterations do not create new individuals with a lower cost function. For the implementation, Python 3.6 was used and the DEAP module [9].
For the target field approach, using predetermined values at given spatial positions [30], the cost function is set to the peak-topeak B 0 difference in the investigated 2D or 3D area. Compared to inhomogeneity, this avoids calculating the mean, which is numerically costly. This is reasonable since the B 0 shim field does not change the mean field amplitude significantly.
In addition, a representation based on spherical harmonics was investigated and the results compared to the target field approach. For this spherical harmonics approach, the cost function is chosen as the sum of the absolute values of the spherical harmonic coefficients (except the 0 th ) [31,32]. As orthonormalized functions are used, every function contributes equally to the field inhomogeneities and no weights are applied.

2D/3D B 0 -Shimming
Prior to shimming the base magnet, simulations were performed to evaluate different shim configurations. The field of the magnet is simulated using the FEM and the genetic algorithm is used to assess different shimming scenarios. The number of magnets in one ring is maximized for the given radius while considering a 2 mm distance between neighbouring magnets. A single shim ring consists of two stacked rings of magnets with Figure  4A) and r 2 95 mm  Figure 4A). 2. One shim ring is placed in front of Ring 1 and another one at the end of Ring 3. These rings are referred to as outer shim rings ( Figures 4A-C). The distance of the outer shim rings to the center of the bore is ±78.75 mm. 3. A combination of inner and outer rings, which is referred to as both.
For all these combinations, the genetic algorithm was applied for cube-shaped shim magnets of 6, 8, 10, 12 and 14 mm edge length. Two targets to homogenize the field were investigated: 1) A 2D area of 4 cm in diameter in y-z plane at the center of the magnet (x 0), which corresponds to a 2D slice used for imaging 2) A 3D spherical volume of 4 cm in diameter around the center of the magnet.
Each simulation took on average 2 h 35 min with a standard deviation of 43 min on an Intel Xeon Processors E5-2,690 v3 (12 cores, 24 threads in total).
For the finally applied shims, cube shaped (9 × 9 × 9) mm 3 NdFeB magnets (N48, Otom Group GmbH, Bräunlingen, Germany) were purchased. Before installation, the magnetic field of these magnets was measured at a distance of 45.6 mm to reduce variability in between magnets. Each 10th measurement a reference magnet was used, and the temperature was monitored ( Figure 5). Magnets with stronger variations in magnetic field were sorted out. Within the errors of the sensor, they are normally distributed with a mean of 1.587 mT and a standard deviation of 7 μT. This results in a mean effective remanence (assuming a perfect magnet volume of (9 × 9 × 9) mm 3 ) of 1.296 T with standard deviation 6 mT at 20°C. This mean remanence was used for the B 0 shimming calculations.

Magnet Construction
The base magnet casing and the shim inserts were designed in FreeCAD (v018, http://www.freecadweb.org). Selective laser sintering (SLS), with a dimensional accuracy of ±0.3 mm, was used to fabricate the designs. These rings are positioned on four threaded brass rods, whereas the distance between the rings was adjusted using nuts ( Figure 2D). Each shim ring consists of four interlockable pieces (Figures 2A-C), which can be inserted radially into the base magnet without modifying its assembly ( Figure 2D). These shim inserts contain pockets that allow the placement of (9 × 9 × 9) mm³ magnets to be positioned at various angles in radial or Halbach orientation. A maximum of 76 shim magnets can be placed in a single shim ring, leading to an overall maximum of 304 shim magnets that can be inserted into the shims.

Measurement Setup
For magnetic field measurements of B z , a Hallprobe (Gaussmeter Model 460, LakeShore Cryotronics, Westerville, OH, United States) was used. The Hallprobe was mounted to COSI Measure [33], an open source 3-axis positioning system with submillimeter precision, to autonomously map the magnetic field of the magnet before and after shimming. Since the magnets are temperature dependent, room temperature was measured inside a water bottle using a temperature probe (P550, Dostmann

Base Magnet
The distance d 1 between Ring 1 and Ring 3 was adjusted in measurements to 75 mm, which was the distance found giving the best compromise between compact magnet size and B 0 field homogeneity. The measured unshimmed magnetic field of the base magnet in the center of the field of view is B 0 102.8 (3) mT, with an inhomogeneity of 5,448 ppm in the 2D and 8,271 ppm in the 3D target region, both of 4 cm diameter.

B 0 -Shimming
The results based on the simulations of the base magnet to evaluate the shim magnet size and configuration are displayed in Figure 6.
For the 2D target the lowest B 0 inhomogeneity was 418 ppm using 10 mm magnets for the outer shim rings ( Figure 6A). Using only the inner rings for shimming, the minimum was found for 9 mm cube magnets with an overall inhomogeneity of 1,240 ppm. A combination of inner and outer same sized magnets showed a minimum of 429 ppm using 9 mm cube shaped magnets. Like the 2D shimming results, 10 mm magnets showed the best homogeneity for the outer ring magnets with 4,015 ppm and a 3D target volume ( Figure 6B). The magnet size for the inner ring magnets was best for 12 mm sized magnets with 4,091 ppm. Using the configuration "both" for same sized magnets, B 0 homogeneity could be improved slightly to 3,913 ppm for 9 mm magnets.

2D B 0 -Shimming of the Base Magnet
Based on the simulation results, 9 mm cube shaped magnets were used to determine the shims for the base magnet. The results of the genetic algorithm for multiple runs and different magnet orientations [k 1 (radial), k 2 (Halbach)] are depicted in Figure 6C. Both show similar performance. Due to an easier construction process, a radial orientation was used for the final shim. The overall number of magnets at a certain rotational angle is displayed in Figure 6D and shows a balanced distribution between the different states. Overall, 236 of possible 304 magnets were placed in the shim rings and all rotational possibilities were used in the final set of shim magnets. The final shim magnet arrangement (exemplified on a single shim ring) is shown in Figure 6E. Implementing this shim, the simulations predicted a reduction in inhomogeneity by a factor 8 from 5,448 ppm ( Figure 7A) to 560 ppm ( Figure 7B). The measured field inhomogeneity was 682 ppm ( Figure 7C). The calculated and measured field inhomogeneities over the target area are depicted in Figure 7D. A slight shift in the measured mean field was observed, which was 0.35 mT higher in the absolute B 0 values for the calculated shim configuration ( Figure 7E).

Spherical Harmonics
All spherical harmonics coefficients up to the 17th degree and ±17th order of the measured B 0 field of the desktop magnet are shown in Figure 8A. To determine how many coefficients are necessary to properly reconstruct the field, the pointwise difference for a truncation at a certain degree (and order in the inset) is depicted in Figure 8B. Above degree four and order two no improvement (deviation <100 μT) of the reconstruction from the measured field can be observed. The difference between the measured ( Figure 8C) and the reconstructed field based on the truncated (l ≤ 4, m ≤ 4) spherical harmonics ( Figure 8D) is depicted in Figure 8E. Overall a mean difference of 0.2 ± 17 μT was found with a maximum peak-to-peak difference of 145 μT in the overall volume. Consequently, the truncated spherical harmonics representation can be used to calculate a B 0 shim for the 3D volume, which reduced computational time substantially in particular for a larger number of shimming magnets.

3D B 0 -Shimming
The calculated and measured 3D shim results are displayed in Figure 9. Before shimming, the 3D target sphere showed an inhomogeneity of 8,271 ppm. The calculated magnetic field distribution after shimming using the 9 mm magnets showed a inhomogeneity of 2,596 ppm ( Figure 9A) over the target volume while the measured values were at 3,759 ppm ( Figure 9B). The difference is displayed in Figure 9C. For the 3D approach, the improvement in homogeneity is less pronounced compared to the 2D target by only a factor of 2.2 ( Table 1). Illustrating the shimming results based on spherical harmonic degree showed that all spherical harmonic coefficients except the coefficients of degree four can be shimmed efficiently ( Figure 9D). Three coefficients are mainly contributing to the inhomogeneities.
These are (l, m) (2, −2), (l, m) (4, 0) and (l) (4, 2) as illustrated in Figure 9E. To further understand how the truncation of the field distribution is influencing the outcome of the shim, the field of the shim magnets is calculated with the dipole approximation and added to the truncated measured field before shimming. Compared to the calculation of the shim field with the truncated coefficients, the inhomogeneity reduces by 31 ppm. Consequently, the truncation of the dipole field of the shims is a good approximation and does not induce a large error. The results of the inhomogeneity per diameter of the sphere is displayed in Figure 9F. After a diameter of around 30 mm, B 0 inhomogeneity rapidly decreases.

DISCUSSION
In this work, B 0 shimming based methodology is investigated to construct a homogeneous, low-cost and low-field (B 0 0.1 T) MR magnet using permanent magnets in an Halbach array configuration. The desktop magnet can be easily constructed using 3D printers, readily available NdFeB magnets and simple tools. It is relatively lightweight (∼15 kg) and has an overall material cost of ∼700 €, which is mostly due to the cost of the magnetic material used. It is therefore suitable to be used for educational applications in tabletop systems [21,34] or small volume imaging applications. Previous work demonstrated that a homogeneity of 2,400 ppm over the target field of view is sufficient to achieve good image quality at 50 mT using turbo spin echo sequences with reasonable acquisition times [9,14,15]. To reach these homogeneities for  the desktop magnet, an iterative approach is suggested to build a base magnet that mainly determines the targeted B 0 field and in a second step to iteratively position shim inserts to improve the field homogeneity. With this approach, the initial B 0 -field inhomogeneity of the base magnet of 5,448 ppm in the 2D area could be reduced by a factor ∼8-682 ppm in the first shimming iteration. The results are encouraging and suggest that even higher B 0 shimming homogeneities can be reached using an iterative approach. Simulation results of varying the shim magnet sizes show that the outer rings alone already improve B 0 field homogeneity substantially ( Figure 6A). Consequently, a first shimming stage would e.g., implement the outer shim rings first and apply the genetic algorithm to determine the magnet size for the second shimming stage. Due to the more homogeneous base field, the magnets from the second stage will be much smaller (e.g., half the size) allowing space for the potential placement of another two shim rings in a third shimming stage close to the magnet center. This iterative shimming approach was not tested in this work due to limitations in the available Hall sensor sensitivity (∼500 ppm), which is clearly visible in the presented data ( Figures 7B,C). For further investigations and to improve the results, a Hall sensor with higher sensitivity is needed or an NMR based magnetic field measurement where accuracies typically are in the order of 10 ppm or less. For the 3D shimming results the target sphere could be shimmed from initially 8,271 to 3,759 ppm. This corresponds to an improvement by a factor of 2.2. Even though such improvement is comparable to other works on passive B 0 shimming after a single iteration [35], it is relatively low compared to the 2D shim results. Calculations based on the measured spherical harmonic coefficients ( Figure 9F) demonstrated that B 0 field inhomogeneity decreases rapidly after around 30 mm diameter from the center of Ring 2. Further calculations ( Figure 9D) showed that the main contributor to these inhomogeneities are the spherical harmonic coefficients of fourth degree, which could not be shimmed efficiently using the investigated setup. This indicates a drawback in the presented magnet design of the base magnet, which is adjusted to perform 2D imaging of a central slice. To improve the homogeneity along the x-axis, more rings are needed in order to approach the homogeneity of a perfect Halbach cylinder [26,36]. Adding these rings however would furthermore increase the size, weight and cost of the magnet substantially and would require numerical optimization [36].
One advantage of the presented approach is that the shims can be inserted after the base magnet assembly, without compromising the inner or outer dimensions of the magnet. Placing movable magnet blocks inside the magnet [37], could further improve B 0 field homogeneity while compromising inner bore diameter. Placing shims outside of the magnet may require bigger shimming magnets and more magnetic mass. Another advantage of the three-ring setup for the base magnet is that, in principle, it can be constructed without any magnetostatic field simulations using FEM, where dedicated software is required. The distance adjustment between Ring 1 and Ring 3 can be performed based on the measurements alone. At this stage the optimization for homogeneity is less important due to the possibility of adding the shim inserts afterwards and homogenizing B 0 in an iterative manner using the genetic algorithm and the dipole approximation. This would allow the magnets to be scaled easily to a particular application of interest where a target B 0 is chosen based on parameters such as inner/outer radius and/or cost of magnetic material used [38]. Bigger magnet sizes are likely to further improve the shimming results since more shimming magnets can be used and magnetic field fluctuations in the target area due to position, orientation and/or material errors of individual shim magnets are expected to be less severe.
Octagonal magnets were used to improve the homogeneity of the base magnet and increase the magnetic flux compared to rectangular magnets [16,27]. However, the first shim iteration is already improving homogeneity by nearly an order of magnitude, so it might be advantageous to use rectangular magnets, which are more accessible and affordable.
The calculations based on the genetic algorithm converged within 300 ppm ( Figure 7D), therefore the parameters are chosen well and conservative. For 3D shimming and larger overall MR magnet dimensions the number of shim magnets that could be placed would increase together with the overall calculation time. Using the spherical harmonics approach investigated in this work reduces the number of parameters used for the genetic algorithm leading to a reduction in simulation time by a factor of ∼3.
From the data presented in Figure 7E, it is visible that the shimmed field shows lower overall B 0 values compared to the calculated shim. This may indicate a slight misalignment of the shim rings along the x-axis, which reduces the absolute field values in the target area. Improving the precision in aligning the shim rings along the x-axis may improve the shimming results in the y-z plane leading to values closer to the calculated ones.
A drawback of permanent magnets is the associated temperature drift of the magnetic field ( Figure 5). In order to investigate the temperature dependence of B 0 field distribution of the current setup an additional experiment was performed, where the magnet was heated inhomogeneously (Supplementary Figure 1). This resembles a possible worst-case scenario, where both ambient temperature changes and local temperature changes are present. Heating the magnet to temperatures from 30.5-36.8°C resulted in a decrease in homogeneity from 407 to 1,095 ppm in the investigated area. Apart from the inhomogeneous temperature distribution which influences both base magnet and shim ring field drifts, a reason for the increased inhomogeneity at different temperatures might be the use of two different magnet grades used in the setup: N50 for the octagonal magnets and N42 for the shim inserts. Ideally a single material grade is implemented for both base magnet and shim inserts to avoid different temperature dependencies, which may affect B 0 homogeneity even for global temperature changes. An interesting approach to stabilize the field at different temperatures is the use of at least two magnetic materials with different temperature coefficients, which can be positioned in a way to cancel temperature dependent field variations efficiently [39]. Another way to counteract unavoidable temperature changes and homogenize the field is the use of active B 0 shimming techniques [31,40].

CONCLUSION
It was demonstrated that an iterative approach to construct a cost-effective, homogeneous desktop MR magnet consisting of a base magnet and B 0 shim ring inserts is feasible. The approach is scalable to bigger magnet dimensions and has the potential to improve B 0 field homogeneity even further. These findings are encouraging towards increasing the availability of MR imaging technology globally using affordable low-field MR systems.

DATA AVAILABILITY STATEMENT
The raw data supporting the conclusions of this article will be made available by the authors, without undue reservation.

AUTHOR CONTRIBUTIONS
KW and LW contributed to conception and design of the study. KW, HA, and LW constructed the magnet. KW, HA, BS, and LW performed the measurements. KW and TO implemented the genetic algorithm. KW and LR implemented the spherical harmonics approach. KW and LW wrote the manuscript. All authors contributed to manuscript revision, read, and approved the submitted version.