# Comparison of Algorithms to Compute Relaxation Time Maps in Magnetic Resonance Imaging
## 2 Materials and Methods
**Processing:** Before fitting, a region of interest (ROI) was selected in the image. Only pixels inside the ROI were fitted. Furthermore, the pixels in which the T\({}_{\rm rel}\) value obtained in the fit was not in a suitable range were discarded. The range chosen was 100-3000 ms for T1 and 10-500 ms for T2. This range is arbitrary, but it seems appropriate to contain meaningful values. The RD-NLS algorithm was programmed in C# (Microsoft Corporation, Redmond, WA, USA). It was tested in a MacBook Air (Apple, Cupertino, CA, USA) laptop with an Intel i5 processor (Intel, Santa Clara, CA, USA) clocked at 1.60 GHz and 8 GB of RAM. The process of analyzing murine, simulated human brain, and phantom image data for this study involved using multiple software and algorithms. First, Bruker software Paravision 6.0.1-Image Sequence Analysis (ISA) Tool (Bruker BioSpin Group, Bruker Corporation, Ettlingen, Germany) was used. This specialized software was used to fit the murine image data to Model I and the phantom image data to Model III on a pixel-by-pixel basis. In addition, three different algorithms were implemented using Matlab (MATLAB Release 2017b, The MathWorks, Inc., Natick, MA, USA). These algorithms were the Levenberg-Marquardt algorithm implemented using the \"fitnlm\" function, a Nelder-Mead algorithm implemented using the \"fminsearch\" function, and a partially linearized algorithm in which linear and nonlinear variables are split, which is implemented using \"lsqcurvefit\". Initial values for the parameters were the same for the three algorithms (where applicable) and can be seen in Supporting Tables S1-S3. Using Matlab and the three algorithms mentioned before, mouse image data, simulated human brain image data, and phantom image data were fitted to Models I, II, and III on a pixel-by-pixel basis. Furthermore, using the RD-NLS algorithm, mouse image data, simulated human brain image data, and phantom image data were also fitted to Models I, II, and III on a pixel-by-pixel basis. The resulting fit from the RD-NLS algorithm was then compared to the fits obtained using ISA and Matlab. All tests were summarized in Table 2, which provided a comprehensive overview of the results obtained from the different software and algorithms used in the study. After fitting, the error was calculated as the sum of the squares of predicted and measured signal differences for each pixel. Then, the following statistics were compiled for each comparison. The name \(\varepsilon_{\rm a}\) refers to the error of the RD-NLS algorithm and \(\varepsilon_{\rm b}\) to which it is compared. * Multiple minima: number of pixels (as a percentage of total pixels) for which the fitting error as a function of Trel after linear parameters have been fitted shows more than one local minimum. * Pixels: The number of pixels (as a percentage of total pixels), for which the Trel difference between the two fits is above a threshold and \(\varepsilon_{\mathrm{a}}\times\varepsilon_{\mathrm{b}}\). No pixels for which the Trel difference between the two fits is above the threshold and \(\varepsilon_{\mathrm{a}}>\varepsilon_{\mathrm{b}}\) or \(\varepsilon_{\mathrm{a}}=\varepsilon_{\mathrm{b}}\) were found. Therefore, the remaining pixels (up to 100%) are pixels for which the Trel difference between the two fits is below the threshold. The threshold exists because if it did not exist, it could be possible to conclude that the same solution is two different solutions due only to rounding errors. The threshold must be small enough not to allow two different minima to be confused. For these reasons, it was set arbitrarily as 1 ms.
* Relaxation time: Average Trel value given by fit a (the RD-NLS algorithm) and fit b (the algorithm it is compared to). Bland-Altman plots [29] were drawn to compare Trel, given by fit a, and Trel, provided by fit b. Comparison is (Trel fit b--Trel fit a) vs. average. Each point in the plot represents the average Trel of 100 randomly selected pixels. Averaging was performed to decrease plot dispersion.