Package: nimbaldetach
nimbaldetachDETACH (Device Temperature and Acceleration Change) algorithm detects non-wear periods for body-worn accelerometers
by integrating a ‘rate-of-change’ criterion for temperature into a combined temperature-acceleration algorithm.PublicationVert, A., Weber, K. S., Thai, V., Turner, E., Beyer, K. B., Cornish, B. F., Godkin, F. E., Wong, C., McIlroy, W. E.,
& Van Ooteghem, K. (2022). Detecting accelerometer non-wear periods using change in acceleration combined with
rate-of-change in temperature.BMC Medical Research Methodology, 22.https://doi.org/10.1186/s12874-022-01633-6Using the DETACH AlgorithmThe DETACH algorithm is stored as a function called nimbaldetach within the /src/nimbaldetach/nimbaldetach.py Python file.The function itself is defined as followsnimbaldetach(x_values,y_values,z_values,temperature_values,accel_freq=75,temperature_freq=0.25,std_thresh_mg=8.0,low_temperature_cutoff=26,high_temperature_cutoff=30,temp_dec_roc=-0.2,temp_inc_roc=0.1,num_axes=2,quiet=False)Input ArgumentsThe input arguments and their definitions are listed in the table below:ArgumentData TypeOptional (default value) or RequiredDescriptionx_valuesNumPy ArrayRequiredx-axis accelerometer valuesy_valuesNumPy ArrayRequiredy-axis accelerometer valuesz_valuesNumPy ArrayRequiredx-axis accelerometer valuestemperature_valuesNumPy ArrayRequiredTemperature valuesaccel_freqfloatOptional (75)Frequency of the accelerometer in Hztemperature_freqfloatOptional (0.25)Frequency of the temperature in Hzstd_thresh_mgfloatOptional (8.0)The value which the standard deviation (STD) of an axis in the window must be below to trigger non-wearlow_temperature_cutofffloatOptional (26.0)Low temperature threshold for non-wear classification (see paper for more details)high_temperature_cutofffloatOptional (30.0)High temperature threshold for non-wear classification (see paper for more details)temp_dec_rocfloatOptional (-0.2)Temperature decrease rate-of-change threshold for non-wear classification (see paper for more details)temp_inc_rocfloatOptional (0.1)Temperature increase rate-of-change threshold for non-wear classification (see paper for more details)num_axesintOptional (2)Number of axes that must be below the STD threshold to be considered non-wearquietboolOptional (False)Whether or not to quiet print statements.ReturnsThe algorithm returns a tuple with two objects:start_stop_df: A pandas DataFrame with the start and end datapoints of the non-wear bouts.vert_nonwear_array: A numpy array with the same length of the accelerometer data marked as either wear (0) or non-wear (1)ExampleExample python code to determine the percentage of non-wear time fromfromsrc.nimbaldetach.nimbaldetachimportnimbaldetachimportnumpyasnp# Load Dataaccelerometer_vals=np.load("path\to\raw\accelerometer.npy")temperature_values=np.load("path\to\raw\temperature.npy")x_values=accelerometer_vals[0]y_values=accelerometer_vals[1]z_values=accelerometer_vals[2]# Define Frequenciesaccel_freq=75temperature_freq=0.25# Calculate Non-wearstart_stop_df,nonwear_array=nimbaldetach(x_values=x_values,y_values=y_values,z_values=z_values,temperature_values=temperature_values,accel_freq=accel_freq,temperature_freq=temperature_freq)# Analysistotal_wear_time=np.sum(nonwear_array)pct_worn=total_wear_time/len(nonwear_array)*100print("The device was not worn%spercent of the time"%pct_worn)Version/Changelogv1.0.3loosen dependency requirements to minimum version instead of minor versionv1.0.2Detecting accelerometer non-wear periods using change in acceleration combined with rate-of-change in temperature.InstallationTo install the latest release of nimbaldetach directly from GitHub using pip, run the following line in terminal or
console:pip install git+https://github.com/nimbal/nimbaldetachTo install a specific release, insert@v#.#.#after the repository name replacing with the tag associated with that
release. For example:pip install git+https://github.com/nimbal/nimbaldetach@v1.0Include nimbaldetach as Package DependencyTo include the latest release of nimbaldetach as a dependency in your Python package, include the following
string within the list alongside your other dependencies:install_requires=['nimbaldetach@git+https://github.com/nimbal/nimbaldetach@[version]']To include a specific release, replace[version]with the tag associated with that release.nimbaldetach Package Dependenciesnumpypandasscipy