Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import numpy as np
from functions.raw_non_wear_functions import cnn_nw_algorithm, hees_2013_calculate_non_wear_time, raw_baseline_calculate_non_wear_time

# read raw acceleration from numpy array. Since the data was not scaled, we are dividing it by the acceleration scale to obtain acceleration values in gravity units
raw_acc = np.load(file = os.path.join(os.sep, 'Users', 'shaheen.syed', 'PA', 'acceleration.npz'))['raw_data'] / 256.
raw_acc = np.load(file = os.path.join(os.sep, 'Users', 'shaheen.syed', 'PA', 'acceleration.npz'), allow_pickle=True)['raw_data'] / 256.
# how to encode wear time
wt_encoding = 0
# how to encode non-wear time
Expand Down Expand Up @@ -128,4 +128,4 @@ xyz_nw = raw_baseline_calculate_non_wear_time(raw_acc = raw_acc, std_threshold =
# VMY baseline method
vmu_nw = raw_baseline_calculate_non_wear_time(raw_acc = raw_acc, std_threshold = 0.004, min_interval = 105, hz = hz, use_vmu = True, nwt_encoding = nwt_encoding, wt_encoding = wt_encoding)

```
```
2 changes: 1 addition & 1 deletion examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from functions.raw_non_wear_functions import cnn_nw_algorithm, hees_2013_calculate_non_wear_time, raw_baseline_calculate_non_wear_time

# read raw acceleration from numpy array. Since the data was not scaled, we are dividing it by the acceleration scale to obtain acceleration values in gravity units
raw_acc = np.load(file = os.path.join(os.sep, 'Users', 'shaheen.syed', 'PA', 'acceleration.npz'))['raw_data'] / 256.
raw_acc = np.load(file = os.path.join(os.sep, 'Users', 'shaheen.syed', 'PA', 'acceleration.npz'), allow_pickle=True)['raw_data'] / 256.
# how to encode wear time
wt_encoding = 0
# how to encode non-wear time
Expand Down
18 changes: 9 additions & 9 deletions infer_nw_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def parse_arguments():

# set the logger and start time
tic, process, logging = set_start()

# pars command line arguments
args = parse_arguments()

Expand Down Expand Up @@ -78,35 +78,35 @@ def parse_arguments():
"""

# read file as numpy array
data = np.load(file)
data = np.load(file, allow_pickle=True)
# extract raw acceleration data from numpy.
actigraph_acc = data['raw_data']

# read meta data from file
meta_data = data['meta_data']
meta_data = data['meta_data'].item()

# convert acceleration values to g values
actigraph_acc = rescale_log_data(log_data = actigraph_acc, acceleration_scale = meta_data['Acceleration_Scale'])

# extract time data
# extract time data
actigraph_time = data['time_data']
# convert time data to correct time series array with correct miliseconds values
actigraph_time = create_time_array(actigraph_time, hz = int(meta_data['Sample_Rate']))

"""
INFER NON-WEAR TIME
"""
# call function to infer non-wear time
nw_vector, nw_data = cnn_nw_algorithm( raw_acc = actigraph_acc,
hz = int(meta_data['Sample_Rate']),
cnn_model_file = cnn_model_file,
cnn_model_file = cnn_model_file,
std_threshold = std_threshold,
distance_in_min = distance_in_min,
episode_window_sec = episode_window_sec,
edge_true_or_false = edge_true_or_false,
start_stop_label_decision = start_stop_label_decision
)

"""
POST PROCESS DATA
"""
Expand Down Expand Up @@ -136,9 +136,9 @@ def parse_arguments():
save_csv(data = nw_data, name = 'non_wear_data_indexes', folder = os.path.dirname(file))
# save human readable start and stop timestamps as CSV file
save_csv(data = nw_data_timestamps, name = 'non_wear_data_timestamps', folder = os.path.dirname(file))

else:
logging.warning('Folder argument not provided. Please specify the -fd or --folder argument which specifies where raw acceleration data is stored in numpy format.')

# verbose
set_end(tic, process)
set_end(tic, process)
20 changes: 10 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
numpy
pandas
joblib
psutil
glob2
tensorflow>=2.0.0
bitstring
scipy
resampy
gt3x>=0.0.2
tensorflow==2.4.1
pandas==1.2.4
scipy==1.6.2
psutil==5.8.0
glob2==0.7
resampy==0.2.2
joblib==1.0.1
gt3x==0.1.1
numpy==1.19.5
bitstring==3.1.7