from datetime import datetime, date, time, timedelta from pampro import Time_Series, Channel, channel_inference, triaxial_calibration # Change the filenames as appropriate # Load sample activPAL data x, y, z = Channel.load_channels( "/pa/data/STVS/_data/activpal_data/714952C-AP1335893 18Nov13 10-00am for 7d 23h 14m.datx", "activPAL") # Autocalibrate the raw acceleration data x, y, z, (cal_params), (results), (misc) = triaxial_calibration.calibrate( x, y, z) # Infer some sample level info from the three channels - VM, ENMO, Pitch & Roll vm = channel_inference.infer_vector_magnitude(x, y, z) enmo = channel_inference.infer_enmo(vm) pitch, roll = channel_inference.infer_pitch_roll(x, y, z) # Create a time series object and add all signals to it ts = Time_Series.Time_Series("activPAL") ts.add_channels([x, y, z, vm, enmo, pitch, roll]) # Request some stats about the time series # In this case: mean ENMO, pitch and roll, and 10 degree cutpoints of pitch and roll angle_levels = [[-90, -80], [-80, -70], [-70, -60], [-60, -50], [-50, -40], [-40, -30], [-30, -20], [-20, -10], [-10, 0], [0, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90]] stat_dict = { "Pitch": angle_levels + ["mean"],
from datetime import datetime, date, time, timedelta from pampro import Time_Series, Channel, channel_inference, triaxial_calibration # Change the filenames as appropriate # Load sample activPAL data x, y, z = Channel.load_channels("/pa/data/STVS/_data/activpal_data/714952C-AP1335893 18Nov13 10-00am for 7d 23h 14m.datx", "activPAL") # Autocalibrate the raw acceleration data x, y, z, (cal_params), (results), (misc) = triaxial_calibration.calibrate(x, y, z) # Infer some sample level info from the three channels - VM, ENMO, Pitch & Roll vm = channel_inference.infer_vector_magnitude(x, y, z) enmo = channel_inference.infer_enmo(vm) pitch, roll = channel_inference.infer_pitch_roll(x, y, z) # Create a time series object and add all signals to it ts = Time_Series.Time_Series("activPAL") ts.add_channels([x,y,z,vm,enmo,pitch,roll]) # Request some stats about the time series # In this case: mean ENMO, pitch and roll, and 10 degree cutpoints of pitch and roll angle_levels = [[-90,-80],[-80,-70],[-70,-60],[-60,-50],[-50,-40],[-40,-30],[-30,-20],[-20,-10],[-10,0],[0,10],[10,20],[20,30],[30,40],[40,50],[50,60],[60,70],[70,80],[80,90]] stat_dict = {"Pitch":angle_levels+["mean"], "Roll":angle_levels+["mean"], "ENMO":["mean"]} # Get the output at 15 minute level quarter_hourly_results = ts.piecewise_statistics(timedelta(minutes=15), stat_dict) # Create a time series object to put the results in
from datetime import datetime, date, time, timedelta from pampro import Time_Series, Channel, channel_inference, Bout # Change filenames as appropriate # Request some interesting statistics - mean, min and max of the counts signal # ...plus basic cutpoints for Sedentary, Light, and Moderate to Vigorous stats = {"AG_Counts": [("generic", ["mean", "min", "max"]), ("cutpoints", [[0,99],[100,2999],[3000,99999]])]} # Load Actigraph data counts, header = Channel.load_channels("/pa/data/Tom/pampro/data/example_actigraph.DAT", "Actigraph", datetime_format="%m/%d/%Y") ts = Time_Series.Time_Series("Actigraph") ts.add_channel(counts) # Get a list of bouts where the monitor was & wasn't worn nonwear_bouts = channel_inference.infer_nonwear_actigraph(counts, zero_minutes=timedelta(minutes=90)) # Use that list to get a list of days of valid & invalid time invalid_bouts = channel_inference.infer_valid_days(counts, wear_bouts) # Since the cutpoints defined above only count positive data, negative values will be ignored # Where the monitor wasn't worn, set the count value to -1 # Where the monitor wasn't valid, set the count value to -2 counts.fill_windows(nonwear_bouts, fill_value=-1) counts.fill_windows(nonwear_bouts, fill_value=-2) # Get the summary level results summary_results = ts.summary_statistics(statistics=stats)
import random import copy from pampro import Time_Series, Channel, channel_inference, Bout execution_start = datetime.now() ts = Time_Series.Time_Series("Actiheart") # Load sample Actiheart data filename = os.path.join(os.path.dirname(__file__), '..', 'data\ARBOTW.txt') chans = Channel.load_channels(filename, "Actiheart") #ts.add_channels(chans) activity = chans[0] ecg = chans[1] # Calculate moving averages of the channels ecg_ma = ecg.moving_average(15) activity_ma = activity.moving_average(15) ts.add_channel(ecg_ma) ts.add_channel(activity_ma) blah = activity.time_derivative() blah = blah.moving_average(121) #ts.add_channel(blah)
from datetime import datetime, date, time, timedelta from pampro import Time_Series, Channel, channel_inference, Bout # Change filenames as appropriate # Request some interesting statistics - mean, min and max of the counts signal # ...plus basic cutpoints for Sedentary, Light, and Moderate to Vigorous stats = { "AG_Counts": [("generic", ["mean", "min", "max"]), ("cutpoints", [[0, 99], [100, 2999], [3000, 99999]])] } # Load Actigraph data counts, header = Channel.load_channels( "/pa/data/Tom/pampro/data/example_actigraph.DAT", "Actigraph", datetime_format="%m/%d/%Y") ts = Time_Series.Time_Series("Actigraph") ts.add_channel(counts) # Get a list of bouts where the monitor was & wasn't worn nonwear_bouts = channel_inference.infer_nonwear_actigraph( counts, zero_minutes=timedelta(minutes=90)) # Use that list to get a list of days of valid & invalid time invalid_bouts = channel_inference.infer_valid_days(counts, wear_bouts) # Since the cutpoints defined above only count positive data, negative values will be ignored # Where the monitor wasn't worn, set the count value to -1 # Where the monitor wasn't valid, set the count value to -2
from matplotlib.dates import DayLocator, HourLocator, DateFormatter, drange from datetime import datetime, date, time, timedelta from scipy import stats import random import copy from pampro import Time_Series, Channel, channel_inference, Bout execution_start = datetime.now() ts = Time_Series.Time_Series("Actiheart") # Load sample Actiheart data filename = os.path.join(os.path.dirname(__file__), '..', 'data\ARBOTW.txt') chans = Channel.load_channels(filename, "Actiheart") #ts.add_channels(chans) activity = chans[0] ecg = chans[1] # Calculate moving averages of the channels ecg_ma = ecg.moving_average(15) activity_ma = activity.moving_average(15) ts.add_channel(ecg_ma) ts.add_channel(activity_ma) blah = activity.time_derivative() blah = blah.moving_average(121) #ts.add_channel(blah) # Infer sleep from Actiheart channels