Monday December 17, 2018 : Sogand roof code changes - Change the logger to sample only 3 datapoints per second /home/sogandm/experiment1/final_experiment/roof_proj/final_roof_code_KG.wrl Friday December 21, 2018 : extract data from logger data - convert string timestamp to int Wednesday December 23, 2018 : plan **Logger** - logger code needs to be written and tested on lab computer. `ROUTE navmap.start_logging TO changeName.start_logging` start logging function tells - `ROUTE navmap.triggerFallAni TO timer.startTime` and `ROUTE navmap.triggerFallAni TO OuchTime.startTime` - write comments in the code!!! - route is added for every single position that triggers a fall. - idea would be to add a count in the create_log function which is part of the changeName script that adds a route only thrice per second. - alternatively, some changes in the navmap script's fall_statement place where the values are actually coming in but that doesnt make any sense because you cannot actually time anything there - timer would be added in the create_log script that starts counting from the first instance that it was called and keeps incrementing. shoots out route only every thrice a second. random thrice? **3rd Jan - fix logger code** - python logger - get all entries in the row with matching timestamp **Heart : start here** - till then, python_csv manipulations. managed to get the first part of the timestamp into python from the logger output. now need to read the heart matrix, compare the first column to the timestamp, add a tolerance value of +/- 4 seconds and obtain HR column value. - get first column into python - match with timestamp - get HR column from same file **Kinect data** - study the format of the matlab kinect data - how to get data from .mat file to csv? csvwrite? - make a plan for kinect data Sunday December 30, 2018 : attempt at getting other col - got FieldValue from logger - possibly use dictionaries to get timestamp as key and FieldValue as value Saturday Jan 5, 2019 : op csv - op csv created - op csv has timestamp and head/ankle values python magic blogpost. In this project I had to amalgamate/coallate/combine data from the wireless tracking system installed in the cave, [intersense motion tracking system](http://www.intersense.com/pages/20/14) [Optical head tracking glasses, Optical hand tracker for small general-purpose targets, wireless interaction device - Flystick2](https://ar-tracking.com/) Sunday Jan 6, 2018 : time related - the timestamp for CAVE sensor is based on milliseconds and the Kinect is based on seconds. - converted ms to secs logger unix timestamp - added timestamp, posi/h, x, y, z from logger to csv - getting approx value of ts to get close enough hr - device name : garmin vivosmarthr+ - [looks like the sampling rate is once per minute since update 2016](https://forums.garmin.com/forum/into-sports/health-fitness/vivosmart-hr-hr/139477-thank-you-for-the-increased-hr-sampling-rate-with-firmware-3-40) - figure out tolerance after logger updated for 3 datapoints per second - kinect data business interesting install issues with scipy ~~~~~ easy_install pip error: can't create or remove files in install directory The following error occurred while trying to add or remove files in the installation directory: [Errno 2] No such file or directory: '/usr/local/lib/python3.6/dist-packages/test-easy-install-13706.write-test' The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was: /usr/local/lib/python3.6/dist-packages/ This directory does not currently exist. Please create it and try again, or choose a different installation directory (using the -d or --install-dir option). ~~~~~ must see what distutils path for python is, that might be causing a lot of my problems in life Monday Jan 7, 2019: did somethings - `alias python = /usr/bin/python2.7` - that makes scipy.io work - emailed sogand who sent over the csv of the kinect data, no need to mess with the .mat files -convert timestamp from the timestamp to unix. - get matching or closest approx timestamp and obtain row number or index number in that list. - get list at corresponding index of x, y, depth into csv. -each joint has its own columns, so add new columns to the headers and add the lists such that they are added in rows with existing logger_cave and hr data - [converting string time to datetime in python](https://stackoverflow.com/questions/16286991/converting-yyyy-mm-dd-hhmmss-date-time) - [make sure you do from datetime import datetime and not just import datetime](https://stackoverflow.com/questions/19480028/attributeerror-datetime-module-has-no-attribute-strptime) ~~~ >>> import time >>> import datetime >>> s = " '10-Nov-2018 10:37:39' File "", line 1 s = " '10-Nov-2018 10:37:39' ^ SyntaxError: EOL while scanning string literal >>> s = '10-Nov-2018 10:37:39' >>> d = datetime.strptime(s, "%d-%b-%Y-%H:%M:%S") Traceback (most recent call last): File "", line 1, in AttributeError: module 'datetime' has no attribute 'strptime' >>> from datetime import datetime >>> d = datetime.strptime(s, "%d-%b-%Y-%H:%M:%S") Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3.6/_strptime.py", line 565, in _strptime_datetime tt, fraction = _strptime(data_string, format) File "/usr/lib/python3.6/_strptime.py", line 362, in _strptime (data_string, format)) ValueError: time data '10-Nov-2018 10:37:39' does not match format '%d-%b-%Y-%H:%M:%S' >>> d = datetime.strptime(s, "%d-%b-%Y %H:%M:%S") >>> d datetime.datetime(2018, 11, 10, 10, 37, 39) >>> d.timestamp() 1541864259.0 ~~~ - [change python version willynilly](https://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux) - [convert datetime to unixtime in py2 and py3](https://stackoverflow.com/questions/19801727/convert-datetime-to-unix-timestamp-and-convert-it-back-in-python) -[math.isclose is a good idea to get closest value](https://stackoverflow.com/questions/5595425/what-is-the-best-way-to-compare-floats-for-almost-equality-in-python) -[isclose api](https://docs.python.org/3/library/math.html#math.isclose) Tuesday Jan 8, 2018: code sketch ~~~ def approx_index(val_ts_log, arr_ts_kinect): for ts in arr_ts_kinect: if(math.isclose(val_ts_log, ts ,rel_tol=0.5)): return arr_ts_kinect.index(ts) index=0 for item in InstantRealityData: # compares timestamp from cave with the kinect's and captures index index = arr_ts_kinect.index(item[4]) # if index found then append that row to a different list if (index != ValueError): X_Kinect.append(xcoords(index)) else: #find the closest approx value using isclose id = approx_index(item[4], arr_ts_kinect) X_Kinect.append(xcoords(id)) ~~~ how to get index with isclose and make sure that each ts entry in InstantRealityData has a corresponding xcoords from Kinect? isclose returns true or false if the value is within limits. Sunday Jan 13 2019: approx function - added the approx_index function as above and realized that I need the case where the tolerance is not maintained. - either adaptively change the tolerance or use a better solution - [find nearest using numpy](https://stackoverflow.com/questions/2566412/find-nearest-value-in-numpy-array) - still need the exact value, if found - AttributeError: module 'numpy' has no attribute 'searchsorted' - numpy had to be installed for python3. `sudo apt-get install python3-numpy` - how to test whether function works correctly - i've gotten some sorta data from the respective files into a csv, now just need to **test** whether its get the right values. - **change logger code sample rate**