dataesr/scientific-paragraphs-categorization huggingface dataset:
XP1 (Data Citation 1) Data collected during the motorloc session were used to identify a ROI for fMRI NF computation. fMRI scans were pre-processed for slice-time correction, spatial realignment and smoothing with SPM8 and activation maps were estimated with a GLM approach. A ROI over the left M1 was defined as the 9 X 9 X 3 voxels surrounding the maximum of activation. The right M1 ROI was defined as the symmetrical voxel across the mid sagittal plane. The activation from these two ROIs was included in the computation of the laterality NF feature and fed back to the subject during NFT. The EEG NF feature, on the other hand, was computed considering the EEG power in the (8-12) Hz band in the C1 and C2 electrodes (see the section NF features computation). After pre-processing EEG features for the first study were computed according to the following expressions: 𝑵𝑭 𝒆𝒆𝒈 (𝒕) = [𝑩𝑷 𝒍𝒆𝒇𝒕 (𝒕) -𝑩𝑷 𝒓𝒊𝒈𝒉𝒕 (𝒕)] [𝑩𝑷 𝒍𝒆𝒇𝒕 (𝒕) + 𝑩𝑷 𝒓𝒊𝒈𝒉𝒕 (𝒕)] ⁄ where    (𝒕)  (  ()) is the band power in the 8-12 Hz range at C1 (C2) during the NF task normalized by the power during rest.
XP2 (Data Citation 2) For the second study, a more sophisticated calibration procedure was performed. Data collected during the MIpre session were used to identify an optimal spatial filter for EEG and a ROI based on the maximum of activation in the target motor area. As described in detail in 18 , EEG data were pre-processed in Analyzer (Brain Product Software) and BCG artefacts were corrected with a semi-automated procedure. A Common Spatial Pattern (CSP) filter maximizing the difference in EEG power in the target band (8-30 Hz) between rest and MI blocks was estimated from a selection of motor channels. fMRI scans were pre-processed for slice-time correction, spatial realignment and smoothing with SPM8 and activation maps were estimated with a GLM approach. The selected ROI was defined as the voxel (9x9x3 mm) around the peak of activation in the target motor area (i.
EEG DATA Raw EEG Raw EEG is sampled at 5kHz with FCz as the reference electrode and AFz as the ground electrode, and a resolution of 0. 5 µV. Following the BIDS arborescence, raw EEG data for each task and subject can be found in XP1/sub-xp1*/eeg in Brain Vision Recorder format (File Version 1. 0). Each raw EEG recording includes three files: the data file (*. eeg), the header file (*. vhdr) and the marker file (*. vmrk). The header file contains information about acquisition parameters and amplifier setup. For each electrode, the impedance at the beginning of the recording is also specified, giving therefore an additional indication of the quality of recording settings. For all subjects, channel 32 is the ECG channel. The 63 other channels are EEG channels. The marker file contains the list of markers assigned to the EEG recordings and their properties (marker type, marker ID and position in data points).
vhdr) and the marker file (*. vmrk), containing information similar to those described for raw data. In the header file of preprocessed data channels locations are also specified. In the marker file the location in data points of the identified heart pulse (R marker) are specified as well. EEG data were pre-processed using BrainVision Analyzer II Software, with the following steps:  Automatic gradient artefact correction using the artefact template subtraction method (sliding average calculation with 21 intervals for sliding average and all channels enabled for correction). As specified in the relative task event files in XP1\ *events. tsv files onset, the scanner began the EPI pulse sequence two seconds prior to the start of the protocol (first rest block), so the first two TRs should be discarded.
fMRI NF Scores For each subject and NF session, a matlab structure with BOLD-NF features can be found in XP1/derivatives/sub-xp1*/NF_bold/ In view of BOLD-NF scores computation, fMRI data were preprocessed using SPM8 and with the following steps: slice-time correction, spatial realignment and coregistration with the anatomical scan, spatial smoothing with a 6 mm Gaussian kernel and normalization to the Montreal Neurological Institute (MNI) template For each session, a first level general linear model analysis was then performed. The resulting activation maps (voxel-wise Family-Wise error corrected at p < 0. 05) were used to define two ROIs (9x9x3 voxels) around the maximum of activation in the ipsilesional primary motor area (M1) and supplementary motor area (SMA) respectively. The BOLD-NF scores were calculated as the difference between percentage signal change in the two ROIs (SMA and M1) and a large deep background region (slice 3 out of 16) whose activity is not correlated with the NF task.
MRI DATA All DICOM files were converted to Nifti-1 and then in BIDS format (version 2. 1. 4) using the software dcm2niix (version v1. 0. 20190720 GVV7. 4. 0) Functional MRI fMRI acquisition in XP2 slightly changed with respect to XP1. We used EPI covering the superior half of the brain with the following parameters: TR=1 s, TE=23 ms, Resolution 2x2x4 mm 3 , Number of 4 mm slices: 16, No slice gap. As for XP1 and as specified in the relative task event files in XP2\ *events. tsv, the scanner began the EPI pulse sequence two seconds prior to the start of the protocol (first rest block), so the first two TRs should be discarded. In task events files for the different tasks, each column represents: -'onset': onset time (sec) of an event -'duration': duration (sec) of the event -'trial_type': trial (block) type: rest or task (Rest, Task-MI, Task-NF) -'stim_file': image presented in a stimulus block.
Technical Validation The bimodal NF platform architecture for simultaneous EEG-fMRI recording is described in  17  , together with details about the two layers data synchronization and preprocessing implemented in order to guarantee real-time NF presentation. Results relative to Data Citation 1 were published in  8  , a study where the added value of bimodal NF with respect to the single modalities (EEG and fMRI only NF) was shown. Data Citation 2 experiment was intended to characterize a more subtle aspect: the impact of visual representation (2D or 1D) of bimodal NF on the NF performances  18. Finally, we are currently extending the bimodal NF paradigm to chronic stroke rehabilitation  22. To illustrate the type of data and results we can extract from these datasets we show in Figure  5  an example of fMRI and EEG activation and NF scores for one subject (Data Citation 2).
To validate the data quality a classic analysis of EEG and fMRI patterns was performed over the 20 participants of Data Citation 2. EEG power spectrum was firstly estimated using a multitaper Hanning approach in the 8-30 Hz frequency band. ERDs for each block and NF run were then computed. The baseline for ERD computation was the 10 s interval before motor imagery execution (in order to exclude from the computation the event related synchronization ERS occurring at the end of the motor imagery task therefore in the first seconds of the following resting block). We performed a k-means cluster analysis on individual ERD and ERS features and identified two outliers (xp211, xp212) showing, at least in one NF run, artefactual ERD. These were excluded from further analysis of EEG patterns. Average ERD scalp distributions in the alpha (8-12 Hz) and beta (13-30 Hz) frequency bands were investigated, as well as temporal and frequency patterns, as shown in Figure  6.
fMRI analysis was performed using a processing pipeline based on Nipype, an open-source neuroimaging software that facilitates workflow reproducibility (https://github. com/nipy/nipype, version 1. 2. 0, Python 3. 6). Preprocessing steps included slice timing and motion correction, detection of motion and intensity outliers, segmentation of anatomical image and coregistration, smoothing (fwhm=6). A fist-level and second-level GLM analysis were also performed across the three NF runs (canonical HRF, voxel-based analysis, Family-Wise error (FWE) correction p=0. 05). Individual results were normalized to the Montreal Neurological Institute (MNI) template before performing a one sample T-test group analysis. More details about MRI data processing can be found in the processing scripts available on github (https://github.
Results are quite robust across the two groups (2dNF and 1dNF) that exhibit largely overlapping contrast maps, as shown in Figure  7 B. To illustrate some possible uses for data fusion and integration, we performed two analysis, one on each dataset. The first one follows the methodology proposed in  24  to estimate sources localisation using a joint EEG and fMRI sparse model. The second shows the methodology to learn a fMRI informed EEG filter aiming at improving NF sessions using EEG only, as proposed in  16.
A data fusion approach for joint EEG-fMRI source estimation (XP1) To estimate source location on the XP1 dataset, we applied the symmetric bi-modal method proposed by  24  to the motor localizer (motorloc) runs. The proposed approach uses a sparse regularisation for the sources and combines the two modalities EEG and fMRI to improve the spatio-temporal resolution of the sources estimation. The problem writes as follow: 𝑺 ̂= 𝒂𝒓𝒈𝐦𝐢𝐧 𝑺 {𝜶 ‖𝑮𝑺 -𝑬‖ 𝟐 𝟐 + (𝟏 -𝜶) ‖𝑺𝑯 -𝑩‖ 𝟐 𝟐 + 𝝀‖𝑺‖ 𝟏 }, With S the estimated sources, G the leadfield matrix, E the observed EEG signals, B the observed BOLD signal and H a matrix linking EEG time samples to BOLD time samples using the hemodynamic response function. We chose different values for  (1 to consider EEG only, 0. 6 the optimal balance between both modalities as found in  24  and 0 to consider fMRI only), and the optimal sparsity parameter  = 2.
We applied the model on all subjects having performed a motorloc run. Figure  8  shows the average results of source estimation from the joint EEG-fMRI model ( 0. 6), from the EEG only model ( = 1) and from fMRI only model ( = 0). These results indicate that the combination of both modalities allows a more robust and complete localisation of the sources than when using only one modality, as even if fMRI provides a better spatial resolution, it can detect false positives, such as those outside motor areas. 2. A sparse EEG-informed fMRI model to improve EEG NF only (XP2) We intended to learn fMRI-NF scores from EEG signal as proposed in  16  in order to determine if fMRI information could be integrated to EEG, on the dataset XP2. The learning and testing process is illustrated at Figure  9  panel A.
The method proposes a model able to learn fMRI-NF scores from bi-modal NF sessions, using EEG signals only. The model learns some parameters of a design matrix composed by different frequency bands between 8 and 30 Hz, and different time delays to better match fMRI delays. A mixed norm is applied ( 1 on the electrodes dimension and  21 on the frequency bands dimension) to the model to regulate the parameters. We excluded from the analysis the two subjects with a bad ERD, as detailed above. One of the sessions was used to learn the model, and the two other NF sessions are used to test the model. validate the efficiency of the prediction, we correlated the estimated fMRI-NF scores with the fMRI-NF scores of the testing sessions, Figure  9  panel B boxplots in blue of such correlation across the dataset, for the learning phase and the testing phase.
Usage Notes This dataset of simultaneously acquired EEG and fMRI during a NF motor imagery task is unique in literature and has potential to shed light on the coupling model underlying the EEG and fMRI signals, to advance methodologies for multimodal data integration and test EEG denoising methods. The design of the platform and the data collection itself represented a challenge and a veritable research advancement: this constitute a major added value of this dataset but also implies that some technical challenges during data acquisition (especially for the first experiment XP1) led to missing training sessions in some subjects. Another limitation of this dataset is the quality EEG acquired during MRI imaging. As showed in the technical validation section and in previously published work, however, average results are in line with literature thus indicating the overall quality of EEG recordings.
New (offline and real-time) EEG artefact correction algorithms may be efficiently tested on these data, as we provided raw and pre-processed EEG data. The efficacy of the proposed algorithms may for instance be assessed looking at quality of ERD patterns associated to the motor imagery (or execution) task. Even if the definition of the BIDS standard for EEG is still evolving  25  we tried to adhere to this standard to have an easily and robustly exploitable EEG-MRI BIDS dataset, that can be processed using predefined and standardized pipeline (such as fMRIprep, BIDSHandler and various other BIDS-Apps, https://github. com/BIDS-Apps). As mentioned in the previous section common and freely available software packages for EEG and MRI data processing were used to analyse data (SPM, Nipype, FieldTrip), except for EEG pre-processing for gradient and BCG artefact correction, for which the Brain Vision Analyser software (Brain Products GmbH, Gilching, Germany) was used.
 lapC3_bandpower_8Hz_30Hz: 1x1280 vector. Bandpower of the filtered signal with a laplacian centred on C3, used to estimate the lapC3_ERD.  lapC3_filter: 1x64 vector. Laplacian filter centred on C3 channel. MRI DATA All DICOM files were converted to Nifti-1 and then in BIDS format (version 2. 1. 4) using the software dcm2niix (version v1. 0. 20190720 GVV7. 4. 0) Raw functional MRI Following the BIDS architecture (Figure 4 A. ), the functional data and relative metadata are found for each subject in the following directory XP1/sub-xp1*/func fMRI acquisitions were performed using echo-planar imaging (EPI) and covering the entire brain with the following parameters: TR=2 s, TE=23 ms, Resolution 2x2x4 mm 3 , FOV = 210×210mm 2 , Number of 4 mm slices: 32, No slice gap.
Acknowledgements MRI data acquisition was supported by the  Neurinfo   MRI research facility  from the  University of Rennes  I. is granted by the the  European Union (FEDER) , the  French State , the  Brittany Council ,  Rennes Metropole ,  Inria, Inserm  and the  University Hospital of Rennes. The project was supported by the  National Research Agency  in the " Investing for 540 the Future" program  under reference  ANR-10-LABX-07-0 , and by the  "Fondation pour la Recherche Médicale " under the convention # DIC20161236427.
Code availability A detailed description of bimodal EEG-fMRI NF platform is given in  17  : the platform software package for real-time analysis and visualization is well documented but not publicly available. Python pipelines for the analysis of structural and functional MRI (Figure  8 ) are available on github (https://github. com/glioi/BIDS_fMRI_analysis_nipype), in form of commented jupyter notebooks. Other scripts used for the technical validation in this paper can be provided by the authors upon request.
Accelerometer Recordings Head movements were recorded using a digital microelectromechanical sensor combining a linear 3D accelerometer and a 3D gyroscope (Ivensense, Mpu-9150). We used a custom printed circuit carrying the surface components (sensor, resistors and capacitors) and the power and data exchange wires  (Dugue et al. 2017 ). To communicate with the sensor, we use an I2C interface controlled via the USB port by a program in the LabVIEW software to synchronize the signal from the accelerometer with the electrophysiological system and optogenetic stimulations. Stimulation-triggered averages were computed in R. Periods of head immobility were defined as periods of at least of 1 s duration with head rotation speed always below 20 deg/s duration. The head rotations were examined in stimulation-triggered average of the rotational speed (Fig.
3 ). The signal was acquired by a headstage and amplifier from TDT (RZ2, RV2, Tucker-Davis Technologies, Alachua, FL, USA). The spike sorting was performed with Matlab (Mathworks, Natick, MA, USA) scripts based on k-means clustering on PCA of the spike waveforms  (Paz et al. 2006). At the end of experiments, the electrodes' positioning in the motor cortex M1 or cerebellar nuclei was verified by electrolytic lesions and compared to a brain atlas after brain slicing (Supplementary Fig. S1 ). The yield of recordings was rather stable over the recording period, but no statement is made whether the same cells were recorded across sessions.
Funding This paper was supported by the following grants:  Agence Nationale de Recherche   ANR-12-JSV4-0004 Ceredystim  and  ANR-16-CE37-0003-02 Amedyst  to  D. P. ,  Agence Nationale de Recherche   ANR-12-BSV4-0027   Cemod  and  ANR-17-CE37-0009 Mopla  to  C. L. ,  Agence Nationale de la Recherche   ANR-10-LABX-54   MEMO LIFE  and  ANR-11-IDEX-0001-02 PSL Research University  to D. P. and C. L. , France Parkinson 2013, and by the  Institut National de la Santé et de la Recherche Médicale (France).
The recent embedding of electroencephalographic (EEG) electrodes in wearable devices raises the problem of the quality of the data recorded in such uncontrolled environments. These recordings are often obtained with dry single-channel EEG devices, and may be contaminated by many sources of noise which can compromise the detection and characterization of the brain state studied. In this paper, we propose a classification-based approach to effectively quantify artefact contamination in EEG segments, and discriminate muscular artefacts. The performance of our method were assessed on different databases containing either artificially contaminated or real artefacts recorded with different type of sensors, including wet and dry EEG electrodes. Furthermore, the quality of unlabelled databases was evaluated.
We specifically used the Melomind device (myBrain Technologies, Paris, France), a new portable EEG system based on two dry electrodes, to validate the method. The performance of our approach is also validated on standard wet sensors recording subsets: one from Acticap BrainProducts (GmbH, Gilching, Germany) and another from an artefact-free EEG public database  [22]  contaminated with simulated artefacts of several types (muscular artefacts, blinks,. ). Our method is also compared with another algorithm for artefact detection in single-channel EEG systems  [2]. Finally, our method is evaluated for the quality assessment of unlabelled EEG databases. The remainder of the paper is organized as follows: Section 2 describes the databases and the methods used in the proposed approach. Section 3 presents the statistical assessment of our method in terms of accuracy of artefact detection.
• High quality level (HIGH-Q): EEG signals without any type contamination (head movement, eye blinking or muscular artefacts). These EEG signals are considered as "clean". In order to validate our method, we first studied two databases containing EEG signals recorded with different EEG sensors on healthy subjects for whom we asked to deliberately generate different type of artefacts. Thirty seconds of EEG data were recorded for each type of artefacts (including eye blinking, head and eye movements, jaw clenching). Very contaminated data (signal saturation and electrode peeling off), was also deliberately produced during 30 s of recording. Finally, 1 min of EEG data was collected during the subjects were asked to be quiet but alert. The first database (artBA) is composed of EEG signals from three subjects recorded by an Acticap BrainProducts (GmbH, Gilching, Germany) system using 32 wet electrodes in the 10-20 International System.
Signals were amplified, digitized at 1000 Hz sampling frequency, then down-sampled to 250 Hz and segmented in one second non-overlapping windows. For all recordings, the impedance between the skin and the sensors was below 5 kΩ. The second database (artMM) is composed of EEG signals from 21 subjects recorded by Melomind (myBrain Technologies, Paris, France), a portable and wireless EEG headset equipped with two dry sensors on P3 and P4 positions according to the 10-20 International System. EEG signals were amplified and digitized at 250 Hz and segmented in one second non-overlapped windows, then corrected to remove DC offset and 50 Hz power line interferences by Melomind's embedded system before being sent via Bluetooth to a mobile device. We used a third database (publicDB) which comes from the BNCI Horizon 2020 European public repository, dataset 13  [22].
It contains motor imagery-related EEG signals from 9 subjects recorded by g. tec GAMMAsys system using 30 wet active electrodes (g. LADYbird) and two g. USBamp biosignal amplifiers (Guger Technolgies, Graz, Austria). Artefact-free EEG segments were selected to build this database contaminated with artificially-generated artefacts. Finally, two unlabelled databases containing real EEG activity were also collected on 10 subjects in parietal regions (P3 and P4) with a standard system (Acticap BrainProducts, GmbH, Gilching, Germany) and with a low-cost system (Melomind, myBrain Technologies, Paris, France). One dataset contains therefore EEG recordings made with wet standard (wetRS) electrodes, whereas the second one contains the data recorded with the dry sensors (dryRS). In all these EEG recordings, the subjects were asked to be at rest with closed eyes but in alert condition during 1 min.
Spectral Distance to Distinguish Muscular Artefacts As mentioned above, our method can discriminate artefacts of muscular origin. For this purpose, a spectral distance is first estimated between all the clean (high-quality or HIGH-Q) segments of the training set. An EEG segment detected with a medium quality (MED-Q) can be further discriminated as a muscular artefact (MED-MUSC) if the distance of its spectrum (Pxx( f )) to the averaged spectrum of clean segments (Pyy( f )) is higher than a threshold T, defined as N standard deviations above the mean distance computed between all clean segments. For each database, N is chosen iteratively so that the accuracy of detection of MED-MUSC segments is maximum in the training set. Here, we use the Itakura distance, a statistical distance widely used in spectral analysis  [33, 34] , defined by: dI = log ∑ f Pxx( f ) Pyy( f ) -∑ f log Pxx( f ) Pyy( f ) (4) where Pxx( f ) and Pyy( f ) are the spectra to be compared over the spectra frequency range, set here 0 < f < 40 Hz as it contains the most relevant information of the EEG.
Generation of Artefacts To test the performance of the different classifiers under study, we generated contaminated data both in a real (True artefacts) and in an artificial condition (Synthetic artefacts), by controlling the level of contamination with respect to the clean EEG. True artefacts: The databases obtained from the standard EEG system (wet electrodes) and the low-cost device (dry sensors) are composed of three sets, each containing a data collection with different types of artefacts: 1. Clean EEG signals without internal or external artefacts recorded while subjects were instructed to remain quiet but alert during 1 min.
3. Very contaminated EEG data after the subjects with deliberately produced signal saturation or electrode peeling off during 30 s. These datasets were visually inspected by trained EEG experts. 1 s-EEG segments were manually label as LOW-Q, MED-Q, MED-MUSC and HIGH-Q to constitute the ground truth of the classification. Synthetic artefacts: Artificially contaminated EEG signals were simulated using data from the public database described in Section 2. 1. Artefacts were generated in three different ways to dispose of the following patterns: 1. Electrooculogram (EOG) signals were first detected by means of a wavelet thresholding procedure  [35]. The residual EEG in the EOG was then extracted so only eye-related activity (blinks, slow vertical and horizontal movements) was kept.