Neural network-based Bluetooth synchronization of multiple wearable devices

Bluetooth-enabled wearables can be linked to form synchronized networks to provide insightful and representative data that is exceptionally beneficial in healthcare applications. However, synchronization can be affected by inevitable variations in the component’s performance from their ideal behavior. Here, we report an application-level solution that embeds a Neural network to analyze and overcome these variations. The neural network examines the timing at each wearable node, recognizes time shifts, and fine-tunes a virtual clock to make them operate in unison and thus achieve synchronization. We demonstrate the integration of multiple Kinematics Detectors to provide synchronized motion capture at a high frequency (200 Hz) that could be used for performing spatial and temporal interpolation in movement assessments. The technique presented in this work is general and independent from the physical layer used, and it can be potentially applied to any wireless communication protocol.


Supplementary Note 2: KiD Hardware layout
KiD comprises a commercial Microcontroller unit (STM32L476 7 , ST Microelectronics), a Bluetooth Low Energy module (BLE, BGM123A 8 , Blue Giga that supports BLE 4.2 specification 9 , and works as a network co-processor 10 ), a Lithium Polymer (LiPo) Battery Controller (BQ24230 11 , Texas Instruments), an Inertial Measurement Unit (IMU, MPU-9250 12 , Invensense) that consists of a nine-axis (gyroscope, accelerometer compass), and an onboard Quad Serial Peripheral Interface (Quad-SPI) Flash memory (S25FL256SAGNFI001 13 , Spansion/Cypress) as shown in Supplementary  Fig. 1a. In particular, a Real-Time Operating System (RTOS, here we use FreeRTOS: https://www.freertos.com) that runs in the Micro controller of the wearable device to actively manage and operate with the connected hardware components to implement routine tasks to function as a standalone system. A Battery controller regulates the battery charging and maintains a constant 3.3 V voltage supply for all the individual hardware components in the device. KiD can exchange data in two different modes: i) using the Bluetooth (BLE using Generic Attribute Profile, GATT) that receives the wireless commands (see Supplementary Table 1 for the KiD user-level commands) from the experimenter and control the data path of the Microcontroller accordingly, and ii) using the Micro USB port, to perform large data transfer (transmission of captured motion profiles to PC). Moreover, the KiD can use the Micro USB port for charging the battery. The IMU inside this device has a significant measurement range, that is ± 4G (± 39.23 ms 2 ) for the accelerometer, ±2000 • s −1 for the gyroscope and ± 4912 µT for the compass. The internal Flash memory (256 Mb) stores the inertial data from the IMU in a pre-defined format (see Supplementary Table 2). All these components are operated by a LiPo battery of 100 mAh capacity packed inside the Plastic inner case, resulting in a continuous operation time of approximately 2.5 hours, available to perform motion capture experiments (see Supplementary Fig. 1b). Figure 1. a, KiD with the hardware components that has an inbuilt Flash memory. b, Latency of the KiD when operated as a single device (the mean value found to be KiD 8 ms). c, The battery drain time is the maximum battery retention in KiD with a 100 mAh battery (the mean value found to be 179±7 minutes).

Supplementary
Structure of RTOS, the firmware RTOS does active multitasking and pre-emptive task scheduling, essentially permitting low-power management. The RTOS task scheduler is tightly coupled with hardware components to execute tasks synchronously or asynchronously, and its operation strongly depends on the device's Real-Time Clock (RTC). Each component in the hardware is conceptually classified (systematically probed by specific functions) and methodically prioritized to implement KiD functionalities. For instance, an IMU is partitioned into several runtime tasks, such as initialization, mode selection, filtering characteristics, and data transfer, to achieve motion capture at a high level. KiD comprises a few device commands (i.e., programmed using C++™) representing some primitive operations to define the Microcontroller internal data path. START command will initiate motion profile acquisition, MARK adds a unique label directly into the device's internal memory, and STOP stops motion capturing (see Supplementary Table 1). Every received command is processed and acknowledged instantaneously to update as soon as possible the device status. Moreover, KiD has a system minimal latency of 8 ms (see Supplementary Fig. 1c), making it highly responsive.

KiD's motion profile
Motion data is the kinematic information of a limb activity at a certain instant (see Supplementary Table 2). The Motion data is a direct component from the IMU, sampled at a given rate (200 Hz), and it contains a tri-axis accelerometer, gyroscope, compass, and Quaternions data (a scalar and vector component of orientation in a complex space). A motion profile is the accumulation of these Motion data. The Identifier in a motion profile does not provide Motion data, but rather it provides a unique label (marker to identify a task).

4/12
Supplementary Methods: KiD Software flow chart The User Interface (UI) is designed with Python™ 3.8 programming language, and Qt™ 5.2 (a cross-platform software development Framework). Python provides exceptional power in managing, interfacing, and driving the hardware and software 14 .
Supplementary Figure 2. Flow chart that shows the functionality of the user interface, with error messages and status messages.
Supplementary Figure 3. Flow chart that shows how the information or data are sent to the KiD from the Remote system. Here the device works on a Neural network. We demonstrate the network using TensorFlow. Fig. 6 shows the loss while training the network and the confusion matrix between the actual and predicted values for the simulated neural network. The designed model/network is further integrated into the UI to act as a virtual clock, thus predicting the wearable devices' time value to perform mutual synchronization.

7/12
Supplementary Discussion: Motor behavior or sensorimotor analysis -a neuroscience study -Human motor behavior encompasses learning, controlling, and executing actions such as locomotion, posture, tool use, and facial expression. The production and execution of these actions involve the recruitment of multiple complementary systems so that sensory information about our body and environment can be incorporated into our central and peripheral nervous systems. For example, when performing an everyday task, such as reaching for a light switch, we utilize our sensory systems to extract task-relevant information, such as the position of our hand and the distance of the switch. This information is then used to establish our current state relative to the given goal and, via comparison with our previous motor experiences, can be used to formulate a motor plan. Which will then be used to generate a motor command that specifies the required muscular forces to be produced to execute the action successfully.
Our ability to produce these behaviors is continuously evolving throughout our entire lives 15 , but the critical phase of sensorimotor development occurs during infancy and early childhood. Here children progressively develop new motor proficiencies such as rolling over by six months and walking by 18 months, allowing them to better to interact with their environment through perception, cognition, and social interaction 16 . Consequently, the child learns the basic three controls: predictive or feed-forward control, reactive control, and bio-mechanical control [17][18][19] .
Contrarily, children diagnosed with a neurological disorder later in life often show differences in motor function, atypical behavioral features, and delays in cognitive development during the sensorimotor development phase 20,21 . For this reason, the Center for Disease Control and Prevention (CDC) has recently devised a new developmental screening process that advises to periodically (9, 18, and 30 months) evaluating children for any developmental delays 22,23 . Generally, motor dysfunctions can be categorized as delays in motor activities, the appearance of atypical motor patterns that affect fine (reaching and grasping) and gross (supine, prone) motor skills, motor stereotypies (repetitive banging), and impairments in bilateral coordination. These all lead to spatial (incorrect body positioning) and temporal (poor movement timing, increased time to initiate movement) disorder 21,[24][25][26][27][28][29][30] .
The evaluation of sensorimotor behavior during childhood often relies on standardized tools, such as the movement assessment battery for children-2 (MABC-2) 31 , where an observer (trained practitioner, parent, etc.) scores the motor skills of the child against predefined criteria. Whilst many of these tools have been shown to have high validity alongside high test-retest reliability 31 , they do not necessarily allow for the tracking of subtle variations in movement kinematics, which provide invaluable insights into motor control processes beyond the outcome measures of motor performance within these tools. In this area, advances in motion capture technology can be leveraged to bring further objectivity to sensorimotor evaluation for both standardized assessment tools and during natural behavior, 32,33 .
We can infer much about child's cognitive states and ongoing decision-making processes just from the kinematics of their movements 34 . A growing number of laboratory studies are now using motion capture and detailed kinematic analyses to investigate questions related to social action and interaction in both typical 35 , and atypical populations [36][37][38] . These experiments, however, are bound to a laboratory.

Supplementary Discussion: Safety measures on wearables design for toddlers
Safety factor recommendations while designing wearable devices for toddlers are a crucial design criterion, (i) Neutral color: Children beyond four months naturally tend to attract colors. Hence, a neutral color must be chosen to discourage the child's attention. (ii) Size: Wearables should be conventionally larger than the children's typical esophagus 39 . Moreover, there should be a safety hole for allowing respiration in case of an accident. (iii) Accessories: Wearables should not have removable accessories (e.g., access media or battery). (iv) Material: Wearables must be made of materials that are devoid of allergens, strong, and resistant to wear and tear.
Kinematics Detector (KiD), by default, has two-layer protection, a silicone outer cover has a particular color (i.e., KiD is grey colored following a neutral color policy) to discourage the child's attention and a Plastic inner case to limit the circuitry access to the child 2 , as shown in Fig. 7a. This protective outer layer is meant to be larger than a children's typical esophagus 39 to avoid accidental swallowing. Moreover, KiDs do not need external media storage, such as a Secure Digital card for storing motion profiles, to avoid removing the media after every usage. Instead, we have designed KiDs with onboard memory to save motion profiles. KiD provides straightforward wearability (volume of 35×20×10 mm 3 , and weight 10 g) so that the devices can be worn on the toddlers' limbs (e.g., wrist, arm, leg, torso, and ankle, see the identified at positions 1, 2, 3, and 4 in Fig. 7b) for capturing the associated motion profile. Considering safety factors, short-lived experiments are advisable for toddlers, and hence a battery capacity of 100 mAh can be enough for a simple neurological experiment among toddlers.