dataesr/scientific-paragraphs-categorization huggingface dataset:
, 2018) , we began the development of an implementation of the IDL SPEDAS package in the Python programming language. The tools in PySPEDAS allow users to access scientific quality data products from numerous space missions and ground observatories with only a few lines of code. PySPEDAS provides a variety of generic analysis tools, from simple operations, such as interpolating magnetic field data, to more complex operations, such as calculating and plotting 2D slices of 3D velocity distribution data from particle instruments. Development of PySPEDAS is occurring on GitHub at: https://github. com/spedas/pyspedas Development of PySPEDAS is occurring in the open to encourage contributions from mission teams as well as the general Heliophysics community. PySPEDAS releases are distributed using the Python Package Index (PyPI) and can be installed with: pip install pyspedas PySPEDAS conforms to the Python in Heliophysics Community standards 3.
PySPEDAS is platform independent, supporting the Windows, macOS, and Linux operating systems, and is released under a permissive free software license (MIT). Each function in PySPEDAS is documented in the docstring of that function. The HTML documentation is built automatically from these docstrings using the Sphinx documentation generator 4. The HTML documentation can be found online at: https://pyspedas. readthedocs. io/ PySPEDAS examples are available as Jupyter notebooks in general and mission-specific repositories at the SPEDAS GitHub organization 5. Tutorials are regularly held at scientific meetings, and webinars are regularly held online and are made available on the SPEDAS YouTube channel 6. PySPEDAS is tested using standard Python-based unit tests that are automatically ran when code is merged with the master branch.
These tests typically exist in the tests directory of each module. While these tests exercise the functionality, they do not typically check the validity of the results. To validate the results, unit tests are implemented in IDL SPEDAS which compare the data products from PySPEDAS to the data products in IDL SPEDAS. These validation tests are released in IDL SPEDAS, as well as in a separate repository at the SPEDAS GitHub organization. In the next section, we give an overview of the "tplot" model, describe the load routine design, and finally describe several analysis tools currently available.
Tplot model Because of its importance, here we repeat the principles of the tplot data model. In the tplot data model, time series data are stored, alongside metadata, in global objects called tplot variables. The tplot data model is shown in Table  1. The time values are stored as Unix times (number of seconds since 00:00:00 UTC on 1 January 1970, excluding leap seconds) in the x component of the variable. These values should be monotonically increasing. The data values are stored in the y component, error bars are stored in the optional dy component, and additional dependencies (e. g. , energy and angular ranges) are stored in the optional v, v1, v2, and v3 components of the variable. PyTplot provides importers for a variety of file formats, including CDF files, netCDF files, STS files, as well as IDL sav files.
These importers use other open-source libraries (e. g. , cdflib 8 , netCDF4 9 , scipy 10 , astropy 11 , etc. ) to load the data and time values into numpy arrays, then convert the time values to a common epoch (Unix time), and then store the tplot variables containing the time values, data, and metadata, using the name of the variable as a reference. A suite of PyTplot routines provides an environment for working with tplot variables, e. g. , creating variables (pytplot. store_data), plotting those variables (pytplot. tplot), returning the data in numpy arrays or xarray objects (pytplot. get_data), setting figure options (pytplot. tplot_options), setting panel options (pytplot. options), as well as doing basic calculations such as data cropping (pytplot. crop) and data averaging (pytplot. avg_res_data).
A list of the tplot variables in the current session can be found using the pytplot. tplot_names function, and the metadata for a variable can be accessed by setting the metadata option when calling (pytplot. get_data). A full list of the routines and their functionality can be found in the PyTplot documentation. The plotting features provided by PyTplot are extensive, supporting multiple possible backends (including Bokeh, Qt, and matplotlib), each supporting stacked time series plots containing any combination of line and spectrogram panels. In addition to the standard features supported by the Bokeh and Qt backends, the current backend used by PySPEDAS (matplotlib) supports error bars, annotations, highlighting.
Load routines The instrument load routines in PySPEDAS follow the form: pyspedas. mission. instrument () And implement a common set of keywords for access to the data (as shown in Table  2 ). Some missions  [e. g. , Magnetospheric Multiscale (MMS; Burch et al. , 2016) ] implement additional keywords to provide additional options when loading the data. Each mission implements at least one core load routine, with instrument-specific wrappers implemented as separate functions. The core load routines typically download the data files, load the data files into PyTplot variables, perform common post-processing (e. g. , time clipping of the data), then return a list of the variables that were loaded. The instrument-specific functions can then call these core routines to load the data. This model, adapted from IDL SPEDAS, allows for instrumentlevel pre-and post-processing in the wrapper routines, while most instrument-independent loading is done in a common core routine shared by the instruments.
Multiple core routines can be developed for access to different data servers (e. g. , one for a mission's official data server and one for the NASA archive). PySPEDAS contains several support routines for downloading data files from remote repositories, including: pyspedas. dailynames: generates a list of file names from a time range using the strftime format pyspedas. download: general download routine that uses the open-source requests 12 library internally, supports authentication, allows parsing and searching HTML directory index pages generated by Apache, and provides local caching and file version numbers. pyspedas. hapi. hapi. hapi: supports loading data from Heliophysics Data Application Programmer's Interface (HAPI) 13 servers; uses hapiclient 14 package to load the parameters into numpy arrays, then creates tplot variables.
By default, the data files are stored in a subdirectory of the current working directory; this directory can be changed using the SPEDAS_DATA_DIR environment variable, as well as missionspecific environment variables (e. g. , MMS_DATA_DIR for MMS, THM_DATA_DIR for THEMIS). The mission-specific environment variables override the global SPEDAS data directory set in SPEDAS_DATA_DIR. The local data directories can also be changed in the Python interpreter by setting the 'local_data_dir' key in the mission's CONFIG dictionary; e. g. , pyspedas. themis. config. CONFIG ['local_data_dir'] = '/path/to/data/' for THEMIS. Once the data files are saved locally, the core load routines typically use importers inside PyTplot, described in (Section 2. 1), to save the parameters as tplot variables. The wrapper routines then take these loaded variables and do any instrument-specific post-processing (e.
Coordinate transformations Coordinate transformations are implemented in the pyspedas. cotrans module. The cotrans function, located in the pyspedas. cotrans module, accepts any tplot variable containing vector data in Cartesian coordinates and supports transformations to and from several coordinate systems  (Hapgood 1992 ): Geocentric Equatorial Inertial (GEI), Geocentric Solar Ecliptic (GSE), Geocentric Solar Magnetospheric (GSM), Solar Magnetic (SM), Geographic (GEO), Geomagnetic (MAG) and Geocentric Equatorial Inertial for epoch J2000. 0 (J2000). Internally, these transformations are direct translations of the IDL SPEDAS coordinate transformation routines, which were originally based on the ROCOTLIB 15 library. In addition to the calculations to perform the various transformations, the pyspedas.
cotrans module utilizes the tplot metadata where possible; i. e. , if the input coordinate system is stored in the variable's metadata, the user does not need to specify it manually. The output variable's metadata are updated to the new coordinate system (including in any plot annotations), minimizing the amount of user effort to produce transformed data with proper annotations. The pyspedas. cotrans module also provides tools for transforming vector data into various field-aligned coordinate systems (for which the Z axis corresponds to the direction of a given field vector, X and Y axes defining the plane perpendicular to it); pyspedas. cotrans. fac_matrix_make generates field-aligned coordinate transformation matrices, and pyspedas. cotrans. tvector_ rotate rotates vector data using these matrices.
Magnetic field models Routines for working with magnetic field models are implemented in the pyspedas. geopack module. Functions are available for generating the Tsyganenko 89, 96, and 2001 models, as well as the Tsyganenko-Sitnov 2004 model at arbitrary points in space (as a function of time)  (Tsyganenko, 2013). Internally, these functions extract the input position data from tplot variables, then use the pure-Python implementation of the Geopack library 16 to generate the various field models at each point, then store the results in tplot variables. The Tsyganenko 96, 2001, and Tsyganenko-Sitnov 2005 models require additional solar wind input. The pyspedas. geopack module contains routines (get_tsy_params, get_w_params) for generating the required input parameters to this model using the OMNI solar wind data loaded using the pyspedas.
Curlometer technique The curlometer technique is implemented in the pyspedas. analysis. lingradest routine. This function takes position and magnetic field data obtained at four spacecraft (e. g. , MMS or Cluster) and applies the linear gradient/curl estimator technique  (Dunlop et al. , 2021)  to calculate the magnetic field gradients, divergence, curl, and field line curvature. This routine is a direct translation of the IDL SPEDAS version originally developed for Cluster  (Runov et al. , 2003)  and most recently used by MMS. The core lingradest function is called by an MMS-specific wrapper mms_lingradest in the pyspedas. mms. fgm module; this wrapper interpolates the spacecraft position and magnetic field data to the first spacecraft timestamps, then calls the lingradest function to perform the calculations and saves the output in tplot variables.
Particle tools General (mission independent) particle tools are implemented in the pyspedas. particles module, with mission-specific particle tools implemented in the particles submodule of a mission's module (e. g. , MMS particle tools are implemented in pyspedas. mms. particles). Tools exist for taking particle data structures and calculating the energy, theta, phi, pitch angle, and gyrophase spectrograms, as well as plasma moments of velocity distribution functions. In addition, tools exist for calculating and plotting 2D slices of the velocity distribution functions. The PySPEDAS particle data structure, which is based on the IDL data structure, is shown in Table  4. The units_name attribute of the particle data structure must be counts, rate, eflux, flux, df, df_cm, df_km, e2flux, or e3flux.
For the theta and phi values, the PySPEDAS particle tools use presumed particle trajectories (not look direction of the instrument). The user-facing functions for doing particle calculations can be found in the particles submodule of the mission's module, e. g. , spectrograms and moments for MMS can be calculated using the mms_part_getspec function found in the pyspedas. mms. particles module. This function loads particle distribution function data (as well as any required support data), re-forms the data into the standard PySPEDAS particle data structure described above, then uses various generic functions to perform the calculations, and stores the output as tplot variables. Options exist for changing the species, limiting the energy and angular ranges, changing the output units, disabling internal and external electron photoelectron corrections [for the Fast Plasma Instrument (FPI;  Pollock et al.
, 2016) ], and more. Slices of MMS distribution function data can be plotted using the mms_part_slice2d function, also found in the pyspedas. mms. particles module. Just as above, this function loads the data and any required support data, creates the PySPEDAS particle data structures, then uses generic tools to calculate and plot the slice. Options exist for rotating the slice into a variety of coordinate systems, limiting the energy range, changing the interpolation type, smoothing, and more.
Spherical elementary currents/equivalent ionospheric currents plots The pyspedas. secs module allows for downloading and plotting vector and contour maps of Spherical Elementary Currents and Equivalent Ionospheric Currents data  (Weygand et al. , 2011). The data are downloaded from the Virtual Magnetospheric Observatory 17 using pyspedas. secs. data, and the data are plotted using the make_plots function in the pyspedas. secs. makeplots module. Internally, this function uses matplotlib to create the figures.
Basic example Figure  1  shows magnetic field data measured by five spacecraft, including Solar Orbiter, Parker Solar Probe, Each routine call returns a list of the variable names that were loaded, and users are encouraged to review the mission team's documentation for details on the loaded data products. The tools (load and analysis routines) shown in these examples have additional options that can be found in the docstrings (available in the interpreter by calling the help function with the PySPEDAS function as an argument), as well as in our online documentation. In this example, as well as several of those that follow, we made minor adjustments to some of the figure annotations prior to saving (using pytplot. options) for consistency; the full code for generating all figures can be found in the Supplementary Material.
Discussion The examples in the previous section show how powerful PySPEDAS is for Heliophysics research; for each example, the data can be downloaded and plotted in less than a page of code. We plan to add support for additional projects, datasets, and analysis tools, as well as additional post-processing to several of the projects we currently support. As of July 2022, the tools for working with particle distribution function data are limited to the MMS FPI and HPCA instruments. We are planning on extending support to the particle instruments onboard THEMIS and Arase in the near future. We are also currently implementing tools for minimum variance analysis calculations. In addition to these analysis tools, we plan to add a Graphical User Interface (GUI) and a "calc" minilanguage for working with tplot variables, much like those that exist in IDL SPEDAS [see  Angelopoulos et al.
com/MAVENSDC/PyTplot 8 https://github. com/MAVENSDC/cdflib 9 https://github. com/Unidata/netcdf4-python 10 https://scipy. org/ 11 https://www. astropy. org/ time intervals, automatic spectrogram interpolation, overplotting lines on top of spectrograms, creating figures in Jupyter notebooks, as well as saving publication quality figures.
ndarray of shape: [n_energy, n_phi, n_theta]; containing the phi (azimuth) values; values should be from [0, 360) Energy numpy. ndarray of shape: [n_energy, n_phi, n_theta]; containing the energy values (eV units) dtheta numpy. ndarray of shape: [n_energy, n_phi, n_theta]; containing the widths of the theta bins dphi numpy. ndarray of shape: [n_energy, n_phi, n_theta]; containing the widths of the phi bins denergy numpy. ndarray of shape: [n_energy, n_phi, n_theta]; containing the widths of the energy bins 12 https://requests. readthedocs. io/ 13 https://hapi-server. github. io/ 14 https://github. com/hapi-server/client-python Frontiers in Astronomy and Space Sciences frontiersin. org.
Acknowledgments This research was supported by  Flanders Innovation & Entrepreneurship (VLAIO ,  HBC. 217. 000 ) and by the  Research & Development Umicore Group. JVL is supported by  Ghent University Bijzonder Onderzoeksfonds (BOF)   BOF. GOA. 2015. 0002. 01  and  BOF15/GOA/006 , while KF is supported by  BOF/PDO/2020/0020. KR is supported by a  BOF   GOA grant  ( BOF19/GOA/026 ). LB is supported by  Ghent University Bijzonder Onderzoeksfonds   BOF20/PDO/025. The authors are grateful to staff working at  CMET  and  Umicore  for their assistance. The authors want to express their explicit gratitude towards  Tim Lacoere , lab technician at CMet. The authors declare no competing financial interest.
The secondary objective was to identify MRI structural markers associated with the different cognitive subgroups. Our hypothesis was that a certain proportion of PD patients, selected for STN-DBS, had PD-MCI, including posterior cortical deficits. We expected specific structural alterations associated with the PD-MCI subtypes. In this ancillary study, we included only baseline data collected from participants in PREDISTIM who underwent a complete comprehensive neuropsychological assessment according to the consensus assessment procedure described below and 3T MRI scan.
MRI acquisition The imaging protocol included an anatomical three-dimensional T1-weighted sequence (3DT1) on 3T scanners using the similar parameters in all sites: voxel size:1x1x1 mm 3 ; repetition time:7. 03ms; echo time:3. 18ms; matrix size:256x256x176 voxels; FA:9°. The harmonization of inter-site imaging protocol along with the collection and quality control of acquired MRI data were performed by the center for imaging acquisition and treatment (CATI)  [30] , a platform dedicated to multicenter neuroimaging. All 3DT1 sequences were reviewed and scored from 0 (bad quality) to 4 (excellent quality). For the present study, imaging data with quality evaluation strictly lower than 2 were excluded. MRI pre-processing 3DT1 images were processed using the Human Connectome Project pipeline in the software workbench 1.
Analysis of radiomic features -After bias field correction, radiomic features were extracted from 3DT1 sequences with the open-source package Pyradiomics  [35]  using the manually corrected masks. Firstorder radiomic features were directly calculated from normalized grey levels for each subcortical structure, namely median, interquartile range, kurtosis (measures the ''peakedness" of the distribution of voxel values) and skewness (measures the asymmetry of the distribution of voxel values about the mean). Second-order radiomic features were also calculated from grey level co-occurrence matrices in 3DT1 MRI sequences  [36]. These matrices are second-order histograms, which capture spatial relationships between voxels with predefined intensities in different directions (here, 26 connected directions) and with a predefined distance between voxels (here, the distance was set at 1 voxel).
Statistical analyses Demographic and clinical variables were reported as mean (standard deviation) for continuous variables and frequency (percentage) for categorical variables. They were compared between PD-NC and PD-MCI on the one hand and between PD-FS and PD-PC on the other hand using Mann-Whitney's U test for numerical variables and Fisher's exact test for categorical variables, with the R software version 4. 0. 4 [39]. Cognitive variables were compared using ANCOVA with permutation test (number of permutations = 10,000) controlling for age, sex, and level of education with the R package permuco version 1. 1. 0 [40]. The mean z-score of a cognitive domain was computed by averaging the z-scores from the test variables that assessed this domain. Regarding MRI parameters, ANCOVA with permutation test (number of permutations = 10,000) was used to compare PD-NC and PD-MCI groups with age, sex, level of education and center of recruitment as covariates.
In case of significant result, comparison between PD-FS and PD-PC was performed within the concerned subcortical structures or cortical clusters. For all analyses, correction for multiple comparisons was applied with a false discovery rate (FDR)  [41]  fixed at 0. 05. Finally, Spearman's partial correlation coefficients were computed between significant MRI measures and mean z-scores for each cognitive domain, controlling for age, sex, level of education and center, with the R package ppcor  [42]. More precisely, volumes, radiomic features and mean cortical thickness with the R package permuco  [40]. For voxel-based morphometry and vertex-wise cortical thickness, it was performed with the permutation analysis linear model (PALM) in the FMRIB software library (FSL 5. 0. 11) [43]. In addition, shape analysis was performed on the 3-dimensional matrices using MANCOVA with permutation test, with the R package geomorph version 3.
3. 2 [44]. Furthermore, it is noteworthy that subcortical volumes were normalized with the total intracranial volume computed with volBrain  [32]  to account for brain size differences between subjects. Likewise, voxel-based morphometry analyses were adjusted with the total intracranial volume using a proportional scaling approach with PALM  [43]. For cortical thickness, information about significant clusters of cortical thinning were extracted using workbench 1. 4. 2 [31]  with a minimum surface set at 20mm 2. Finally, Spearman's partial correlation coefficients were computed between significant MRI measures and mean z-scores for each cognitive domain, controlling for age, sex, level of education and center, with the R package ppcor  [42].
Strengths and limitations of the study This study was the first to investigate the neuroimaging markers associated with PD-MCI among PD patients, candidates to STN-DBS. A comprehensive cognitive assessment of PD patients that fulfilled MDS guidelines was performed, with at least two tests for each of the five assessed cognitive domains. Furthermore, we used innovative and sensitive imaging methods such as analyses of shape and radiomic features to explore the structural brain markers. Finally, the effect of potential nuisance variables was highly controlled in our MRI analyses. Our study also has some limitations. Firstly, only baseline data are reported here and, of course, it will be essential to determine whether PD-MCI influence the long-term outcome of STN-DBS and if the identified MRI alterations are markers of this outcome.
However, as it is the first study on such a large multicentric cohort associating cognitive and MRI data, it was worth to communicate these results. Secondly, to be able to distinguish PD-MCI subtypes, we had to adapt the consensus MDS criteria for PD-MCI  [11]. Our adapted criteria were stricter since a cognitive domain was considered impaired and the patient as having PD-MCI when two tests in that domain were failed. This introduces a bias by reducing the frequency of PD-MCI compared to the criteria. Thirdly, the small number of subjects in our PD-PC group might have limited the power of our statistical analyses when comparing the PD-MCI subtypes. Fourthly, our data were acquired in multiple centers and were consequently subject to inter-operator variability. However, the center effect was controlled and this multicentric design provided a more representative sample of PD patients, candidates to STN-DBS.
Conclusions and perspectives Among PD patients, candidates to STN-DBS, a significant proportion has PD-MCI. Cognitive deficits in this subgroup of patients were associated to both cortical and subcortical structural alterations. Follow-up is necessary to determine whether this cognitive status and the associated MRI biomarkers influence STN-DBS outcomes. Data represent the label and surface (mm 2 ) of each cluster, the corresponding cortical areas in the Freesurfer atlas as well as the coordinates in the MNI152 space, t-and p-value of the most significant vertex. Clusters were significant at *pFDR<0.