## 3 Method
### Optimization Algorithm and Implementation  
The task of optimization is described by the following formula,  
\[P=\arg\min\sum_{x,y,z\in M}\left(X\left(x,y,z\right)\ -\sum_{i=1}^{N}f_{i}(x,y,z,p_{i}) \right)^{2}, \tag{11}\]  
where \(P\) is the matrix of parameters, \(p_{i}\) is the vector of parameters, and \(f_{i}\) a set of Multivariate Generalized Gaussian Function Mixture functions and \(X\) is measured volume. MSE (Mean Squared Error) is reduced using this formula. There are 11 of parameters for single \(i\). There are 33 unknown parameters for this model (\(11\cdot N\)). A previous work [31] was based on mean absolute error (MAE).  
Different optimization algorithms are available and for this project PSO was selected [48], as it is a derivative-free optimization algorithm. The main task of optimization algorithm is the separation of maxima.  
Random walk based algorithm, proposed in [31], allows the estimation of parameters, but convergence is slow. Random walk algorithm could be considered as a single particle algorithm. The application of multiple particles in PSO provides the possibility of testing a volumetric region at one iteration step with the interactions between particles (swarm behavior), which is promising for global minimum search.  
The optimization process uses a single CPU (Central Processing Unit) core. The matrix algebra applied for the synthesis of the volume uses Armadillo library [49]. PSO code [50] was modified for the application of constrained optimization and there are two types of constraints that should be applied for particular parameters:  
* selected by range and
* folded with range.  
The considered model requires both approaches, and there are 8 regular range constraints and 3 folded range constraints.  
Folded range constraints are related to angles only. The application of regular range constraints for angles leads to a few times slower convergence due to the problem of orientation switching near 0 (360) region. Folding allows the smooth transition in 0 (360) degree value region. All ranges are presented in Table 2.  
Where \(B\) is the side of volume (\(B=32\)). Centers of functions are not placed near volume boundaries, because such cases are related to wrong selection of VOIs. Angles folding could be further reduced to the 0 to 180 range due to rotational symmetry of ellipsoid. The value range for \(\beta\) prefers Laplace function and it was intentionally selected, because peak is observed in real measurement.  
Random selection of parameters could lead to degenerate cases with two overlapped functions with \(i\) and \(j\) indexes, if their position is too close: \((m_{x}^{i}\approx m_{x}^{j})\wedge(m_{y}^{i}\approx m_{y}^{j})\wedge(m_{z}^{i }\approx m_{z}^{j})\). So as to prevent generation of such cases, as they are are impossible to solve, testing of minimal positional distance for each pair of functions was performed. The minimal Euclidean distance 3 was obtained by checking of numerous real SPECT volumes.  
Original PSO code uses normalized range values (0-1) and the denormalization of values of \(p\) vector is required according to Table 2 during the volume synthesis.  
Three types of topology are supported in PSO implementation: global best, ring, and random neighborhood [50]. Additional parameters specific to topologies are also available in source code [50].