Skip to content
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

Trying to fix pickle #8

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.DS_Store
*.pyc
__pycache__
logs/
logs/
data/
11 changes: 9 additions & 2 deletions functions/signal_processing_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
"""
import sys
import logging
import resampy # to resample frequency

import numpy as np
from scipy import signal
from multiprocessing import cpu_count
import resampy
import math
try:
from multiprocessing import cpu_count
except ImportError:
def cpu_count():
return 1

try:
from joblib import Parallel
Expand Down Expand Up @@ -100,6 +106,7 @@ def resample_acceleration(data, from_hz, to_hz, use_parallel = False, num_jobs =

# calculate number of 1 sec samples (note that hz is the frequency per second)
num_seconds = len(data) // from_hz
# num_seconds = len(data)/from_hz)

# calculate number of new samples required when data is resampled
num_samples = num_seconds * to_hz
Expand Down
4 changes: 4 additions & 0 deletions infer_nw_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,15 @@ def parse_arguments():

# read file as numpy array
data = np.load(file)
data.allow_pickle = True;

# extract raw acceleration data from numpy.
actigraph_acc = data['raw_data']

# read meta data from file
meta_data = data['meta_data']
if type(meta_data) is np.ndarray:
meta_data = meta_data.tolist()

# convert acceleration values to g values
actigraph_acc = rescale_log_data(log_data = actigraph_acc, acceleration_scale = meta_data['Acceleration_Scale'])
Expand Down
26 changes: 26 additions & 0 deletions read_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os
import numpy as np
import tempfile as tmp

# import functions
from functions.helper_functions import set_start, set_end, read_directory, create_directory
from gt3x import unzip_gt3x_file, extract_info, extract_log, create_time_array, rescale_log_data


file = "data/AI12_NEO1F09120034_2017-09-25.gt3x"
save_folder = tmp.TemporaryDirectory()
save_folder = save_folder.name
delete_source_file = False
# unzip .gt3x file and get the file location of the binary log.bin (which contains the raw data) and the info.txt which contains the meta-data
log_bin, info_txt, _, _ = unzip_gt3x_file(f = file, save_location = save_folder, delete_source_file = delete_source_file)

# get meta data from info.txt file
meta_data = extract_info(info_txt)

# read raw data from binary data
log_data, time_data = extract_log(log_bin = log_bin, acceleration_scale = float(meta_data['Acceleration_Scale']), sample_rate = int(meta_data['Sample_Rate']), use_scaling = False)

actigraph_acc = rescale_log_data(log_data = log_data, acceleration_scale = meta_data['Acceleration_Scale'])

# convert time data to correct time series array with correct miliseconds values
actigraph_time = create_time_array(time_data)
2 changes: 1 addition & 1 deletion read_raw_gt3x.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def process_gt3x_file(idx, total, file, save_folder, delete_source_file, delete_


# unzip .gt3x file and get the file location of the binary log.bin (which contains the raw data) and the info.txt which contains the meta-data
# log_bin, info_txt = unzip_gt3x_file(f = file, save_location = save_folder, delete_source_file = delete_source_file)
# log_bin, info_txt, _, _ = unzip_gt3x_file(f = file, save_location = save_folder, delete_source_file = delete_source_file)

# # get meta data from info.txt file
# meta_data = extract_info(info_txt)
Expand Down