#!/usr/bin/env python # coding: utf-8 # # # # #
# | EEG Sensor - Unit Conversion | #
Tags | #pre-process☁eeg☁conversion | #
1 - Importation of the needed packages
# In[1]: # biosignalsnotebooks Python package with useful functions that support and complement the available Notebooks import biosignalsnotebooks as bsnb # Function used for creating a numpy array, where a mathematical operation can be applied to each entry # in an easy and automatic way. On the other side, linspace, here will be used for generation of a time-axis. from numpy import array, linspace #2 - Download of the sensor datasheet (from https://www.biosignalsplux.com/index.php/learn/documentation). In this case we are working with EEG, being our file located at http://www.biosignalsplux.com/datasheets/EEG_Sensor_Datasheet.pdf
# In[2]: # Embedding of .pdf file from IPython.display import IFrame IFrame(src="../../images/pre-process/unit_conversion_eeg/EEG_Sensor_Datasheet.pdf#page=3", width="100%", height="350") #3 - Extraction of the transfer function from the beginning of the second page
# \begin{equation} # EEG_{uV} = \frac{(\frac{ADC}{2^n} - \frac{1}{2}).VCC}{G_{EEG}} # \end{equation} # #$EEG_{uV}$ - EEG value in uV | #$ADC$ - Digital value sampled from the channel (initialism of "Analog to Digital Converter") | #$n$ - Number of bits of the channel (dependent on the chosen resolution specified on OpenSignals previously to the acquisition stage [8, 12 or 16 bits]) | #
$VCC$ - $3 \times 10^6 uV$ | #$G_{EEG}$ - 40000 | ## |
4 - Loading of data stored in biosignalsnotebooks own signal library
# In[3]: # Data loading data, header = bsnb.load_signal("https://drive.google.com/open?id=1XcYTmw5ZGoKBGNq1xM4FbFnoN4XORjwW", get_header=True) # In the following cell, some relevant information is stored inside variables. This relevant information includes the mac-address of the device, channel number and signal acquisition parameters such as resolution and sampling rate. # # For a detailed explanation of how to access this info, the "Signal Loading - Working with File Header" Notebook should be consulted. # In[4]: ch = "CH1" # Channel sr = 1000 # Sampling rate resolution = 16 # Resolution (number of available bits) # Access to acquired signal samples and storage inside a new variable. # In[5]: signal = data[ch] #5 - Final unit conversion (to uV) by applying the transfer function sample by sample
# Definition of $VCC$ and $G_{EEG}$ constants # In[6]: vcc = 3e6 # uV gain = 40000 # In[7]: signal_uv = (((array(signal) / 2**resolution) - 0.5) * vcc) / gain #6 - Time axis generation
# In[8]: time = bsnb.generate_time(signal_uv, sr) # Comparison between RAW and uV signal. # In[9]: bsnb.plot([time, time], [signal, signal_uv], y_axis_label=["Raw Data", "Electric Voltage (uV)"], grid_lines=1, grid_columns=2, grid_plot=True) # Similar Notebooks, dedicated to the unit conversion of other sensors, are available in the following "conversion" section of Notebooks Grouped by Tag page # # A list of PLUX's available sensors (and the respective datasheets) can be accessed at Sensors page . # # 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 ! # **Auxiliary Code Segment (should not be replicated by the user)** # In[10]: from biosignalsnotebooks.__notebook_support__ import css_style_apply css_style_apply() # In[11]: get_ipython().run_cell_magic('html', '', '\n')