Source code for brainaccess.core.device_features
import ctypes
from brainaccess.core import _dll
from brainaccess.core.device_info import DeviceInfo
from brainaccess.utils.exceptions import BrainAccessException
# has_gyro()
_dll.ba_core_device_features_has_gyro.argtypes = [ctypes.c_void_p]
_dll.ba_core_device_features_has_gyro.restype = ctypes.c_bool
# has_accel()
_dll.ba_core_device_features_has_accel.argtypes = [ctypes.c_void_p]
_dll.ba_core_device_features_has_accel.restype = ctypes.c_bool
# is_bipolar()
_dll.ba_core_device_features_is_bipolar.argtypes = [ctypes.c_void_p]
_dll.ba_core_device_features_is_bipolar.restype = ctypes.c_bool
# electrode_count()
_dll.ba_core_device_features_electrode_count.argtypes = [ctypes.c_void_p]
_dll.ba_core_device_features_electrode_count.restype = ctypes.c_uint8
# device_features_get()
_dll.ba_core_device_features_get.argtypes = [ctypes.POINTER(DeviceInfo)]
_dll.ba_core_device_features_get.restype = ctypes.c_void_p
[docs]
class DeviceFeatures:
"""What a headset model can do: sensors and electrode layout.
Parameters
----------
device_info : ~brainaccess.core.device_info.DeviceInfo
Information about the headset, from
:meth:`~brainaccess.core.eeg_manager.EEGManager.get_device_info`.
Raises
------
BrainAccessException
If the headset model is not recognized.
Examples
--------
>>> features = DeviceFeatures(manager.get_device_info())
>>> features.electrode_count()
8
"""
def __init__(self, device_info):
self._handle = _dll.ba_core_device_features_get(ctypes.pointer(device_info))
if self._handle is None:
raise BrainAccessException("Unknown device")
[docs]
def has_gyro(self) -> bool:
"""Tell whether the headset has a gyroscope.
Returns
-------
bool
``True`` if it has a gyroscope.
"""
return _dll.ba_core_device_features_has_gyro(self._handle)
[docs]
def has_accel(self) -> bool:
"""Tell whether the headset has an accelerometer.
Returns
-------
bool
``True`` if it has an accelerometer.
"""
return _dll.ba_core_device_features_has_accel(self._handle)
[docs]
def is_bipolar(self) -> bool:
"""Tell whether the electrodes are bipolar.
A bipolar electrode has a positive (P) and a negative (N) contact, and its
signal is the difference between the two. The contact status is then
reported per contact (``ELECTRODE_CONTACT_P`` and ``ELECTRODE_CONTACT_N``
in :mod:`brainaccess.core.eeg_channel`).
Returns
-------
bool
``True`` if the electrodes are bipolar.
"""
return _dll.ba_core_device_features_is_bipolar(self._handle)
[docs]
def electrode_count(self) -> int:
"""Get the number of electrodes of the headset.
Returns
-------
int
The number of electrodes available for recording.
"""
return _dll.ba_core_device_features_electrode_count(self._handle)