Class imbalance should not throw you off balance: Choosing the right classifiers and performance metrics for brain decoding with imbalanced data
Thölke Philipp
;
MantillaRamos Yorguin Jose
;
Abdelhedi Hamza
;
Maschke Charlotte
;
Dehgan Arthur
;
Harel Yann
;
Kemtur Anirudha
;
Mekki Berrada Loubna
;
Sahraoui Myriam
;
Young Tammy
;
Bellemare Pépin Antoine
;
El Khantour Clara
;
Landry Mathieu
;
Pascarella Annalisa
;
Hadid Vanessa
;
Combrisson Etienne
;
O'Byrne Jordan
;
Jerbi Karim
Machine learning (ML) is increasingly used in cognitive, computational and clinical neuroscience. The reliable and efficient application of ML requires a sound understanding of its subtleties and limitations. Training ML models on datasets with imbalanced classes is a particularly common problem, and it can have severe consequences if not adequately addressed. With the neuroscience ML user in mind, this paper provides a didactic assessment of the class imbalance problem and illustrates its impact through systematic manipulation of data imbalance ratios in (i) simulated data and (ii) brain data recorded with electroencephalography (EEG), magnetoencephalography (MEG) and functional magnetic resonance imaging (fMRI). Our results illustrate how the widely-used Accuracy (Acc) metric, which measures the overall proportion of successful predictions, yields misleadingly high performances, as class imbalance increases. Because Acc weights the per-class ratios of correct predictions proportionally to class size, it largely disregards the performance on the minority class. A binary classification model that learns to systematically vote for the majority class will yield an artificially high decoding accuracy that directly reflects the imbalance between the two classes, rather than any genuine generalizable ability to discriminate between them. We show that other evaluation metrics such as the Area Under the Curve (AUC) of the Receiver Operating Characteristic (ROC), and the less common Balanced Accuracy (BAcc) metric - defined as the arithmetic mean between sensitivity and specificity, provide more reliable performance evaluations for imbalanced data. Our findings also highlight the robustness of Random Forest (RF), and the benefits of using stratified cross-validation and hyperprameter optimization to tackle data imbalance. Critically, for neuroscience ML applications that seek to minimize overall classification error, we recommend the routine use of BAcc, which in the specific case of balanced data is equivalent to using standard Acc, and readily extends to multi-class settings. Importantly, we present a list of recommendations for dealing with imbalanced data, as well as open-source code to allow the neuroscience community to replicate and extend our observations and explore alternative approaches to coping with imbalanced data.
We derive bounds on the Kolmogorov distance between the dis- tribution of a random functional of a {0, 1}-valued random sequence and the normal distribution. Our approach, which relies on the general framework of stochastic analysis for discrete-time normal martingales, extends existing results obtained for independent Bernoulli (or Rademacher) sequences. In particular, we obtain Kolmogorov distance bounds for the sum of normalized random sequences without any independence assumption.
Tuning Minimum-Norm regularization parameters for optimal MEG connectivity estimation
Vallarino Elisabetta
;
Hincapié Ana Sofia
;
Jerbi Karim
;
Leahy Richard M
;
Pascarella Annalisa
;
Sorrentino Alberto
;
Sommariva Sara
The accurate characterization of cortical functional connectivity from Magnetoencephalography (MEG) data remains a challenging problem due to the subjective nature of the analysis, which requires several decisions at each step of the analysis pipeline, such as the choice of a source estimation algorithm, a connectivity metric and a cortical parcellation, to name but a few. Recent studies have emphasized the importance of selecting the regularization parameter in minimum norm estimates with caution, as variations in its value can result in significant differences in connectivity estimates. In particular, the amount of regularization that is optimal for MEG source estimation can actually be suboptimal for coherence-based MEG connectivity analysis. In this study, we expand upon previous work by examining a broader range of commonly used connectivity metrics, including the imaginary part of coherence, corrected imaginary part of Phase Locking Value, and weighted Phase Lag Index, within a larger and more realistic simulation scenario. Our results show that the best estimate of connectivity is achieved using a regularization parameter that is 1 or 2 orders of magnitude smaller than the one that yields the best source estimation. This remarkable difference may imply that previous work assessing source-space connectivity using minimum-norm may have benefited from using less regularization, as this may have helped reduce false positives. Importantly, we provide the code for MEG data simulation and analysis, offering the research community a valuable open source tool for informed selections of the regularization parameter when using minimum-norm for source space connectivity analyses.
Functional connectivity
MEG
Minimum norm estimate
Regularization parameter
Surrogate data
The impact of ROI extraction method for MEG connectivity estimation: Practical recommendations for the study of resting state data.
Brkic Diandra
;
Sommariva Sara
;
Schuler Anna Lisa
;
Pascarella Annalisa
;
Belardinelli Paolo
;
Isabella Silvia L
;
Pino Giovanni Di
;
Zago Sara
;
Ferrazzi Giulio
;
Rasero Javier
;
Arcara Giorgio
;
Marinazzo Daniele
;
Pellegrino Giovanni
Magnetoencephalography and electroencephalography (M/EEG) seed-based connectivity analysis typically requires regions of interest (ROI)-based extraction of measures. M/EEG ROI-derived source activity can be treated in different ways. For instance, it is possible to average each ROI's time series prior to calculating connectivity measures. Alternatively one can compute connectivity maps for each element of the ROI, prior to dimensionality reduction to obtain a single map. The impact of these different strategies on connectivity estimation is still unclear. Here, we address this question within a large MEG resting state cohort (N=113) and simulated data. We consider 68 ROIs (Desikan-Kiliany atlas), two measures of connectivity (phase locking value-PLV, and its imaginary counterpart- ciPLV), and three frequency bands (theta 4-8 Hz, alpha 9-12 Hz, beta 15-30 Hz). We consider four extraction methods: (i) mean, or (ii) PCA of the activity within the ROI before computing connectivity, (iii) average, or (iv) maximum connectivity after computing connectivity for each element of the seed. Connectivity outputs from these extraction strategies are then compared with hierarchical clustering, followed by direct contrasts across extraction methods. Finally, the results are validated by using a set of realistic simulations. We show that ROI-based connectivity maps vary remarkably across strategies in both connectivity magnitude and spatial distribution. Dimensionality reduction procedures conducted after computing connectivity are more similar to each-other, while PCA before approach is the most dissimilar to other approaches. Although differences across methods are consistent across frequency bands, they are influenced by the connectivity metric and ROI size. Greater differences were observed for ciPLV than PLV, and in larger ROIs. Realistic simulations confirmed that after aggregation procedures are generally more accurate but have lower specificity (higher rate of false positive connections). Although computationally demanding, after dimensionality reduction strategies should be preferred when higher sensitivity is desired. Given the remarkable differences across aggregation procedures, caution is warranted in comparing results across studies applying different extraction methods.
The aim of this work was to characterize the palette and painting technique used for the realization of three late sixteenth century paintings from "Galleria dell'Accademia Nazionale di San Luca" in Rome attributed to Cavalier d'Arpino (Giuseppe Cesari), namely "Cattura di Cristo" (Inv. 158), "Autoritratto" (Inv. 546) and "Perseo e Andromeda" (Inv. 221). This study presents a diagnostic campaign that was carried out with non-invasive and portable techniques such as Energy Dispersive X-ray Fluorescence (ED-XRF) spectrometry, Fiber Optics Reflectance Spectroscopy (FORS) and Multispectral (MS) Imaging. This work was part of a project founded by Regione Lazio and MUR ("IMAGO - Multispectral Imaging for Art, Gamification and hOlografic reality" project). FORS and ED-XRF analyses allowed the preliminary characterization of the pictorial materials in a reliable non-invasive way. In particular, it was possible to identify most of the pigments used for the production of the paintings attributed to Cavalier d'Arpino. The MS images were acquired between the ultraviolet and the near-infrared regions of the electromagnetic spectrum (UV-Vis-NIR) by using different illumination sources and a cooled CCD camera equipped with interferential filters. It was possible to observe significant differences between the visible and the NIR images with some details of the paintings which resulted transparent in the infrared region. Furthermore, MS images were investigated in-depth by the application of data clustering algorithms to obtain semantic segmentation. This methodology exploits the information reported in MS images to generate a pixel classification based on statistical methods together with image analysis techniques. The result provides both an extrapolation of salient parts of the work as well as a better perception of some details. The combined results of this work allowed to investigate in-depth the production of one of the main painters from Italian mannerism.
Multispectral imaging
cultural heritage
spectroscopy
The IMAGO project aims to develop an innovative system that utilizes Multispectral Imaging and
Augmented Reality (AR) techniques for studying and preserving cultural heritage. By employing
machine learning algorithms on multispectral images, the system can detect lost original elements
and hidden features in cultural artifacts, offering a unique perspective beyond human vision.
Here we show some preliminary results related to the multi spectral analysis conducted on three
paintings attributed to Cavalier d'Arpino (Giuseppe Cesari) located at the Galleria dell'Accademia
Nazionale di San Luca in Rome. Non-invasive and portable techniques such as Energy Dispersive
X-ray Fluorescence (ED-XRF) spectrometry, Fiber Optics Reflectance Spectroscopy (FORS), UV
fluorescence imaging, and Multispectral (MS) imaging were employed. Preliminary characterization
of the pictorial materials was achieved through FORS and ED-XRF analyses, allowing the identi-
fication of pigments used for the creation of the three paintings and highlighting similarities and
differences in the palette.
MS images, acquired between the ultraviolet and near-infrared regions (NIR), revealed significant
differences between visible and NIR images with some details of the paintings transparent in the
infrared region. Furthermore, data clustering algorithms were applied to the MS images, enabling
semantic segmentation and providing extrapolation of salient parts of the artwork and better per-
ception of details.
The combined results of this work contribute to the preservation and interpretation of cultural
heritage and are of paramount importance for the developing of the IMAGO system
multispectral imaging
cultural heritage
spectroscopy
clustering
Estimates networks of conditional dependencies (Gaussian graphical models) from multiple classes of data (similar but not exactly, i.e. measurements on different equipment, in different locations or for various sub-types). Package also allows to generate simulation data and evaluate the performance. Implementation of the method described in Angelini, De Canditiis and Plaksienko (2022)
Type 2 diabetes mellitus (T2D), the most common form of diabetes, is a chronic metabolic disorder characterized by hyperglycemia, insulin resistance, and insulin deficiency. Although genetic predisposition determines in part the susceptibility to T2D, an unhealthy diet and a sedentary lifestyle are commonly recognised as essential drivers for the onset of the disease. Indeed, considerable evidence suggests that regular exercise and appropriate nutrition bring undeniable health benefits by reducing the risk of developing T2D or delaying its onset. The literature dealing with mathematical modelling for diabetes is abundant and in the view of a growing more personalized medicine the benefits of having tools to represent different virtual patient populations are clear. In this study, we describe a multi-scale computational model of the human metabolic and inflammatory status that is determined by individual dietary and activity habits. It includes a description of the immune activation and inflammation, a model for the food intake, stomach emptying and gut absorption of all three macronutrients (proteins, carbohydrates, fats), a component to account for the effects of physical activity on the hormones' regulation and the inflammatory state of the individual, and finally, a characterization of energy intake-expenditure balance. All these pieces are merged into a single integrated simulation tool to provide a helpful aid that can be used proactively to prevent the onset of the disease. Moreover, this model turns out to help design virtual cohorts of patients to conduct in silico studies.
Type 2 diabetes
agent-based model
ordinary differential equation
personalised medicine
computational model
Starting from 2019, the Italian Space Agency (ASI) is supporting dedicated projects for the development of new methods, tools and competences for the interpretation and the exploitation of the future measurements of the FORUM (Far-infrared Outgoing Radiation Understanding and Monitoring) experiment.
FORUM will be the ninth Earth Explorer mission of the European Space Agency, scheduled for launch on a polar orbiting satellite in 2027. The core instrument of the mission will be a Fourier Transform Spectrometer with spectral range extending down to the Far-InfraRed (FIR), from 100 to 1600 cm-1 (from 100 to 6.25 microns in wavelength), thus covering the whole Earth's outgoing longwave radiation spectrum.
FORUM will fly in loose formation with the MetOp-SG-A satellite, hosting the Infrared Atmospheric Sounding Interferometer - New Generation (IASI-NG). The Middle-InfraRed (MIR) range (645 to 2760 cm-1) of the upwelling atmospheric spectrum measured by IASI-NG will effectively complement the FORUM measurement. All together, the two missions will provide matching spectral radiance measurements with unprecedented coverage, from 100 to 2760 cm-1.
While the FIR part of the spectrum (100-667 cm-1) measured by FORUM is the most sensitive to the water vapour content in the UTLS and to ice cloud properties, the atmospheric windows in the MIR are measured by IASI-NG with a very high signal-to-noise ratio, thus supplying very precise information on the surface temperature and on the temperature profile, which are essential to constrain the retrieval of the other geophysical parameters.
To get ready for the exploitation of the synergistic FORUM and IASI-NG measurements, in the frame of the mentioned ASI projects a Bayesian retrieval algorithm with the capability to perform the simultaneous inversion of two different synergistic spectral radiance measurements was developed. The tool is named FAst Retrieval Model (FARM) as it is based on a fast monochromatic and parametrized radiative transfer model (?-IASI) which is also being further extended and refined within the same projects. FARM includes the capability to retrieve simultaneously both atmospheric and cloud parameters. Furthermore, the code can handle both air/space- borne nadir measurements and ground- based zenith measurements.
In this work, we introduce the functionalities of the developed algorithm and present the results of the self-consistency and verification tests. The preliminary results of the inversion of some existing real measurements are also discussed.
A new, highly parallelized, adaptive mesh refinement (AMR) library, equipped with an accurate immersed boundary (IB) method for solving the compressible Navier-Stokes system is presented. The library, named ADAM, is designed to efficiently exploit modern exascale GPU-accelerated supercomputers and it is implemented with a highly modular structure in order to make easy to leverage it for a wide range of CFD applications. The structured Cartesian grids at the basis of (octree) AMR approach allows to implement very high order accurate models retaining a low computational cost and high level of parallelization. The accurate IB method coupled with efficient AMR technique enables the simulation flows with complex (possibly moving and deforming) geometries. The library is applied to the simulation of a strong shock diffraction over a solid sphere and a detailed discussion concerning the physical results and the parallel performance obtained is presented.
This paper concerns the study of a non-smooth logistic regression function. The focus is on a high-dimensional binary response case by penalizing the decomposition of the unknown logit regression function on a wavelet basis of functions evaluated on the sampling design. Sample sizes are arbitrary (not necessarily dyadic) and we consider general designs. We study separable wavelet estimators, exploiting sparsity of wavelet decompositions for signals belonging to homogeneous Besov spaces, and using efficient iterative proximal gradient descent algorithms. We also discuss a level by level block wavelet penalization technique, leading to a type of regularization in multiple logistic regression with grouped predictors. Theoretical and numerical properties of the proposed estimators are investigated. A simulation study examines the empirical performance of the proposed procedures, and real data applications demonstrate their effectiveness.
Surface and vegetation monitoring is a key activity in analyzing and understanding how climate change is impacting natural resources. Moreover, identifying vegetation stress using remote-sensed data has proven to be essential in assessing said understanding, as well as in the effort to prevent or act upon extreme phenomena, such as premature land and forest dryness due to summer heatwaves in the Mediterranean area. Typically used satellite indices for this purpose are the well-known NDVI, followed by Leaf Area Index (LAI) and Surface Soil Moisture (ssm), together with physical parameters such as surface and air temperature close to the surface (the latter retrieved by both remote-sensed data and in situ measurements). However, it is a known fact that NDVI is not able to differentiate between barren soil and suffering vegetation, while surface temperature and air temperature correlate poorly with soil moisture. The analysis carried out in this paper is aimed at proving the effectiveness of two newly designed thermodynamical indices, ECI and wdi, in assessing vegetation stress and woodland degradation in southern Italy between 2014 and 2022. ECI is based on infrared surface emissivity, which is closely related to land cover, while wdi directly measures surface water loss. Said indices have been estimated from both ECMWF operational analysis and IASI L2 data, the latter upscaled and remapped on a regular grid using an optimal interpolation scheme. Moreover, a comparison with other traditional indices is presented, further validating the applied methodology.
climate change
surface dryness
water deficit index
emissivity contrast index
infrared observations
remote sensing
surface temperature
dew point temperature
Exploiting the Infrared Atmospheric Sounder Interferometer (IASI) profiling capability for surface parameters, atmospheric temperature, and water vapour we have designed a new Water Deficit Index (wdi) to monitor drought and heatwaves. Because of climate change at a global level, drought is becoming a strong emergency also in countries which never experienced it, such as the Mediterranean mid-latitude area and, in particular, Italy. The last two years strongly affected the northern part of Italy, i.e. the Po Valley, causing high vegetation and soil water stress. Satellite data can provide a large spatial coverage (locally and globally) as well as a continuous data supply and are an important help to ground monitoring stations, especially in remote regions with dense vegetation. In this paper, we used the wdi to investigate the 2022 intense drought over the Po Valley region. We integrated the study considering both the Surface Soil Moisture (SSM) from Copernicus Sentinel-1 C-SAR and the Normalized Difference Moisture Index (NDMI) from Sentinel-2 images. We also considered the Fractional Vegetation Cover (FVC), the Fraction of Absorbed Photosynthetically Active Radiation (FAPAR) and the Leaf Area Index (LAI) data from the Drought & Vegetation Data Cube (D&V Data Cube) from the European Organization for the Exploitation of Meteorological Satellites - Satellite Application Facilities (EUMETSAT SAFs). Overall, we found that the wdi compares well to other indices related to vegetation stress and can be used as a tool for risk assessment of forest fires and agriculture productivity.
Infrared radiative transfer
Vegetation and soil water stress
Drought
IASI
Surface Temperature
Dew point temperature
SSM
NDMI
2023Poster in Atti di convegnometadata only access
Role of diagnostic tests in the decision to perform the oral food challenge test
Pignataro E
;
Brindisi G
;
Oliviero F
;
Mondì F
;
Martinelli I
;
De Canditiis D
;
Cinicola B
;
Capponi M
;
Gori A
;
Zicari AM
;
De Castro G
;
De Castro M
;
Anania C
Background: The oral food challenge test (OFC) represents the gold standard for the diagnosis of food allergy (FA). It is also necessary for the safe
reintroduction of the allergen into the diet of the patient. However, it is burdened with serious side effects. We aimed to determine the role of Skin
Prick Tests (SPT) and of component resolved diagnosis (CRD) in the decision to perform OFC in patients aged between 0 and 18 years with FA towards tree
nuts, peanuts and seeds.
Material and Methods: We enrolled 22 patients (mean age of 10.91±4.22 years; 12 males) with a diagnosis of FA towards nuts, peanuts and seeds. A total of 29
OFCs were performed (6 of these patients were tested for more than one allergen at different times) with the following allergens: peanut, hazelnut,
walnut, almond, pistachio and sesame. For each patient, were performed SPT and IgE levels through CRDs towards the culprit allergens (ImmunoCAP). In
particular, for the first two variables we considered the diameter of the wheels for the allergen tested for OFC (Prick-OFC) and the mean diameter of the wheals
for the other untested allergens (Prick-non OFC). For the other two variables, we focused on the IgE towards the CRDs characterizing the allergens of which they
were diagnosed and tested at the OFC (CRD-OFC) and the two most cross-reactive CRDs with the first chosen CRD (CRD-cross). We conducted an
inferential statistical analysis with the aim of answering the question: is it possible to predict OFC outcome using the values of the four covariates CRD-
OFC, CRD-cross, Prick-OFC and Prick-non OFC? The discriminative power of each of the four covariates was first analyzed independently of the others, by
performing a T-test on the two groups for each of them (Y=1, OFC positive result and Y=0, OFC negative result), figure 1.
Results: The most indicative variables of a possible positive reaction to OFC are the values of the CRD-cross (p =0.01957) and of the Prick-OFC (p=0.046936),
while the prick-non OFC (p=0.30857) and CRD-OFC(P=0.24193) variables do not seem to have discriminatory power. Multivariate logistic regression analysis
indicates that none of the four variables considered is statistically predictive of test result.
Conclusions: These results are unable to quantify the likelihood that a patient will have a positive OFC based on their SPT and IgE assays. However, we can
qualitatively say what to expect by considering its CRD-cross and Prick-OFC values rather than those of CRD-OFC and Prick-non OFC.
Exploiting the Abstract Calculus Pattern for the Integration of Ordinary Differential Equations for Dynamics Systems: An Object-Oriented Programming Approach in Modern Fortran
This manuscript relates to the exploiting of the abstract calculus pattern (ACP) for the (numerical) solution of ordinary differential equation (ODEs) systems, which are ubiquitous mathematical formulations of many physical (dynamical) phenomena. We present FOODIE, a software suite aimed to numerically solve ODE problems by means of a clear, concise, and efficient abstract interface. The results presented prove manifold findings, in particular that our ACP approach enables ease of code development, clearness and robustness, maximization of code re-usability, and conciseness comparable with computer algebra system (CAS) programming (interpreted) but with the computational performance of compiled programming. The proposed programming model is also proven to be agnostic with respect to the parallel paradigm of the computational architecture: the results show that FOODIE applications have good speedup with both shared (OpenMP) and distributed (MPI, CAF) memory architectures. The present paper is the first announcement of the FOODIE project: the current implementation is extensively discussed, and its capabilities are proved by means of tests and examples.
A technical characterization of APTs by leveraging public resources
Gonzaez-Manzano, Lorena
;
de Fuentes, Josè M.
;
Lombardi, Flavio
;
Ramos, Cristina
Advanced persistent threats (APTs) have rocketed over the last years. Unfortunately, their technical characterization is incomplete--it is still unclear if they are advanced usages of regular malware or a different form of malware. This is key to develop an effective cyberdefense. To address this issue, in this paper we analyze the techniques and tactics at stake for both regular and APT-linked malware. To enable reproducibility, our approach leverages only publicly available datasets and analysis tools. Our study involves 11,651 regular malware and 4686 APT-linked ones. Results show that both sets are not only statistically different, but can be automatically classified with F1 > 0.8 in most cases. Indeed, 8 tactics reach F1 > 0.9. Beyond the differences in techniques and tactics, our analysis shows thats actors behind APTs exhibit higher technical competence than those from non-APT malwares.
Advanced persistent threat; APTs; Malware; MITRE ATT and CK
SRv6 can provide hybrid cooperation between a centralized network controller and network nodes. IPv6 routers maintainmulti-hop ECMP-aware segments, whereas the controller establishes a source-routed path through the network. Since thestate of the flow is defined at the ingress to the network and then is contained in a specific packet header, called SegmentRouting Header (SRH), the importance of such a header itself is vital. Motivated by the need to study and investigate thistechnology, this paper discusses some security-related issues of Segment Routing. A SRv6 capable experimental testbed is built and detailed. Finally, an experimental test campaign is performed and results are evaluated and discussed.
IntroductionThe aim of the study is to understand the evolution of COVID-19 vaccine acceptance over the key 7-month vaccine campaign in Italy, a period in which the country moved from candidate vaccines to products administered to the public. The research focus points to evaluate COVID-19 vaccine attitudes in adults and their children, propension towards compulsory vaccination, past and present adherence to anti-flu and anti-pneumococcal vaccines, and the reasons for trust/mistrust of vaccines.MethodsItalian residents aged 16->65 years were invited to complete an online survey from September 2020 to April 2021. The survey contained 13 questions: 3 on demographic data; 8 on vaccine attitudes; and 2 open-ended questions about the reasons of vaccine confidence/refusal. A preliminary word frequency analysis has been conducted, as well as a statistical bivariate analysis.ResultsOf 21.537 participants, the confidence of those in favor of the COVID-19 vaccine increases of 50 % and the number of people who wanted more information decreases by two-third. Willingness to vaccinate their children against COVID-19 also increased from 51 % to 66.5 %. Only one-third of the strong vaccine-hesitant participants, i.e. 10 %, remained hostile. Compulsory vaccination showed a large and increasing favor by participants up to 78 %, in a way similar to their propensity for children's mandatory vaccination (70.6 %). Respondents' past and present adherence to anti-flu and anti-pneumococcal vaccines does not predict their intentions to vaccinate against COVID-19. Finally, a semantic analysis of the reasons of acceptance/refusal of COVID-19 vaccination suggests a complex decision-making process revealed by the participants' use of common words in pro-and-cons arguments.ConclusionThe heterogeneity in the COVID-19 vaccine hesitancy, determinants and opinions detected at different ages, genders and pandemic phases suggests that health authorities should avoid one-size-fits-all vaccination campaigns. The results emphasize the long-term importance of reinforcing vaccine information, communication and education needs.
Preservation of the angle of reflection when an internal gravity wave hits a sloping boundary generates a focusing mechanism if the angle between the direction of propagation of the incident wave and the horizontal is close to the slope inclination (near-critical reflection). This paper provides an explicit description of the leading approximation of the unique Leray solution to the near-critical reflection of internal waves from a slope in the form of a beam wave. More precisely, our beam wave approach allows to construct a fully consistent and Lyapunov stable approximate solution, L2-close to the Leray solution, in the form of a beam wave, within a certain (nonlinear) time-scale. To the best of our knowledge, this is the first result where a mathematical study of internal waves in terms of spatially localized beam waves is performed.A beam wave is a linear superposition of rapidly oscillating plane waves, where the high frequency of oscillation is proportional to the inverse of a power of the small parameter measuring the weak amplitude of waves.Being localized in the physical space thanks to rapid oscilla- tions (and high variations of the modulus of the wavenumber), beams are physically more relevant than plane waves/packets of waves, whose wavenumber is nearly fixed (microlocalized). At the mathematical level, this marks a strong difference between the previous plane waves/packets of waves analysis and our approach.The main novelty of this work is to exploit the spatial localization of beam waves to exhibit a spatially localized, physically relevant solution and to improve the previous mathematical results from a twofold perspective: 1) our beam wave approximate solution is the sum of a finite number of terms, each of them is a consistent solution to the system and there is no artificial/non-physical corrector; 2) thanks to the absence of artificial correctors (used in the previous results) and to the special structure of the nonlinear term, we can push the expansion of our solution to next orders, so improving the accuracy and enlarging the consistency time-scale.Finally, our results provide a set of initial conditions localized on rays, for which the Leray solution maintains approximately in L2 the same localization.