## 2 Materials and Methods
### Workflow  
Once the (N \(\times\) M) \(\times\) 13 input matrix has been built, the first step is to pre-process the input data by filtering the areas of the images from clouds or plumes. Thus, a binary mask is created in order to remove those pixels and then applied to the input matrix. To identify pixels belonging to the lava flow and pixels that do not, a classification method is used by exploiting the thermal information of the input data. Pixels with similar trends are grouped, creating representative clusters of the entire imaged area. In fact, the similarity of the pixels inside the same cluster reveals similar changes in time from pre- to post-eruptive images. Figure 2 shows an example of the different spectral reflectance trends of pixels belonging to two classes after the clustering stage. In particular, the 12 spectral components (4 pre- and 8 post reflectance) of the pixels belonging to a lava flow class (foreground-FG) and pixels belonging to a vegetation area (background-BG) are shown--upper and bottom, respectively. Generally speaking, pixels inside a cluster not belonging to the recent lava flow have similar spectral responses over the pre- and post-eruptive days, while pixels inside a cluster belonging to the lava flow have different spectral responses over the pre- and post-eruptive days due to the fact that their reflectance decreases [72]. These differences can be caught from remote sensors when images are acquired under the same conditions with negligible differences in the atmospheric and environmental conditions. As classification method, we used the k-medoids unsupervised clustering technique, which is applied to the pre-processed input data [77]. The k-medoids algorithm partitions data in groups to minimize the distance between points in each cluster and the pixel iteratively identified as the cluster center. Here, the correlation distance is adopted as a measure of similarity and is defined as one minus the sample correlation between points (treated as sequences of values). The number of clusters \(n\) is set a-priori after a trial and error procedure. Thus, each cluster will be made by highly correlated pixels resulting in a 2D map made by \(n\) clusters. The k-medoids map is built using only Sentinel 2-MSI images, without any knowledge about the real lava flow. At this point, pixels with similar trends are grouped together and consequently any pixel inside each cluster is overall representative of the cluster itself. Unfortunately, atmospheric and environmental conditions do not allow to uniquely classify each of the cluster as belonging or not to the lava flow. Snow, clouds, and shaded and bright areas prevent using the correlation distance as the only metrics  
Figure 2: Difference between background (BG) and foreground (FG) pixels spectral reflectance trends over pre- and post- MSI Sentinel-2 data. Trends of pixels belonging to a FG class (up) and trends of the pixels belonging to a BG class (down) are shown. Different colored lines correspond to the pixels belonging to the FG class (up) and BG class (down). to classify newly lava flow pixels. For instance, under certain light conditions, older and newer lava flow pixels may manifest similar trends, thus belonging to the same cluster, although not belonging to the same class. This suggests that the relationship between the input data and the output requires a more complex modelling. As a consequence, a nonlinear BNN was designed to learn how to discriminate recent lava flow pixels from both the older lava flow and the background in non-ideal condition. The BNN requires a training dataset to learn the non-linear relationship among the input and target variables. To select a representative training dataset, three pixels for each of the \(n\) clusters have to be manually labelled to create the BNN input and target. In particular, some of the pixels characterized by clouds, snow or shaded area are given as training points.