-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Old GT3X ending parsed wrong #1
Comments
I managed to read the content according the the NHANES format described here: I converted the .gt3x file with ActiLife to a .csv file and the acceleration values do match up. Note that the order is YXZ whereas the ActilLife export is XYZ. However, there is repetition in the csv file of some values for a very long duration; idle mode? I guess this is the imputation you talked about? I am unable to find out where to identify what values need to be repeated for which duration. Any ideas? Also, I'm reading the bytes and converting them to bits and then taking 12 bits to get a single acceleration value. So for every 3 bytes we get 24 bits, which is 2 acceleration values. In the end, I am left with a remainder which I simply trim. Some quick code here: # file size
file_size = os.path.getsize(file)
# # total number of samples
# num_samples = int(np.floor(file_size * 8 / 36))
hz = 30
axes = 3
scale = 341.0
# open the log.bin file in binary mode
with open(file, mode='rb') as file:
# hold acceleration values
values = []
# read bytes as bits
payload_bits = Bits(bytes = file.read(file_size)).bin
# extract 12 bits as 1 acceleration value and add them to a list
for i in range(0,len(payload_bits),12):
# check if i is larger than file size
if i + 12 > file_size:
break
# extract the 12 bit as a string
bitstring = payload_bits[i:i+12]
# convert to acceleration value
acc_value = Bits(bin=bitstring).int
# add to list
values.append(acc_value)
# convert list to numpy array
acc = np.array(values)
# cut of last values
acc_cut = len(acc) % (hz * axes)
# cut of
acc = acc[:-acc_cut]
# resize to samples x axes
acc = acc.reshape(len(acc) // 3, 3)
# scale
acc = acc / scale |
I have made additions to gt3x over the past few days looking at this as well. I think https://github.com/muschellij2/gt3x/blob/master/gt3x/gt3x_functions.py#L622 should fix it. If the bits are 8, then it adds |
There seems to be some overflow issue here or reading in some data I shouldn't be (like after the file length)
Created on 2020-08-31 by the reprex package (v0.3.0)
Session info
The text was updated successfully, but these errors were encountered: