A HTML report generator of accelerometer data for pre-processing and determining variables for feature generation. Created by Ryley Delaney February 2025
This Repository contains scripts that allows the user to create a HTML document from accelerometer data that displays various information to help with feature generation. The document contains some preliminary information about the dataset used and a series of plots and tables. It was created as a part of a volunteering project during my undergrad with PhD candidate Oakleigh Wilson at the University of the Sunshine Coast.
You can view Oakleigh's Github and her work on machine learning and accelerometry here
You can view an example report using Squirrel data from Studd (2019) here
The example report is in HTML format and will need to be downloaded to be viewed properly if attempting to view from GitHub.
Below is a brief summary of the task outlined to me by my supervisor:
Animal-borne accelerometers collect high-frequency changes in acceleration, capturing patterns that can be linked to specific fine-scale behaviours. These patterns are used to train machine learning models that can identify what an animal is doing based on its movement. However, training these models requires converting the raw accelerometer data into machine-interpretable statistical 'features.' One key step in generating these features is determining the duration of behaviours that appear in the data. Using the provided code as a base, please develop an automated reporting system that can take accelerometer data and sample rate as inputs and generate a html report to A) visualise the existing data, and B ) suggest the optimal window length for feature generation. This system should require minimal user input and include clear explanations of how to interpret graphs and tables, as well as a description and reasoning for the ultimate recommendation.
The main script of the repository, loads all packages, sources all functions as well as the GenerateBehaviourReport.Rmd. Part of the script involves seamlessly guiding inputs from the user on including outliers in the Behaviour Duration box plot.
Contains all the functions that are necessary for AccelerometerAnalysis_Main.R to run.
The R markdown file that calls on the plot generator functions and creates the final HTML report.
Contains a basic theme thats used for the Behaviour Generation Report.
This program uses a few packages which will need to be installed in order to run.
- pacman
- data.table
- tidyverse
- kableExtra
The Accelerometer Analysis Report generator requires a brief setup of directory structure. All Scripts should be placed in the working directory inside a folder called Scripts.
For Example: C:/Users/user/Desktop/AccelerometerData/Scripts
When first running the main script it will create a series of directories necessary for the program to work.
One of these folders will be YourWorkingDirectory/AccelerometerData/Data/Data
Afterwards the program will prompt for you to place your data into this folder before continuing.
The main script will require the data placed in the 'Data/Data' folder to be named and formatted in a certain way.
The data will need to follow the convention of: "Your_Data_Modified.csv" as this is what the program will look for in the data folder.
An example of a correctly formatted data CSV is given below:
Note that the data in the example shown has it's columns titled with the following:
It's very important that any data inserted into the program is formatted, case sensitive, this way as otherwise the program will throw an error and not work.
For example:
Which will allow the program to look for the file within your directory as shown:
You will also need to change or insert an appropriate list of variables into the dictionary for your current dataset:
- sample_rate
- overlap_percent
- window_length
sample_rate refers to the rate of sampling, in seconds, taken by the accelerometer within the dataset.
The name of the list needs to be the same as your 'dataset_name' variable.
Below is another example:
At this point you are ready to source AccelerometerAnalysis_Main.R.
The program will search to see if a report already exists and prompt you whether or not to overwrite it. Afterwards it will prompt the user if they would like to include outliers within the plot. This was because in some data sets, including outliers made some values very difficult to read in the behaviour duration plot.
Studd, E. K. et al. Behavioral classification of low-frequency acceleration and temperature data from a free-ranging small mammal. Ecology and Evolution 9, 619–630 (2019).
