## 2 Materials and Methods
### Adversarial Neural Network for Embedded Data Harmonization and Classification  
We proposed a different approach to the analytical harmonization by developing a DNN model specifically designed to perform a classification unbiased by site-related features.  
The construction of this network, which is schematically represented in Figure 2 and referred to as ad-DNN, obtains its main idea from the network proposed by [PERSON] et al. [11]. We replicated the structure of their model, which consists of three parts. A feature extractor branch takes input data and creates an inner representation of them within its structure; we modeled this part as dependent on parameters \(\theta_{f}\), which represent the weights of all the connections between neurons. The network is then forked into two branches: a label classifier branch for control vs. ASD classification, dependent on parameters \(\theta_{y}\) and with an associated loss function \(L_{y}\), and a site classifier branch aimed for site classification, which is dependent on parameters \(\theta_{d}\) and is associated to a loss function \(L_{d}\). The optimization of the overall loss function \(E(\theta_{f},\theta_{y},\theta_{d})\) will then depend on all the parameters constituting the network because it can be written as:  
\[E(\theta_{f},\theta_{y},\theta_{d})=L_{y}(\theta_{f},\theta_{y})-\lambda L_{d }(\theta_{f},\theta_{d}). \tag{4}\]  
In the training phase of this particular network, parameters are updated in order to obtain a minimization of the loss function \(E(\theta_{f},\theta_{y},\theta_{d})\) with respect to parameters \(\theta_{f}\) and \(\theta_{y}\), and a maximization of it with respect to \(\theta_{d}\); in other words, one seeks for a saddle point given by:  
\[\begin{split}\hat{\theta}_{f},\hat{\theta}_{y}&= \underset{\hat{\theta}_{f},\theta_{y}}{argmin}E(\theta_{f},\theta_{y},\theta_{ d})\\ \hat{\theta}_{d}&=\underset{\theta_{d}}{argmax}E( \theta_{f},\theta_{y},\theta_{d}).\end{split} \tag{5}\]  
If compared to the approach described in [11], our model presents a substantial difference in the structure of the domain-classifier branch. Unlike their work, which only concerns 2 domains, our model has to deal with 36 sites because, as described in Section 2.1, data from the ABIDE datasets are collected from 36 medical centers.  
The structure of the ad-DNN adversarial network, which is depicted in Figure 3, is similar to the one of DNN described in the previous section but, whereas the DNN ends with a single-neuron output layer, the adversarial network is split at this point into the label classifier layer consisting of a single neuron, and the site classifier branch. At the beginning of the site classifier, the gradient reversal layer is placed, linked to a dense layer with 16 neurons, batch normalization and the final output dense layer consisting of 36 neurons as the number of sites. To restrain overfitting, this configuration was obtained after different attempts to create a model that gives the maximum reachable performances with the minimum number of parameters. These results, as in the previous analysis, are reported as the mean AUC scores across all the folds in a 5-fold CV scheme.  
Figure 2: Schematic representation of the ad-DNN adversarial network employed in this work for ASD vs. TD classification, and the main gradients that play a relevant role in the weight update. The neural network layers are pictured as bars whose length is representative of the number of neurons in each layer. The green bars constitute the feature extractor branch, which forks into the label classifier branch (a single-output neuron) in blue, and the site classifier in pink, consisting of a hidden layer and a multiple-output layer. The main gradients are highlighted with a color matching the section of the network that they operate on.