dataesr/scientific-paragraphs-categorization huggingface dataset:
An MEG analysis that starts from raw data and ends up with group-level statistics may, for example, require the use of Freesurfer for cortical segmentation, MNE for preprocessing and source estimation, radatools for connectivity metrics and Visbrain  (Combrisson et al. , 2019)  for 3D visualizations. Thus, most of the processing is conducted using multiple heterogeneous software and in-house or custom tools leading to workflows that are hard or even impossible to reproduce in practice. Furthermore, with the exponential increase in data dimensionality and complexity, conducting state-of-the-art brain network analyses using MEG and EEG is becoming an increasingly challenging and time-consuming endeavor. Streamlining all the steps of MEG/EEG data analyses into a unified, flexible and fast environment could greatly benefit large-scale MEG/EEG research and enhance reproducibility in this field.
Here, we describe NeuroPycon, a free and open-source Python package, which allows for efficient parallel processing of full MEG and EEG analysis pipelines which can integrate many available tools and custom functions into a single workflow. The proposed package uses the Nipype engine framework to develop shareable processing pipelines that keep track of all analyses steps and parameter settings. Although initially developed with MEG and EEG in mind, NeuroPycon allows for multimodal brain data analysis thanks to the flexibility and modularity it inherits form Nipype. This paper describes the architecture, philosophy and rationale behind NeuroPycon. The functionalities of ephypype and graphpype are illustrated by describing how NeuroPycon is used to wrap existing tools that analyze electrophysiological data (e.
1B ). The current release of the Neuro-Pycon project includes two distinct packages: The ephypype package includes pipelines for electrophysiological data analysis and a command-line interface for on the-fly pipeline creation. A second one called graphpype is designed to investigate functional connectivity via a wide range of graph-theoretical metrics, including modular partitions. Although based on the same Nipype framework, graphpype and ephypype can be used separately. We designed the software with these two distinct packages so that users who only need the functionalities of one, don't need to bother installing useless components. For instance, users who only want to make graph-theoretical analysis on fMRI data will not be obliged to install mne-python, and conversely MEG users who do not plan to do graph-theoretical analysis will not have to install radatools.
Software download, free license and documentation NeuroPycon is freely available to the research community as open source code via GitHub (https://github. com/neuropycon). A basic user manual and some example scripts can be found in the tutorial webpages: https://neuropycon. github. io/ephypype/index. html, https://neuropycon. github. io/graphpype/index. html. The documentation is built using sphinx, 3  a tool developed for python documentation that uses reStructuredText as markup language; an extension of sphinx, sphinx gallery, 4  was used to create an examples gallery by structuring the example scripts to automatically generate HTML pages. Graphpype and Ephypype are provided under the permissive BSD 3-Clause license, which allows the use, modification and re-usability, under the condition of propagating the license.
Unit tests, continuous integration and python coding standards A lot of effort has been put into providing high-quality code that is kept intact through tests and continuous integration (CI). Most of the functions and classes of the package are covered by unit-tests (as of writing this article: 68% and 70% coverage for ephypype and graphpype respectively), including tests on several kinds of data (Nifti MRI files, FIF MEG files, NumPy arrays and Radatools files). All the code also conforms to a standard Python coding convention known as PEP8 which facilitates readability and consistency with software packages in the Python scientific ecosystem.
Ephypype Ephypype is a package designed to analyze electrophysiological data using the Nipype engine. In particular, it focuses on MEG/EEG data and exploits many functions from the MNE-Python package  (Gramfort et al. , 2013) , as well as a range of standard Python libraries such as NumPy  (Van Der Walt et al. , 2019)  and SciPy  (Virtanen et al. , 2019). Current implementations allow for MEG/EEG data import, pre-processing and cleaning by automatic removal of eyes and heart related artefacts, source reconstruction, as well as sensors or source-level spectral connectivity analysis and power spectral density computation. The ephypype package features a convenient and sophisticated command-line interface which is designed to make the best use of UNIX shell capabilities and NiPype framework for parallel processing of MEG/EEG datasets.
Graphpype The graphpype package includes pipelines for graph theoretical analysis of neuroimaging data. Computations are mostly based on radatools, a set of functions to analyze Complex Networks (http://deim. urv. cat/~sergio. gomez/radatools. php). Radatools comes as a set of freely distributed binary executables, obtained from compiling from a library originally written in Ada, and the executables are thus wrapped as command line nodes in nipype. Although it was initially mainly used on fMRI data, the graphpype package can be used for the computation of graph metrics for multiple modalities (MEG, EEG, fMRI etc). This package has been developed to address the needs of functional connectivity studies that would benefit from the computation of a wide graph-theoretical metrics, including modular partitions  (Achard et al.
2 , option 3). Data import for the second option (Fig. 2 , door 2) expects data structure of sensor or source-level time-series, allowing to read in data that may have already been analyzed by other software (e. g. BrainStorm  (Tadel et al. , 2011)  or FieldTrip  (Oostenveld et al. , 2011) ), and then connectivity data (possibly followed by graph metrics) are calculated using appropriate pipeline of NeuroPycon. The user can alternatively directly import connectivity matrices (Fig. 2 , door 3) computed elsewhere and solely use NeuroPycon to compute graph-theoretical metrics.
All example Fig. 2. Four doorways to NeuroPycon: Illustrative pipelines showcasing different distinct uses depending on the type of input data: Full MEG preprocessing, source estimation, connectivity and graph analysis starting from raw MEG data (door 1), only connectivity and graph analysis from time series (door 2), functional connectivity and graph analysis on fMri data (door 3) or only graph analysis from connectivity matrices computed elsewhere (door 4). scripts are based on one of a sample MEG dataset from the OMEGA project (https://www. mcgill. ca/bic/resources/omega). The original data format follows BIDS specification (K. J. Gorgolewski et al. , 2016; Niso et al. , 2018). The NeuroPycon parameters settings (e. g. for the connectivity method, the source reconstruction algorithm, etc.
Data preprocessing pipeline (ephypype) [pipeline #1] The preprocessing pipeline performs filtering, it optionally downsamples the MEG raw data and runs an ICA algorithm for automatic removal of eye and heart related artifacts. The implementation is primarily based on the MNE-Python functions that decompose the MEG/ EEG signal by applying the FastICA algorithm  (Hyvarinen, 1999). An HTML report is automatically generated and can be used to correct and/or fine-tune the correction in each subject. The inclusion and exclusion of more ICA components could be performed either by re-running the same preprocessing pipeline with different option parameters (recommended option) or interactively in a Jupyter notebook (or IPython). In this last case, we suggest to save the new ICA solution and cleaned data in the corresponding node folder.
Here we show the time series, topomap and some properties (e. g. power spectrum) of ICA components obtained by running the example script provided in the documentation website (https://neuropycon. github. io/ephypype/auto_examples/plot_preprocessing. html) on the raw MEG sample dataset. computation of the lead field matrix and the noise covariance matrix. These matrices are the main ingredients to solve the MEG/EEG inverse problem by one of the three inverse methods currently available in the ephypype package: MNE  (H€ am€ al€ ainen et al. , 1993; Lin et al. , 2006) , dSPM  (Dale et al. , 2000) , sLORETA  (Pascual-Marqui, 2002). In particular, the lead field matrix is computed by the Boundary Element Method (BEM)  (Gramfort et al. , 2010)  provided in MNE-Python. We use a single layer, i. e.
the brain layer for MEG data, while for EEG datasets a three compartment BEM (scalp, skull and brain layers) is chosen. A graphical depiction of the source reconstruction pipeline with its node and connections is shown in Fig. 4. To use this pipeline, a user would either need a template MRI or the individual anatomical data. In the latter case, the segmentation of the anatomical MRI has to be performed by Freesurfer in order to generate surfaces and parcellations of the structural data. The anatomical segmented data will be used in the pipeline to extract the BEM surfaces and to create the source space. By default it is expected that the current dipoles are situated on the cortical surface, but it is also possible to set a mixed source space constituted by the cortical surface and the volumes of some user-selected subcortical regions, as amygdala, thalamus, cerebellum, etc.
Finally, the segmented MRI data are also used to perform the coregistration step between the MEG/EEG and MRI coordinate system. This is the only manual step one has to perform before using the source reconstruction pipeline and can be performed by mne_analyze process of MNE-C 5  or an MNE-Python Graphical User Interface (GUI). In the future, automatic co-registration will become available when this feature becomes a robust function in MNE python. A template MRI, just like the one provided by the Freesurfer software, could be used if the individual anatomical data are not available. Fig. 7  shows the results obtained by running the inverse solution pipeline on the sample dataset. The script used to generate this figure can be downloaded as Jupyter notebook from the documentation website https://neuropycon.
Spectral power pipeline (ephypype) [pipeline #3] The power pipeline computes the power spectral density (PSD) in either sensor or source space. It also computes the mean PSD for each frequency band specified by the user. The latter can choose to compute the PSD by Welch's method or multitapers. The input of the pipeline can be either raw/epoched data specified by the user or simply the output of another pipeline, e. g. the cleaned raw data from the preprocessing pipeline or the estimated source time series from the source reconstruction pipeline. Fig. 6A  shows the results obtained by running the power pipeline on the sample dataset. The script used to generate this figure can be downloaded as Jupyter notebook in the documentation website https://neuropycon. github. io/ephypype/auto_examples/plot_po wer.
Spectral connectivity pipeline (ephypype) [pipeline #4] The spectral connectivity pipeline computes the connectivity matrices in the frequency domain. The current implementation is based on the spectral connectivity computation in MNE, and can be computed on time series in NumPy format (in either sensor or source space), or even from Matlab format after conversion using the SciPy package. All the frequency-domain coupling measures available in MNE-Python are directly accessible through this pipeline (e. g. Coherence, Imaginary Coherence, Phase Locking Value, Phase-Lag Index). Fig. 6B  shows the results obtained by running the connectivity pipeline on the sample dataset. The script used to generate this figure can be downloaded as Jupyter notebook in the documentation website https://neuropycon.
Functional connectivity analysis (graphpype) [pipeline #5] Starting from pre-processed functional MRI data, we provide a pipeline named "nii_to_conmat", which allows the user to compute functional connectivity from a given file in Nifti format, and a corresponding template. The pipeline convolves the template with a grey-matter mask, extracts time series under the restriction of sufficient proportion of voxels in the template ROI, regresses non-interest covariates (white matter, cerebrospinal fluid, movement parameters, etc) and computes Z-score Pearson correlations over residuals signals. An example of this pipeline, followed by the graph-theoretical analyses pipeline (see following section) is provided at https://neuropycon. github. io/graphpype/auto_examples/plot_nii _to_graph. html#nii-to-graph.
Some specific metric computation, mostly related to node roles (participation coefficient and within-module normalized degree, see  Guimera et al. , 2005)  have also been specifically coded and are part of Radatools' standard modular decomposition pipeline. The script used to generate this figure can be downloaded as Jupyter notebook on https://neuropycon. github. io/graphpype/ auto_examples/plot_inv_ts_to_graph. html. Another package allowing for graph-theoretical analysis, very popular in the neuroscience community, is the Brain Connectivity Toolbox  (Rubinov and Sporns, 2011). As an example of a wrap, and to show potential users what would be done to integrate their favorite software functions, we documented the definition of a small pipeline consisting of one node (K-core from the bctpy package): https://neuropycon.
Validation of NeuroPycon group analysis using previously published work on open data In order to show how to use NeuroPycon pipelines to analyze a cohort of subjects, we replicated the results obtained by  Jas et al. (2018). In this article, the authors reanalysed an open dataset from  Wakeman and Henson (2015)  using the MNE software package, with the aim of providing group analysis pipelines with publicly available code and documentation. The data consist of simultaneous MEG/EEG recordings from 19 healthy participants performing a visual recognition task. Subjects were presented images of famous, unfamiliar and scrambled faces. Each subject participated in 6 runs, each 7. 5 min in duration. The data were acquired with an Elekta Neuromag Vectorview 306 system. We focused only on MEG data and used NeuroPycon pipeline #1 to preprocess the MEG raw data and pipeline #2 to perform source reconstruction of time-locked event-related fields.
In the following, we describe the main steps of the analysis. All parameters of the analysis are set in a single json file, with a nested structure to keep track of which parameters correspond to which steps. All the scripts can be downloaded from https://github. com/neuropycon/n europycon_demo. git. Note that anatomical segmentation is performed using a dedicated script and the preprocessing and source reconstruction pipelines are combined in a single workflow. The individual steps of this group-analysis replication with NeuroPycon are described below.
Comparison Fig. 5  (right) shows group average of dSPM solutions for the contrast between both types of faces together and scrambled at 170 ms poststimulus. The image was produced by subtracting normalized solutions of faces to the ones of scrambled. The results are similar to the ones obtained by  Jas and colleagues (Fig. 5, left). We also measured the computational time needed to compute ICA by MNE and NeuroPycon with the aim to see the performance benchmarks of running MNE python in NeuroPycon versus in pure python. While the parallel library used by Jas and colleagues leads to a computational time comparable with the one obtained by using NeuroPycon, one of the main advantages provided by NeuroPycon is related to the caching provided by Nipype engine that stores intermediate files and recomputes only those nodes which do not have a cache.
Statistical analyses Within NeuroPycon, it is possible to conduct group-level statistics in several ways. Any current or future statistical analysis functions available through tools wrapped by NeuroPycon are automatically available for use in NeuroPycon pipelines (e. g. all statistical analyses provided by MNE python). Additionally, the graphpype package offers several functions to compute statistics on connectivity and graph data. These include assessing statistical significance by computing parametric tests (paired and unpaired t-test, binomial, Mann-Whitney, etc. ) between groups of matrices or vectors. Of course, with the increasing number of dimensions we also need to address the multiple comparison problem. It is possible to compute several levels of significance accounting for multiple comparisons, tailored for connectivity and graph metrics: For instance, a False Positive metric (1/#of tests) has been suggested to be an acceptable threshold when hundreds or even thousands of nodes are at play  (Bassett and Lynall, 2013).
Other implemented tools include False Discovery Rate  (Benjamini and Hochberg, 2000; Hyvarinen, 1999)  and Bonferroni correction. An alternative approach is of course to implement non-parametric permutation testing over mean connectivity matrices. The time-consuming steps of permutation computing here critically benefit from the parallelization available in NeuroPycon (via Nipype engine). A reasonable number of computations (e. g. 1000) can be achieved in a relatively short time (a few hours for the full network pipeline computation, including modular decomposition, assuming typical network sizes of ~100 nodes). The gather_permuts module of graphpype package in the "gather" directories offer a range of functions allowing for computation of the corresponding p-values.
Visualization tools (graphpype, visbrain) Numerous tools can be used to visualize the results and data computed by or manipulated within NeuroPycon. One option is to use visualization tools currently used within MNE python, such as pysurfer 6  and mayavi  (Ramachandran and Varoquaux, 2011) , as well as a more recent implementation using PyVista  (Sullivan and Kaszynski, 2019). An example of visualization provided by MNE python is shown in Fig. 3  containing the output of preprocessing pipeline, i. e. the topographies and time series of the ICA components. Another more recent option to visualize the results is to use visbrain (http://visbrain. org), a python based open-source software dedicated to the visualization of neuroscientific data  (Combrisson et al. , 2019). It is built on top of PyQt 7  and VisPy  (Campagnola et al.
Here we show illustrative results obtained using the connectivity pipeline to compute coherence between MEG sensors in alpha band. Connectivity edges are colored according to the strength of the connection, while the node size and color depend on the number of connections per node. These results are obtained by running the examples script in the documentation webpage: (https://neuropycon. github. io /ephypype/auto_examples/plot_co nnectivity. html. from the ROI estimated time series computed by the inverse solution pipeline. The graph is obtained after thresholding at 5% highest coherence values.
NeuroPycon command line interface (CLI) As previously mentioned, the construction of neuropycon data processing pipelines is done in a python script specifying the affinity and arguments of the processing nodes and the source of input data. Such scripts can be distributed, shared and reused later, which facilitates reproducibility and results sharing. However, this can arguably sometimes be tedious if we want to construct and run simple pipelines quickly. To address this problem, we've provided neuropycon with a Command Line Interface (CLI) which is provided in the ephypype package. Indeed, at the moment the command line interface wraps only some of the functionality of the ephypype package only but will be expanded in the future. CLI is aimed at building the processing workflows on the fly leveraging the UNIX shell wildcards mechanism for flexible input specification (Fig.
In the example shown in Fig. 9 , the list of files is specified using the UNIX wildcards matching mechanism and can be spelled out as 'Go to each subfolders of the NeuroPyConData folder and take all the '. fif' files contained in it' (here we presume that there's only one level of nesting in NeuroPyConData folders structure, i. e. files are organized according to the following scheme: NeuroPyConData/<SubjectName>/<subject_data. fif>). Integration with the UNIX wildcards pattern matching is one of the biggest strengths of the supplied CLI since it allows for flexible and concise fetching of files in the nested folders hierarchy given that these folders are organized in a regular and well-defined fashion, which is often the case for electrophysiological datasets. A more detailed explanation of the command line interface operation principles and examples can be found on the documentation webpage (https://neuropycon.
Multiprocessing The implementation of multiprocessing is very easy, and can be either made for multi-processing on a same machine with multiple cores (Multiproc plugin) or a cluster with multiple machines in parallel (q-sub/ ipython plugin). In addition to substantially speeding up the computations for a planned analysis, the ability to easily launch multiprocessing computations also encourages users to rapidly test and compare different analyses options (e. g. various preprocessing strategies, or different source localization methods, or even optimizing parameter selection, such as matrix thresholding or graph construction, or frequency band choices, etc. ). Easy definition of multiprocessing is also an advantage over Matlab-based scripting when it comes to handling big datasets. While multiprocessing exists in Matlab its implementation requires specific coding, whereas in NeuroPycon the exact same code is used for both sequential and parallel processing, except for one line that specifies the option.
Choices and interaction between multiple software tools It is not uncommon in the literature to see that graph analysis of EEG or MEG data is achieved by combining distinct independent software tools (e. g exporting connectivity data from one of the MEG/EEG analysis toolboxes available to a functional connectivity software such as the Brain Connectivity Toolbox (BCT)  (Rubinov and Sporns, 2010) ). By contrast, NeuroPycon provides a unified framework with seamless interactions between tools allowing to compute graph properties starting from raw MEG/EEG data.
github. io/graphpype/how_to _wrap. html#how-to-wrap and (ii) an example on how to create a workflow connecting a Node that wraps a function of a Matlab toolbox (e. g. FieldTrip) with a Node that wraps a function of a python toolbox (e. g. MNE): https://neuropycon. github. io/ephypype/auto_examples/run_fie ldtrip_wf. html. On the other hand, the compatibility is readily guaranteed if the aim is to include in NeuroPycon a new pipeline based on an algorithm already implemented in a software wrapped by NeuroPycon (e. g. MNE python or radatools). For example, adding a source reconstruction pipeline using Linear Constrained Minimum Variance beamformer  (Van Veen et al. , 1997)  as inverse method is possible via a small modification of the ephypype package (not more than ten lines of code). This type of extension is also illustrated in NeuroPycon's online documentation, see for example: https://neuropycon.