|
Synchrony - Accelerometer Signal |
Tags | pre-process☁synchrony☁accelerometer |
OpenSignals software allows to acquire signals from multiple devices at the same time and using the synchronisation cable, available in https://store.plux.info/cables/231-synchronization-cable.html , the signals are automatically sinchronised in real time.
However, there might be cases in which it is not possible to use the synchronisation cable and the acquired signals may be dephased. In some cases, it might be helpful to synchronise the signals in order to compare them in the time domain. This can be achieved after acquisition by using the </span> biosignalsnotebooks Python package.
The low-level explanation of synchronisation techniques is available in the
Device Synchronisation - Cable, Light and Sound Approaches
notebook.
In this
Jupyter Notebook
we will show how you can use the
accelerometer sensor
to synchronise all of your signals acquired with different devices.
1 - Import the required packages
In order to have access to all functionalities of </span> biosignalsnotebooks Python package, we have to import it.# Import biosignalsnotebooks package
import biosignalsnotebooks as bsnb
2 - Open the files to see the signals
In this case, two accelerometer signals were acquired at the same time but dephased, because the acquisitions did not start at the same instant. In order to use this type of signals to synchronise data, it is suggested to produce a distinctive event where it can be visually possible to perceive the instant of synchronisation. Accelerometers acquire three-dimensional data on the x, y and z axis.path = '../../signal_samples/'
file_name_1 = path + 'sync_acc_1.txt'
file_name_2 = path + 'sync_acc_2.txt'
file_1 = bsnb.load(file_name_1)
file_2 = bsnb.load(file_name_2)
3 - Synchronising the signals
The last step consists on the application of the function synchronise_signals , available in the biosignalsnotebooks Python package, using the signals of the channels that we want.channels = ('CH3', 'CH3')
dephase, signal_1, signal_2 = bsnb.synchronise_signals(file_1[channels[0]], file_2[channels[1]])
3.1 - Create synchronised files
It is possible to synchronise the signals of different files or even from the same file and to produce a new file with the synchronised signals. In this case, all of the signals available in the files(s) will be synchronised - even when there is more than one channel in each file.# path to all the input files - txt and h5 files
input_paths = ([path + 'sync_acc_1.txt', path + 'sync_acc_2.txt'], [path + 'sync_acc_1.h5', path + 'sync_acc_2.h5'])
# channels of the signals used in synchrony
channels = (3, 3)
# path to the generated file
new_path = path + 'new_file'
# Function to generate the new file with all the synchronised signals
bsnb.create_synchronised_files(input_paths)
Now we have created a new file containing the synchronised signals of the input file(s). The generated file can be opened by OpenSignals or in Python using the load function of the biosignalsnotebooks package, because they are structured as the files produced by the software.
We hope that you have enjoyed this guide.
biosignalsnotebooks
is an environment in continuous expansion, so don"t stop your journey and learn more with the remaining
Notebooks
!