dataesr/scientific-paragraphs-categorization huggingface dataset:
We apply this protocol in three different situations: two biting simulations (unilateral and bilateral) and a shoulder flexion simulation. 3. We demonstrate how to prepare the mesh, delineate the muscle origins and insertions, define the constraints, adjust material properties, choose a loading scenario (uniform, tangential or tangential-plus-normal), and extract the results. 4. Our automated script meshes the 3D model, defines the constraints and distributes muscle forces within a single simulation software: 'Metafor' (nonlinear solver, owned and distributed by Gesval S. A) or 'Fossils' (a new open-source linear static solver developed in the frame of this work). 'Metafor' and 'Fossils' can perform the entire protocol (from the meshing to the muscle-induced simulations) on high-resolution volumetric meshes (millions of tetrahedra) and rapidly, exceeding the processing time of other widely used software protocols by up to four times.
, 2019) , or load vectors  (Zhou et al. , 2019) ; this overcomes the practical limitation that muscle is an extremely complex structure to model. Few protocols are available to realistically simulate the wrapping of muscle fibres other than the BONELOAD MATLAB routine, initially developed by  Grosse et al. (2007) , which allows the modelling of muscle-induced forces onto skeletal structures. This script exports Nastran files which can be read by a variety of FEA software, such as Strand7 (Strand7 Pty Ltd). The entire process can therefore be cumbersome, involving multiple software in a strict and repetitive sequence. Here, we describe and demonstrate a new FEA protocol focussing on the biomechanical analysis of bone (and its mechanical behaviour under muscular load). This protocol is implemented in a new, freely available, open-source linear static solver ('Fossils') and in 'Metafor', a simulation software developed at the University of Liège (Belgium).
'Metafor' has previously been applied to biomechanical questions such as orthodontics  (Mengoni et al. , 2016) , validation tests in subject-specific FE models  (Laurent et al. , 2016)  and applied veterinary orthopaedics  (Laurent et al. , 2020). We developed a series of routines in 'Fossils' and 'Metafor' to run muscle-driven FE analyses in which three muscle loading scenarios are implemented utilising those already available in the BONELOAD MATLAB routine: (1) a uniform traction load model, (  2.
| Preparation of the mesh Surface meshes can be obtained using various methods: photogrammetry, surface scanning (laser or structured light) and CT scanning. The image sequence of the leopard mandible was downloaded from MorphoSource (Media 000009046); image stacks were imported in Avizo lite 2020  (Thermo Fisher Scientific, United States)  and the regions of interest were segmented and exported in STL (STereoLithography) format. The mosasaurid mandible was obtained from a Creaform HandyScan 300 laser scanner (0. 2 mm resolution) and exported as a PLY file from the VX models software (Creaform, United States). The mesh of the tapir scapula and humerus was obtained using a Faro ScanArm Platinum V2 system with integrated Faro Laser Line probe, and exported as PLY files from Geomagic Qualify v.
Models must be oriented to easily define the constraints along the x, y, z axes; the orientation will depend on the movement studied (see axes drawn of Figure  1 ). 'Metafor' can call various meshing software (e. g. Tetgen, Gmsh, Samcef) to produce solid meshes; in our example, we called Gmsh  (Geuzaine & Remacle (2009)  Figure  1 ). [Correction added on 19 January 2023, after first online publication: Citation to Geuzaine & Ramacle added here and to Reference list. ] 'Fossils' is internally based on Gmsh for the meshing, calculation and result visualisation; it can thus be considered as an extension to Gmsh. The Gmsh meshing algorithm is quite tolerant with the details of the surface mesh, allowing conversion of surface meshes composed of millions of triangles into solid mesh files. It can handle 'stereolithography' (STL), Wavefront (OBJ) or a 'Polygon File Format' (PLY) (ASCII or binary) files.
Any software capable of creating a 3D object based on a selection, and to estimate the geometric centroid of an object surface, could be used for these steps. Figure  S2  shows an example of muscle surface delineation with our three specimens, using Geomagic Wrap 2020 (3D Systems, United States) for the leopard and the mosasaurid, and using Blender (Blender Foundation, The Netherlands) for the tapir. Boundary conditions must now be defined, which will depend on the scenario being tested. Boundary conditions are defined as xyz coordinates of precise surface nodes. In the given examples, the leopard model was constrained by three degrees of freedom (xyz) on the biting point, and we allowed lateral translation at both jaw articulations (temporomandibular joints; TMJs), constrained in yand z-axes only (see Figure  1  for a graphical representation of the constraints); the mosasaurid mandible boundary conditions were constrained by three degrees of freedom (no xyz translations) at the jaw articulation (quadratomandibular joint), and by one degree of freedom (z, dorsoventral axis only) at the biting point.
| Loading The STL files of each muscle insertion should now be called in the   [281. 827445, 30. 054466, 237. 947288] , and finally the loading scenario ('method'). Loading scenarios implementable in 'Metafor' and 'Fossils' can be defined to a uniform traction load model 'U', a tangential-traction load model 'T', and a tangential-plus-normaltraction load model 'T + N'. Figure  2  shows the repartition of forces on the 3D model of a cylinder under these different loading scenarios. In the uniform scenario (U), the force vectors go through the surface of the bone (Figure  2a  script 'loadbone. py' is based on the BONELOAD routine initially published by  Grosse et al. (2007). However, some changes were made to the BONELOAD routine to adjust the pressure magnitude and increase efficiency. In the simplest model-the Uniform-Traction model-the total traction force F applied by a muscle on the bone is uniformly distributed on the surface mesh of the muscle attachment.
| COMPARISON WITH OTHER PROTO CO L S We ran the same analysis on our three examples using 'Metafor', 'Fossils' and the widely used MATLAB/Strand7 to compare the meshing and model resolution times and the results obtained (see Table  1 ). Analyses in 'Metafor' and 'Fossils' were performed using an ASUS laptop Intel Core i5 -8300H, 2. 30GHz Quad Cores with 32 GB of RAM, whereas analyses in Strand7 were performed on a workstation Intel Xeon Silver 4208, 2. 10 Ghz Octa Core with 64 GB of RAM. To compare the different software on equal terms, we did not run the analyses in parallel as the Strand7 R2 version we used did not allow it (both 'Metafor' and 'Fossils' could handle parallel processing). Here we detail the durations obtained for the leopard mandible, the mosasaurid mandible and the tapir shoulder (detailed in Tables  1  and 2  and Figure 5 ).
An arbitrary number of layers can thus be easily and robustly treated, with continuous material gradients being a limiting case. Although this approach is often used in high frequency studies involving wave propagation, this is the first time that has been used for the induction problem arising in an eddy current inspection situation. The developed method is implemented in Matlab and is used to deal with the following problems: magnetic material with a hole, a magnetic cylinder, and a magnetic ring. In all the conducted tests, the results are obtained in a very short time, without missing a single eigenvalue.
Determination of the eigenvalues then boils down to finding complex roots of the appropriate complex function. Because of the oscillating nature of eigenfunctions, and overflow errors caused by local maxima of very large values, both complex plane search methods and the procedures available in numerical packages (such as fsolve in Matlab or FindRoot in Mathematica) are often not fully efficient at precisely determining all eigenvalues. At the same time, attempts to develop a reliable algorithm based on iterative methods, such as the Newton-Raphson method, have been unsuccessful so far, even with the employment of a very small step. More promising seems to be the approach based on Cauchy's argument principle  [33] [34] [35] [36] [37] [38] [39] [40]  the solution domain is divided into small parts where the roots are found with contour integration.
The developed solution can be used for a wide class of eddy current problem, in particular for those related to the detection of flaws and discontinuities in tested objects. Its speed and efficiency have been verified with the use of other root-finding algorithms, Because of the oscillating nature of eigenfunctions, and overflow errors caused by local maxima of very large values, both complex plane search methods and the procedures available in numerical packages (such as fsolve in Matlab or FindRoot in Mathematica) are often not fully efficient at precisely determining all eigenvalues. At the same time, attempts to develop a reliable algorithm based on iterative methods, such as the Newton-Raphson method, have been unsuccessful so far, even with the employment of a very small step. More promising seems to be the approach based on Cauchy's argument principle  [33] [34] [35] [36] [37] [38] [39] [40]  the solution domain is divided into small parts where the roots are found with contour integration.
Results and Discussion The developed solution is named the Sturm-Liouville global function (SLGF) method and is implemented in Matlab. Matrix eigenvalues calculations (7) are make using the command [V,D] = eigs(A,B,'sr'), with V representing the eigenvectors and D the set of eigenvalues (a matrix whose diagonal elements are equal to the eigenvalues squared). Since accuracy in the numerical computation is higher for the first eigenvalues, for N S eigenvalues, we use matrices with dimensions 4N S × 4N S. The eigenvalues determined in this way are verified with the multilevel computation of complex eigenvalues (MCCE) method  [39] , the Newton-Raphson method and the fsolve() procedure available in Matlab. The calculations consist in finding the Ns = 50 first eigenvalues for the sets of input data (Table  1 ) that correspond to different values of the parameters used in eddy current testing.
Characterization methods The surface roughness  [20]  and the wear loss of the samples were measured using an Altisurf 500 optical profilometer. The OCA series machine (Data Physics Model ESr-N, Germany) was used to measure the contact angle of a sessile drop of 0. 9 wt% NaCl solution with the surface of the studied samples. The nanohardness and the local elastic modulus measurements were performed using a Nanoindenter XP machine equipped with a Berkovich indentation tip. The average value of the hardness and the elastic modulus was taken between 500 nm and 780 nm of indentation depth, for the substrate, and between 100 nm and 280 nm for the GM coating. Five nanoindentation measurements were performed at each distance from the surface. The open porosity measurements were carried out via an in-house developed MATLAB routine.
Acknowledgments The authors gratefully acknowledge financial support from the  Region of Grand Est (France)  through the  CORR -FA project as well as from the  EPF Graduate School of Engineering. They also acknowledge the  FabAdd Platform of EPF Troyes  for manufacturing the samples. The ' Troyes Champagne Métropole ' and the  Aube Department Council (France)  are also acknowledged for their financial support of Markforged-Metal X System. Finally, the authors would like to thank the scientific and technical expertise provided by  Dr. Bruno Guelorget  and  Mr. Matthieu STRUB  for the nanoindentation measurements and sample preparation, respectively.
The issue of data imbalance  [11, 12]  is a perfect example of an important problem that is generally well understood in the field of data science, but not always properly appreciated and tackled in neuroscience and neuroimaging. This technical note provides (1) a didactic description of the pitfalls associated with using skewed datasets in supervised machine learning, (2) a detailed assessment of the impact of varying the degree of class imbalance on classifier models and their performance using synthetic and real data, (3) concrete recommendations for mitigating the adverse effects of imbalanced data, and  (4)  open-source code to replicate the present work and extend it to other methods and metrics. In binary classification problems, data imbalance occurs whenever the number of observations from one class (majority class) is higher than the number of observations from the other class (minority class)  [11, 12].
This problem is commonly encountered in cognitive neuroscience and in clinical applications, where observations for the target class (e. g. patients with neurological disorders) are often much harder to come by than for the control class (e. g. cognitively healthy individuals), leading to datasets with many more control observations than target observations  [13, 11]. Additional care has to be taken when evaluating the performance of diagnostic tests on rare conditions  [14]. What makes imbalanced data problematic? When faced with highly skewed data, a classifier can achieve a high decoding accuracy merely by systematically and blindly voting for the majority class  [11]. For example, if an image classifier is asked to discriminate pictures of crows versus ravens, 3 but only one out of twenty images in the training and test sets are ravens and the rest are crows, then the algorithm can (and likely will) achieve 95% accuracy simply by calling everything it sees a crow-though no discrimination or classification can rightly said to have been accomplished.
In this paper, we aim to provide a straightforward and practical demonstration of how the outcome of different machine learning performance metrics, classifiers and cross-validation schemes are impacted by various degrees of data imbalance, using simulated data and real electrophysiological recordings. More specifically, we examine the behavior of four prominent metrics (Accuracy (Acc), Area Under the ROC Curve (AUC), Balanced Accuracy (BAcc)  [22, 23] , and F1; Table  1 ) across four widely-used classifiers (Logistic Regression (LR)  [24] , Linear Discriminant Analysis (LDA)  [25] , Support Vector Machine (SVM)  [26] , and Random Forest (RF)  [27] ), as we gradually increment data imbalance. The topic of data imbalance, also often referred to as class or domain imbalance, has been addressed in previous work and online resources  [11, 21] , primarily within the computer science community.
Primary Analysis Pipeline The analysis pipeline was developed specifically for binary classification problems. Its primary purpose is to generate scores for different metrics across a range of imbalance ratios, using a list of classifiers and cross-validation schemes (Fig. 1c ). In order to estimate the chance level of correct classification, given the configuration of dataset and performance metric, the pipeline performs permutation tests  [28]  (repeatedly training and evaluating a classifier on the same dataset but with randomly permuted labels). Generating data-driven chance level is necessary because the theoretical binary classification chance level of 0. 5 could be incorrect when performing binary classification on a dataset which has imbalanced classes or a small sample size. Furthermore, different performance metrics can lead to different estimates of the chance level.
7 To simulate different amounts of imbalance in the class distribution we artificially limited the number of samples for both classes separately. We used a range of imbalance ratios from 0. 1 (9:1 balance between the two classes) to 0. 9 (1:9 balance) with 25 linearly spaced intermediate ratios, which provided a good trade-off between speed and performance. For a dataset with 100 data points (50 in either class), for example, we ran experiments with the following class distributions: 50:5, 50:7,. , 50:50,. , 7:50, 5:50. Imbalance was achieved by undersampling (dropping samples) either one of the two classes.
Secondary Analysis Additionally, we explored the effect of data imbalance as a function of 1) the selection of hyperparameters, 2) the size of the dataset, 3) the type of cross-validation, 4) the effect of a balanced hold-out test set and 5) the impact of class imbalance on statistical significance testing. To simplify our approach, we only performed analysis 2-5 using SVM with an RBF kernel and evaluated it using Acc. We chose SVM specifically because we expected this algorithm to display important effects of class imbalance on performance.
Effect of Hyperparameters To assess the putative effect of hyperparameters, we explored those that are expected to have a significant impact on the robustness of classifiers with respect to imbalanced data  [34]. We used synthetic data (section 2. 3) with 1000 samples and a distance of one between the two Gaussian distributions and evaluated the effect of the selected hyperparameters using Balanced Accuracy. This allows us to track improvements in robustness, which would manifest as a flatter curve of classification scores across imbalance ratios. We limited this experiment to hyperparameters implemented in scikit-learn as this is one of the most commonly used libraries. In contrast to LDA, Logistic Regression, SVM, and Random Forest all implement an automatic class-weighting algorithm to deal with imbalanced data, which can be enabled by setting the class_weight parameter to balanced.
Effect of Balanced Hold-out Set While so far all cross-validation splits came from the training data distribution, thereby replicating class imbalance, we also decided to explore the effects of training on an imbalanced dataset and performing validation on a balanced subset. Here, we trained an SVM on 1000 samples of synthetic data (Section 2. 3) with a distance of one between the means of both classes. The balanced hold-out set was created by taking a 10% split of the full dataset before artificially generating an imbalanced training set. This analysis aims at uncovering a potential performance bias when the train and test set have different class distribution, i. e. imbalanced and balanced respectively. Note that in this case, the Balanced Accuracy and Accuracy metrics are strictly equivalent as we are evaluating performance on a balanced hold-out set.
EEG Motor Movement/Imagery Dataset The publicly available EEG Motor Movement/Imagery Dataset  [35, 36]  consists of 64-channel EEG recordings of 109 subjects at 160Hz. While the dataset contains several tasks related to motor movement, only baseline resting-state runs were used, in this way creating a binary classification task between the eyes-open and eyes-closed conditions. Each recording has 1 minute of resting-state data which was segmented into 5-seconds epochs. As a result, 24 epochs per subject were extracted, half of them being eyes-closed and the others eyes-open. The effect of these conditions on neural oscillations is well studied, and consists of an increase in alpha power  in posterior regions of the brain during eyes closed  [37, 38] , compared to the eyes open condition. We computed alpha power (8-12Hz) from the power spectral density (PSD) obtained using the multi-taper method.
To restrict the features to the visual cortex, only parieto-occipital electrodes (17 out of the 64) were used. The total sample size of this dataset was 109 subjects × 2 conditions × 12 trials = 2616 samples. A second analysis was carried out on this dataset to study the relationship between electrode locations and performance scores along 3 different imbalance ratios (0. 1, 0. 5 and 0. 9). As topographic differences are the main focus of this experiment, the sensors were not constrained to be from parieto-occipital regions. Similarly, placing the emphasis on performance as a function of spatial location, single-channel, single-feature SVM classifiers were trained (in contrast to multi-feature classification in the previous analysis). The motivation behind this analysis is to tentatively illustrate that with increasing class imbalance, classifiers loose focus on the areas whose data best discriminate the classes, and merely predict the majority class.
Cam-CAN Dataset We used the passive auditory/visual perception task out of the open access MEG dataset collected at the Cambridge Centre for Ageing and Neuroscience (Cam-CAN)  [39]. The preprocessing steps for this dataset can be found in  [40]. The task consists of 2-min recordings during which subjects were presented with either visual checkerboards or auditory tones (in random order) 60 times each, with a second between each stimulus. We further processed the data by down-sampling to 500Hz and epoching into 800-millisecond trials with 150 milliseconds of signal before stimulus onset and 650 milliseconds after. The epochs were baseline-corrected before computing low-gamma power (30-60Hz) using the multi-taper method on the 650 milliseconds after onset. We excluded the magnetometers and averaged powers for the two gradiometers for each location.
Data and Code Availability The scripts, notebooks and pipeline used in this study are open-source under the MIT licence. The code is available on GitHub for further explorations. Our experiment pipeline is not limited to the datasets explored in this study and can easily be used to explore other datasets. The open-source repository can be found at: https://github. com/thecocolab/data-imbalance. The code was developed using Python and its rich ecosystem for scientific computing. To process brain data we used MNE-Python  [41] , and machine learning algorithms and metrics came from scikit-learn  [33]. Visualization was done with matplotlib  [42]  and seaborn  [43]. The synthetic data used in this study can be generated using the opensource code we provide. The EEG Motor Movement/Imagery Dataset is publicly available and can be downloaded here: https://physionet.
Difficult classification In the second scenario, binary classification was performed on data from two overlapping Gaussian distributions with a distance of one (Fig. 2f ), representing a difficult classification task. Due to the nature of this dataset we expected performance scores to reach above chance level. Over all levels of data imbalance, AUC remained consistent and above chance level in LR and LDA. Only in SVM and RF did the AUC decrease to chance level on both ends of increased data imbalance, with the strongest decrease in SVM. Accuracy exhibited a similar behavior over all four classification algorithms. Similarly to the first scenario, the Accuracy scores reached maximal scores on both ends of data imbalance. Despite the decrease of Acc towards the point of maximally balanced data, the distance between Acc and its chance level was increasing.
The maximum distance between Acc and corresponding chance level was reached at the point of perfect class balance, indicating that the classifier was best at learning the structure in the dataset at this point. In contrast to Acc, BAcc reached its maximum at maximal data balance and dropped to chance level, i. e. 50%, at both ends of class imbalance. Again, the RF showed more stable BAcc scores over the range of class imbalance. The F1 score successively increased from 0 to 1 and showed similar but dampened behavior compared to the results from the identical class distributions (Fig. 2g-j ).