*4.2. Latency Test*

Some experiments with MuseStudio may require real-time data visualization, which is an included feature in the library. However, researchers may have special requirements in terms of the latency between the time an event occurs in the brain of a participant and the moment it is visible on screen. For this reason, we performed a latency test with all the different update intervals selectable. Those intervals were: 200 ms, 500 ms, 750 ms, 1 s, 1.5 s, 2 s, 3 s, and 5 s.

The design of the experiment measured the latency with real events, having a subject wearing Muse and a computer with the device connected. In particular, the device is able to capture eye blinks clearly, so this was the event that was going to be recorded repeatedly with the slow-motion camera of a Samsung Galaxy S20+ (Sony IMX555 main camera sensor) at a resolution of 1920 × 1080 and 240 frames per second. Then, the procedure consisted of a slow-motion camera pointing at the screen showing the real-time graphs and the subject performing the experiment, simultaneously. Afterwards, the subject was instructed to blink his/her eyes exactly when the graph updated. We are aware that there might be a slight variability regarding the time at which the subject blinks, so the experiment was repeated ten times with all the intervals, and then, we calculated the arithmetic mean between the values. Figure 7 shows a summary of the recording stage of the experiment. When that phase was finished, we loaded the video into an editor to count the frames between the blinks and the instant of those shown on screen. Once the frames were collected, we converted them into seconds knowing that 240 frames is equivalent to 1 s.

For the sake of reproducibility, Muse was connected to a computer with these specifications: Intel Core i7-9750H (base frequency 2.60 GHz and turbo frequency 4.50 GHz), 16 GB of RAM, and SSD (although no brain data were stored). The screen had an input lag of 5ms, which was discounted to each measurement. The connection with another computer to the server was not contemplated because that would add the latency of the network. Time synchronization was ensured by the LSL protocol [40], which achieves submillisecond accuracy on a local network without further action on practically all consumer PC hardware. The results are presented in Figure 8 through a bar plot that includes the variability of the measurements for each interval. It is observable that update intervals equal to or greater than one second showed the events with the correct timing and the expected latency. However, less than one-second values did not show a latency equivalent to the interval. This happened due to a combination of two different sources of delay: the time it takes for the device to send data and the time needed for the computer to attach the new values, create a visual representation, and update the interface. The difference in latency between those values was around 1ms, which did not correspond to the interval chosen. Nevertheless, we maintained those options because higher-performing CPUs are able to reduce the latency tested.

**Figure 7.** Design of the setup for the latency test.

**Figure 8.** Results of the latency test.

#### **5. Discussion**

The objective of the study covered the creation of an open-source software product that allows working with brain activity data and facilitates the management of activities designed for performing experiments. In particular, Muse was chosen as the low-cost device to allow researchers to focus on their research.

The library MuseStudio provides a set of tools for management activities, including the import, conversion, export, and visualization of brain data. Thus, the solution adapts to real-time usage and recorded experiments. Moreover, those steps can be performed far from the place where the trial is being conducted, due to the tools provided.

The internal features of MuseStudio are the following: open-source cross-platform library; developed for Python 3 [41]; complies with the best practices in data analysis [2] and the recommendations from the OHBM COBIDAS MEEG committee [6]; allows visualizing real-time data from multiple devices concurrently without being in the same place; imports data from unlimited raw recordings and multiple devices in a structured manner; exports using the standard for EEG data; converts to MNE- and Pandas-compatible data formats. These internal features drove the MuseStudio development activities. Moreover, other external features were identified by two external experts in neuroscience.

Making the library open-source allows its usage and modification without worries, so other researchers and people interested in this field can use low-cost and minimally invasive devices in their experiments. In addition, the community can help by introducing new features and adapt the library to their particular necessities. It has been developed for all three major operating systems (Windows, Linux, and macOS) to ensure compatibility. As a prerequisite to use the library, having prior knowledge of Python is required. Python has converted into the preferred programming language for data science [41].

MuseStudio complies and follows the recommendations provided by the BIDS standard for neuroscience [42] to manage data recordings adequately. Therefore, it can import and export the data associated with multiple subjects and sessions using multiple devices. These data are not limited to the tasks that Muse natively supports, such as meditation. Instead, it supports any other validated activity. Following the BIDS [43] standard allows sharing data between partners and replicating experiments easily through the import and export functionalities.

The external features of MuseStudio were validated by three external experts in neuroscience. They validated the presence of these features and their relevance. All these features, initially established by using the DESMET method, were identified and properly evaluated in the current version of MuseStudio.

In MuseStudio, there are no limitations softwarewise, except for the lack of a guided user interface. This software shortcoming was previously identified and discussed. It

can be overcome by designing and integrating user interface forms to provide session and participant descriptors and identifiers. Hardwarewise, the number of Muse devices simultaneously connected to a single computer is limited by the bandwidth and throughput of the Bluetooth module, which is different across machines. The library supports pausing the visualization at some point to explore a certain moment in time, and if the connection is lost, it automatically continues after reconnection. Additionally, the latency was tested with real-world usage in a controlled environment to maximize the delay between an event and its visualization on screen. The results showed exact timing from a 1 s update interval and times that varied depending on the interval if it was lower than 1 s. Nonetheless, those can be further reduced using a computer with better specifications.

In summary, MuseStudio shows that low-cost devices related to neuroscience, such as Muse, can have a complete set of tools to manage brain data. It offers features that increase flexibility, reliability, and the ease of data management.
