Package: sit2standpy
Sit2StandPySit2StandPyis an open source Python package that uses novel algorithms to first detect Sit-to-Stand transitions
from lumbar-mounted accelerometer data, and then provide quantitative metrics assessing the performance of the
transitions. A modular framework is employed that would allow for easy modification of parts of the algorithm to suit
other specific requirements, while still keeping core elements of the algorithm intact. As gyroscopes impose a
significant detriment to battery life due to power consumption,Sit2StandPy's use of acceleration only allows for
a single sensor to collect days worth of analyzable data.DocumentationFull documentationis available, containing API references,
installation instructions, and usage examples.RequirementsPython >= 3.7NumpypandasScipypywaveletsudatetimeTo run the tests, additionally the following are neededpytesth5pyInstallationRun in the command line/terminal:pipinstallsit2standpypip will automatically collect and install the required packages by default. If you do not want this behavior, runpipinstallsit2standpy--no-depsTestingAutomated tests can be run withpytestthrough the terminal:pytest--pyargssit2standpy.tests-vTo run the v2 interface tests:pytest--pyargssit2standpy.v2.tests-vV2 InterfaceStarting with version 1.1.0 a new "v2" interface is available alongside the old interface. Following a sequential
pipeline layout, a basic usage example is:importsit2standpyass2s# transform the data into the appropriate format for H5 or dictionary# note that "data_transform_function" is your own function to achieve the appropriate format# if you are looking for a quick example data loader function, you can use the one at# https://gist.github.com/LukasAdamowicz/b8481ef32e4beeb77c80f29f34c8045edata=<data_transform/loader_function>(acceleration_data)sequence=s2s.v2.Sequential()sequence.add(s2s.v2.WindowDays(hours=[8,20]))# window the data into days using only the hours from 8:00 to 20:00sequence.add(s2s.v2.AccelerationFilter())# Do the initial filtering and processing requiredsequence.add(s2s.v2.Detector(stillness_constraint=True))# Detect the transitions using the stillness constraintsequence.predict(data)# predict and save the results into datas2s.v2.tabulate_results(data,path_to_csv_output,method='stillness')# tabulate the results to a csv for easy readingOld UsageBasic use is accomplished through theSit2Standobject:importsit2standpyass2simportnumpyasnp# importing sample datafromsysimportversion_infoifversion_info<(3,7):frompkg_resourcesimportresource_filenameelse:fromimportlibimportresources# locate the sample data and load it (depending on python version)ifversion_info<(3,7):file_path=resource_filename('sit2standpy','data/sample.csv')data=np.loadtxt(file_path,delimiter=',')else:withresources.path('sit2standpy.data','sample.csv')asfile_path:data=np.loadtxt(file_path,delimiter=',')# separate the stored sample datatime=data[:,0]accel=data[:,1:]# initialize the framework for detectionths={'stand displacement':0.125,'transition velocity':0.3,'accel moving avg':0.15,'accel moving std':0.1,'jerk moving avg':2.5,'jerk moving std':3}sts=s2s.Sit2Stand(method='stillness',gravity=9.84,thresholds=ths,long_still=0.3,still_window=0.3,duration_factor=4,displacement_factor=0.6,lmin_kwargs={'height':-9.5},power_band=[0,0.5],power_peak_kwargs={'distance':128},power_stdev_height=True)# run the sit-to-stand detectionSiSt=sts.apply(accel,time,time_units='us')# print the list of Transition objects, stored as a dictionary with the time they occurredprint(SiSt)sit_to_standsis then a dictionary ofTransitionobjects containing information about each of the transitions
detectedContributingContributions are welcome.  Please see thecontributionsdocument for more information