It is often the case that one has to deal with multidimensional datasets, where each pixel has to be fitted individually. Unfortunately, for most uses, non-linear fitting routines have to be employed, which are extremely sensitive to starting conditions, and may fall into local extrema that do not represent a good fit. When the dataset is not uniform, the user has to manually specify starting parameters for each pixel, and with an increasing number of dimensions and data, it becomes extremely time-consuming, impractical, and, eventually, impossible.
Here we present a new adaptive multidimensional fitting algorithm, that we have written in Python and contributed to HyperSpy. All number-crunching is done using Scipy and Numpy, whereas the actual fitting is distributed over available CPU cores. For most datasets the algorithm provides a solution with minimal user input. If, however, the out-of-the-box strategy is not sufficient, the user can combine various strategies and triggers for them from in-built collections, or easily write his own, to develop a fitting routine as sophisticated as required for the particular problem. This freedom then enables tackling a broad spectrum of problems that were previously not possible to solve using standard fitting procedures.
The method was developed to enable the analysis by curve fitting of surface plasmon excitations in electron energy-loss tilt-series in the field of electron microscopy. However, we believe that it can be employed in a number of other fields that deal with multidimensional datasets such as astrophysics, high-energy particle physics, etc.
 Nicoletti, O. et al. Three-dimensional imaging of localized surface plasmon resonances of metal nanoparticles. Nature 502, 804 (2013).