Coder Social home page Coder Social logo

pyshimmer's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyshimmer's Issues

Calibration Data

Hi, I'm trying to deploying and end to end system, so I don't want that the user interact with Consensys or other Shimmer software.
The data I'm downloading it through the dock station.
Following your examples I could access to the raw data, but I can't access to the calibration one. Can you help me?

integration with pylsl

Hi thank you for this code. Could you explain how this could be intergrated with PyLSL to set up data streaming?
This would be a great merge with the LSL project to combine GSR with other sensors.

Storing and Event Marker to the recording

Hi, thanks for the great work with this API.

We are trying to integrate shimmer with a Psychopy https://www.psychopy.org/ experiment where we present some images and want to record the physiological signals using the shimmer kit.

Is there a way to send a "trigger"/ event marker using the API, such that I can synchronise the image presentation with the recording afterwards?

I hope this makes sense

After successful flashing, the device returns exception.

After successful firmware flashing, and rfcomm bind,
The test code provides below error.
'device reports readiness to read but returned no data'.
Should I do something between binding and run the testcode provided in repository?

Setting which channels are streamed

Dear Lukas,
first thank you for this library, I have been looking for a long time for a simpler way to access the shimmer via python.
One thing is missing is the possibility to set configure the Shimmer before starting to stream.

One should be able to select which channels are active (e.g., AC13, RAW GSR, SRC, etc) and the streaming frequency.
Maybe the features is already there, if that's the case, could you please provide me a snippet on how to use it?

Thank you!
Dario

Compatibility with new firmware LogAndStream v0.16.000

Hello,

Thank you for your impressive work on Shimmer devices.
I would like to know if you were able to test the compatibility of pyshimmer with the new version of the LogAndStream v0.16.000 firmware.
I await your feedback before updating my IMUs.

Thank you in advance,
Sincerely

Using the Bluetooth interface

Hey,
I followed the instructions of the readme. I also patched LogAndStream Firmware on my Shimmer3 EXG.
Everything work till the example Program of the BT API. I am working on an Ubuntu 18.04.4 LTS.
I got the Error:
My name is: Shimmer_86A5
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/usr/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/z-fcc/PycharmProjects/Test/pyshimmer/pyshimmer/bluetooth/bt_api.py", line 294, in _run_readloop
self._bluetooth.process_single_input_event()
File "/home/z-fcc/PycharmProjects/Test/pyshimmer/pyshimmer/bluetooth/bt_api.py", line 206, in process_single_input_event
self._process_data_packet()
File "/home/z-fcc/PycharmProjects/Test/pyshimmer/pyshimmer/bluetooth/bt_api.py", line 148, in _process_data_packet
cb(packet)
File "/home/z-fcc/PycharmProjects/Test/pyshimmer/test_hallo.py", line 26, in handler
cur_value = pkt[EChannelType.INTERNAL_ADC_13]
File "/home/z-fcc/PycharmProjects/Test/pyshimmer/pyshimmer/bluetooth/bt_commands.py", line 60, in getitem
return self._values[item]
KeyError: <EChannelType.INTERNAL_ADC_13: 19>

After that i have to keyinterrupt the session:

Traceback (most recent call last):
File "/home/z-fcc/PycharmProjects/Test/pyshimmer/test_hallo.py", line 43, in
shim_dev.stop_streaming()
File "/home/z-fcc/PycharmProjects/Test/pyshimmer/pyshimmer/bluetooth/bt_api.py", line 480, in stop_streaming
self._process_and_wait(StopStreamingCommand())
File "/home/z-fcc/PycharmProjects/Test/pyshimmer/pyshimmer/bluetooth/bt_api.py", line 301, in _process_and_wait
compl_obj.wait()
File "/home/z-fcc/PycharmProjects/Test/pyshimmer/pyshimmer/bluetooth/bt_api.py", line 50, in wait
self.__event.wait()
File "/usr/lib/python3.8/threading.py", line 558, in wait
signaled = self._cond.wait(timeout)
File "/usr/lib/python3.8/threading.py", line 302, in wait
waiter.acquire()
KeyboardInterrupt

I can't find the mistake by my own. Can you help me pls?

Dear StudentofGermany

Consensys reading logged data failed

Hello lumagi,

I use your Python API for my Shimmer3 EXG Unit and it works well. Thank you for that :)
Now I want to get the data from the Shimmer SD with Consensys. Sometimes it works, but more often an error occur.
Also I use your Reader API, but with the reader API the data have a different shape, like the streaming data. And i would prefer to have the data in the shape of the output from Consensys.
Could it be that the data got damaged or not closed with the Python API? Even if i use the stop() and shutdown() command?

Best StudentofGermany

Realign functionality is incorrect

Hi Lukas,

I think the realign functionality when loading data is incorrect. From my understanding it does the following right now:

  1. take the first timestamp as an initial offset for the new timestamps
  2. extrapolate from the first timestamp assuming a constant sampling rate while preserving the total number of observations
  3. interpolate the sensor data to match the newly generated timestamps

If the original timestamps are assumed to be correct, keeping the total number of observations in the second step will lead to an too early final timestamp. Instead, the correct approach would be to impute missing timestamps and interpolate new sensor values. Otherwise, if the timestamps are assumed to be incorrect, interpolating the sensor values in the third steps is wrong.

Working with the raw data from the Shimmer devices, I have made the following observations:

  • the difference between consecutive observations is almost always an integer multiple of the sample time (inverse of the sampling frequency)
  • the only exception I have seen so far is the time difference between the first and second sample: often this one is not an integer multiple of the sampling time

Using this observations, my current approach is to disable the realign functionality, drop the first sample and impute missing values by linear interpolation as outlined below.

import pandas as pd
import numpy as np
from pyshimmer import ShimmerReader, EChannelType

with open("ECG.sb3", "rb") as ecg_file:
    ecg_reader = ShimmerReader(ecg_file, realign=False)
    ecg_reader.load_file_data()
    ecg_fs = ecg_reader.sample_rate

    # convert to pandas dataframe and drop the first sample
    ecg_df = pd.DataFrame({
        "ecg1": ecg_reader[EChannelType.EXG_ADS1292R_1_CH1_24BIT][1:],
        "ecg2": ecg_reader[EChannelType.EXG_ADS1292R_1_CH2_24BIT][1:],
    }, index=ecg_reader[EChannelType.TIMESTAMP][1:])

    # add empty rows for the missing timestamps and interpolate the sensor values
    ecg_ts = pd.Index(np.arange(ecg_df.index[0], ecg_df.index[-1], 1/ecg_fs), name="timestamps")
    ecg_df = ecg_df.reindex(ecg_ts).reset_index().interpolate()

Concluding, I think it would be better to remove the realign functionality and let the users decide on how to deal with the presumably missing observations. Though, it may be helpful to raise a warning on detecting such gaps in the recording and, in particular, on detecting those which are are not an integer multiple of the sample time.

Cheers,
Matthias

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.