# MuseStudio: Brain Activity Data Management Library for Low-Cost EEG Devices
## 4 Validation
### 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 \(\times\) 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 5 ms, 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 sub-millisecond 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 1 ms, 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.