shaheen-syed / CNN-Non-Wear-Time-Algorithm

A novel algorithm to detect non-wear time from raw accelerometer data using convolutional neural networks.
7 stars 3 forks source link

Resampling with same Hz #9

Open muschellij2 opened 3 years ago

muschellij2 commented 3 years ago

I opened this: https://github.com/bmcfee/resampy/issues/76, but I think a large issuet

I think this is OK for actually resampled data (e.g. 30hz to 100hz), but it seems odd to give back a different array of data if the sampling frequency is already 100Hz.

import gt3x

accdata, dates, meta = gt3x.read_gt3x("/Users/johnmuschelli/Library/R/4.0/library/pygt3x/extdata/TAS1H30182785_2019-09-17.gt3x")

old_rate = int(meta['Sample_Rate'])
new_rate = 100

from functions import signal_processing_functions as sig

newacc = sig.resample_acceleration(accdata, from_hz = old_rate, 
    to_hz = new_rate)
accdata
#> array([[ 0.        ,  0.0078125 ,  **0.99609375**],
       [ 0.015625  ,  0.        ,  **1.0078125** ],
       [ 0.01953125, -0.0078125 ,  1.00390625],
       ...,
       [-0.0078125 , -1.03125   ,  0.0234375 ],
       [-0.0078125 , -1.02734375,  0.02734375],
       [-0.0078125 , -1.03125   ,  0.01953125]])
newacc
#> array([[ 8.55656854e-05,  7.41243251e-03,  **9.70546013e-01**],
       [ 1.55232568e-02,  4.15953172e-04,  **1.03304702e+00**],
       [ 1.96514211e-02, -8.24255770e-03,  9.79292690e-01],
       ...,
       [-7.39899911e-03, -1.00475948e+00,  2.28906658e-02],
       [-8.19142534e-03, -1.05449253e+00,  2.79129544e-02],
       [-7.46866818e-03, -1.00377634e+00,  1.89510810e-02]])
newacc == accdata
#> array([[False, False, False],
       [False, False, False],
       [False, False, False],
       ...,
       [False, False, False],
       [False, False, False],
       [False, False, False]])

Created on 2020-11-29 by the reprexpy package