Skip to main content

Communicate with your Empatica E4 in your Python scripts.

Project description

pyEmpatica

Parties Involved

Institution: Munroe Meyer Institute in the University of Nebraska Medical Center
Laboratory: Virtual Reality Laboratory
Advisor: Dr. James Gehringer
Developer: Walker Arce

Motivation

This Python library was written to facilitate biometric data collection from an Empatica E4. It also includes windowed sample collection, threaded error handling, and on-wrist detection.

Installation

This library is available for installation over pip using: pip install pyEmpatica

For developers, clone this repository, cd into the directory using either your virtual environment or your local environment, and run: python setup.py install

To actually utilize this library the Empatica Streaming Server is required, meaning this library is only compatible with Windows systems.

Usage

from pyempatica import EmpaticaClient, EmpaticaE4, EmpaticaDataStreams, EmpaticaServerConnectError
import time


try:
    client = EmpaticaClient()
    print("Connected to E4 Streaming Server...")
    client.list_connected_devices()
    print("Listing E4 devices...")
    time.sleep(1)
    if len(client.device_list) != 0:
        e4 = EmpaticaE4(client.device_list[0])
        if e4.connected:
            print("Connected to", str(client.device_list[0]), "device...")
            for stream in EmpaticaDataStreams.ALL_STREAMS:
                e4.subscribe_to_stream(stream)
            print("Subscribed to all streams, starting streaming...")
            e4.start_streaming()
            for i in range(0, 10):
                time.sleep(1)
                if not e4.on_wrist:
                    print("E4 is not on wrist, please put it on!")
                if e4.client.last_error:
                    print("Error encountered:", e4.client.last_error)
                    break
            e4.suspend_streaming()
            e4.disconnect()
            e4.close()
            print("E4 Errors")
            for key in e4.client.errors:
                print("\t", key, ":", e4.client.errors[key])
            print("E4 connection closed, saving readings...")
            e4.save_readings("readings.txt")
            print("Readings saved to readings.txt...")
        else:
            print("Could not connect to Empatica E4:", client.device_list[0])
    client.close()
    print("Cleaning up connections...")
except EmpaticaServerConnectError:
    print("Failed to connect to server, check that the E4 Streaming Server is open and connected to the BLE dongle.")

Before running this script, ensure the Empatica Streaming Server is up and running. This library is currently only compatible with Windows due to the Streaming Server dependency.

Citation

@misc{Arce_pyEmpatica_2021,
      author = {Arce, Walker and Gehringer, James},
      month = {8},
      title = {{pyEmpatica}},
      url = {https://github.com/Munroe-Meyer-Institute-VR-Laboratory/pyEmpatica},
      year = {2021}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyEmpatica-0.5.9.tar.gz (3.1 kB view details)

Uploaded Source

Built Distributions

pyEmpatica-0.5.9-py3.8.egg (11.8 kB view details)

Uploaded Source

pyEmpatica-0.5.9-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file pyEmpatica-0.5.9.tar.gz.

File metadata

  • Download URL: pyEmpatica-0.5.9.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for pyEmpatica-0.5.9.tar.gz
Algorithm Hash digest
SHA256 22139c6cf780381d3935f0c2c254b34cbc21ef845a4869678b2112c7ba3ea040
MD5 25ac6214a43c20ee778006138ff53170
BLAKE2b-256 1fd137f35b44a15b86c6fcfe502e8792d488ca30c0abf6a606b5165d3a9d71a5

See more details on using hashes here.

File details

Details for the file pyEmpatica-0.5.9-py3.8.egg.

File metadata

  • Download URL: pyEmpatica-0.5.9-py3.8.egg
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for pyEmpatica-0.5.9-py3.8.egg
Algorithm Hash digest
SHA256 1c5ede4a654f06ec88a5d76bb9cfbd9ae82d59b9d54fc0b9fc14a8e284287c44
MD5 5f2bef4623ece57dcda7c06132939f6d
BLAKE2b-256 4fa05a7ca7e7d55ca42ad987a38c0af0e25fb1fd373575cbe5d34a7970af8394

See more details on using hashes here.

File details

Details for the file pyEmpatica-0.5.9-py3-none-any.whl.

File metadata

  • Download URL: pyEmpatica-0.5.9-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for pyEmpatica-0.5.9-py3-none-any.whl
Algorithm Hash digest
SHA256 8362ee628eeebaa41a4a35d7ecb34377cb564ef6929acdffd4e0a76240d44414
MD5 90c73cd73b067268f98828127c0b5616
BLAKE2b-256 526a9f3fb42004009a4152afa21b570b1db60450679680c704406d27d96ffff3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page