*3.1. Data Conversion*

MuseStudio can import from XDF files to work with Python arrays. There are two methods created for importing recordings, and both return the same data. The method *read\_raw\_xdf* handles one file, and *read\_raw\_xdf\_dir* handles a directory with several XDF files. The following code shows an example of the latter:

```
stream_eeg, stream_acc, stream_ppg, stream_gyr, filenames = read_raw_xdf_dir("/path/to/directory")
```
where *stream\_eeg*, *stream\_acc*, *stream\_ppg*, *stream\_gyr*, and *filenames* are lists containing the data for EEG, the accelerometer, PPG, the gyroscope, and the file names of all recordings, respectively.

Once the data are imported using the methods exposed by the library, they can be converted into the MNE RawArray and Pandas data frame. One key difference between them is that MNE provides a powerful set of tools for EEG streams, but does not support the rest. For that reason, all data can be manipulated through data frames. Again, one method is necessary for the conversion:

```
raw = to_mne_eeg(eegstream = stream_eeg, line_freq = 50, filenames = filenames, nasion = [0,0,0],
   lpa = [0,0,0], rpa = [0,0,0])
```
where *eegstream* is the list of EEG data previously imported, *line\_freq* the powerline frequency of the region (50 for Europe), and *filenames* the list of file names imported. The three following lists correspond to the nasion fiducial point (nasion), the left periauricular fiducial point (lpa), and the right periauricular fiducial point (rpa). Those indicate a precise reference for the EEG sensors' position on the head [37].

The conversion to the Pandas data frame gives the flexibility to import only the streams in which the researcher is interested. This example of usage includes all the streams at once:

```
df = to_df(mne_eeg = raw, eegstream = stream_eeg, accstream = stream_acc, ppgstream = stream_ppg,
  gyrstream = stream_gyr)
```
the parameters being those variables that were already described. The resulting data frame contains blank spaces (Pandas NotaNumber data types) between rows in the last three columns. That happens because the sampling rates are different, as explained previously.

#### *3.2. Working with the BIDS Specification*

The BIDS specification establishes the directory structure to standardize how researchers store and share EEG recordings. The huge advantages make using it useful for working in a collaborative environment. To simplify the process, we created the *setup* structure. In order to export recordings, the BIDS file name paths are necessary, which is the information of the type BIDSPath object. Afterwards, the paths of the recordings included in *setup* are returned. Then, the first step is to execute the appropriate method provided for such a task:

```
bids_paths = create_bids_path(setup = setup)
```
After that, there is another method that uses those paths together with other parameters to finally export the recordings in the BIDS format. This example uses the *participants* structure to specify the characteristics of the subjects and the list of BIDSPath objects:

```
export_bids(raweeg = raw, bids_paths = bids, participants = participants, overwrite = False,
  verbose = False)
```
With that process, the recordings are exported to the directory indicated in the "root" field inside *setup*. In contrast, importing from the BIDS requires executing one method with a single parameter, which is *setup*. It returns the list of RawArray objects and the list of BIDSPath objects for the recordings in *setup*:

## raw, bids\_paths = import\_bids(setup = setup)

With the solution proposed, anyone can import directly into MNE to start working with Muse as if it were any other more advanced device, provided that other researchers have exported the recordings previously.
