Skip to content

Commit

Permalink
Initial changes for repo
Browse files Browse the repository at this point in the history
  • Loading branch information
“Aidan committed Feb 1, 2024
1 parent d42fed6 commit fd394d3
Show file tree
Hide file tree
Showing 11 changed files with 452 additions and 166 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
src/sample_package/_version.py export-subst
src/actinet/_version.py export-subst
15 changes: 15 additions & 0 deletions CITATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
When using this tool, please consider citing the following works:

1. Yuan H, Chan S, et al. (2023)
[Self-supervised Learning for Human Activity Recognition Using 700,000 Person-days of Wearable Data](https://arxiv.org/abs/2206.02909).

```
@misc{yuan2023selfsupervised,
title={Self-supervised Learning for Human Activity Recognition Using 700,000 Person-days of Wearable Data},
author={Hang Yuan and Shing Chan and Andrew P. Creagh and Catherine Tong and David A. Clifton and Aiden Doherty},
year={2023},
eprint={2206.02909},
archivePrefix={arXiv},
primaryClass={eess.SP}
}
```
52 changes: 52 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Academic Use Licence

**These licence terms apply to all licences granted by THE CHANCELLOR, MASTERS AND SCHOLARS OF THE UNIVERSITY OF OXFORD whose administrative offices are at University Offices, Wellington Square, Oxford OX1 2JD, United Kingdom (the “University”) for use of “actinet” (“the Software”) through this website (https://github.com/OxWearables) (the ”Website”).

By downloading the Software through the Website, you (the “Licensee”) are confirming that you agree that your use of the Software is subject to these licence terms**

**PLEASE READ THESE LICENCE TERMS CAREFULLY BEFORE DOWNLOADING THE SOFTWARE. IF YOU DO NOT AGREE TO THESE LICENCE TERMS YOU SHOULD NOT DOWNLOAD THE SOFTWARE.**

**THE SOFTWARE IS INTENDED FOR USE BY ACADEMICS CARRYING OUT RESEARCH AND NOT FOR USE BY CONSUMERS OR COMMERCIAL BUSINESSES.**

**1. Academic Use Licence**
1.1 The Licensee is granted a limited non-exclusive and non-transferable royalty free licence to download and use the Software provided that the Licensee will:
- (a) limit their use of the Software to their own internal academic non-commercial research which is undertaken for the purposes of education or other scholarly use;
- (b) not use the Software for or on behalf of any third party or to provide a service or integrate all or part of the Software into a product for sale or license to third parties;
- (c) use the Software in accordance with the prevailing instructions and guidance for use given on the Website and comply with procedures on the Website for user identification, authentication and access;
- (d) comply with all applicable laws and regulations with respect to their use of the Software; and
- (e) ensure that the Copyright Notice “Copyright © 2022, University of Oxford” appears prominently wherever the Software is reproduced and is referenced or cited with the Copyright Notice when the Software is described in any research publication or on any documents or other material created using the Software.


1.2 The Licensee may only reproduce, modify, transmit or transfer the Software where:
- (a) such reproduction, modification, transmission or transfer is for academic, research or other scholarly use;
- (b) the conditions of this Licence are imposed upon the receiver of the Software or any modified Software;
- (c) all original and modified Source Code is included in any transmitted software program; and
- (d) the Licensee grants the University an irrevocable, indefinite, royalty free, non-exclusive unlimited licence to use and sub-licence any modified Source Code as part of the Software.


1.3 The University reserves the right at any time and without liability or prior notice to the Licensee to revise, modify and replace the functionality and performance of the access to and operation of the Software.


1.4 The Licensee acknowledges and agrees that the University owns all intellectual property rights in the Software. The Licensee shall not have any right, title or interest in the Software.


1.5 This Licence will terminate immediately and the Licensee will no longer have any right to use the Software or exercise any of the rights granted to the Licensee upon any breach of the conditions in Section 1 of this Licence.


**2. Indemnity and Liability**
2.1 The Licensee shall defend, indemnify and hold harmless the University against any claims, actions, proceedings, losses, damages, expenses and costs (including without limitation court costs and reasonable legal fees) arising out of or in connection with the Licensee's possession or use of the Software, or any breach of these terms by the Licensee.

2.2 The Software is provided on an ‘as is’ basis and the Licensee uses the Software at their own risk. No representations, conditions, warranties or other terms of any kind are given in respect of the the Software and all statutory warranties and conditions are excluded to the fullest extent permitted by law. Without affecting the generality of the previous sentences, the University gives no implied or express warranty and makes no representation that the Software or any part of the Software: (a) will enable specific results to be obtained; or (b) meets a particular specification or is comprehensive within its field or that it is error free or will operate without interruption; or (c) is suitable for any particular, or the Licensee's specific purposes.

2.3 Except in relation to fraud, death or personal injury, the University's liability to the Licensee for any use of the Software, in negligence or arising in any other way out of the subject matter of these licence terms, will not extend to any incidental or consequential damages or losses, or any loss of profits, loss of revenue, loss of data, loss of contracts or opportunity, whether direct or indirect.

2.4 The Licensee hereby irrevocably undertakes to the University not to make any claim against any employee, student, researcher or other individual engaged by the University, being a claim which seeks to enforce against any of them any liability whatsoever in connection with these licence terms or their subject-matter.


**3. General**
**3.1 Severability** - If any provision (or part of a provision) of these licence terms is found by any court or administrative body of competent jurisdiction to be invalid, unenforceable or illegal, the other provisions shall remain in force.
**3.2 Entire Agreement** - These licence terms constitute the whole agreement between the parties and supersede any previous arrangement, understanding or agreement between them relating to the Software.
**3.3 Law and Jurisdiction** - These licence terms and any disputes or claims arising out of or in connection with them shall be governed by, and construed in accordance with, the law of England. The Licensee irrevocably submits to the exclusive jurisdiction of the English courts for any dispute or claim that arises out of or in connection with these licence terms.


If you are interested in using the Software commercially, please contact Oxford University Innovation Limited to negotiate a licence. Contact details are [email protected]
132 changes: 132 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,135 @@
# actinet

A tool to extract meaningful health information from large accelerometer datasets.
The software generates time-series and summary metrics useful for answering key questions such as how much time is spent in sleep, sedentary behaviour, or doing physical activity.
The backbone of this repository is a self-supervised Resnet18 model.

## Install

*Minimum requirements*: Python>=3.8, Java 8 (1.8)

The following instructions make use of Anaconda to meet the minimum requirements:

1. Download & install [Miniconda](https://docs.conda.io/en/latest/miniconda.html) (light-weight version of Anaconda).
1. (Windows) Once installed, launch the **Anaconda Prompt**.
1. Create a virtual environment:
```console
$ conda create -n actinet python=3.9 openjdk pip
```
This creates a virtual environment called `actinet` with Python version 3.9, OpenJDK, and Pip.
1. Activate the environment:
```console
$ conda activate actinet
```
You should now see `(actinet)` written in front of your prompt.
1. Install `actinet`:
```console
$ pip install actinet
```

You are all set! The next time that you want to use `actinet`, open the Anaconda Prompt and activate the environment (step 4). If you see `(actinet)` in front of your prompt, you are ready to go!

## Usage

```bash
# Process an AX3 file
$ actinet sample.cwa

# Or an ActiGraph file
$ actinet sample.gt3x

# Or a GENEActiv file
$ actinet sample.bin

# Or a CSV file (see data format below)
$ actinet sample.csv
```


### Troubleshooting
Some systems may face issues with Java when running the script. If this is your case, try fixing OpenJDK to version 8:
```console
$ conda install -n actinet openjdk=8
```

### Output files
By default, output files will be stored in a folder named after the input file, `outputs/{filename}/`, created in the current working directory. You can change the output path with the `-o` flag:

```console
$ actinet sample.cwa -o /path/to/some/folder/
```

The following output files are created:

- *Info.json* Summary info, as shown above.
- *timeSeries.csv* Raw time-series of activity levels

See [Data Dictionary](https://biobankaccanalysis.readthedocs.io/en/latest/datadict.html) for the list of output variables.


### Crude vs. Adjusted Estimates
Adjusted estimates are provided that account for missing data.
Missing values in the time-series are imputed with the mean of the same timepoint of other available days.
For adjusted totals and daily statistics, 24h multiples are needed and will be imputed if necessary.
Estimates will be NaN where data is still missing after imputation.


### Processing CSV files
If a CSV file is provided, it must have the following header: `time`, `x`, `y`, `z`.

Example:
```console
time,x,y,z
2013-10-21 10:00:08.000,-0.078923,0.396706,0.917759
2013-10-21 10:00:08.010,-0.094370,0.381479,0.933580
2013-10-21 10:00:08.020,-0.094370,0.366252,0.901938
2013-10-21 10:00:08.030,-0.078923,0.411933,0.901938
...
```

### Processing multiple files
#### Windows
To process multiple files you can create a text file in Notepad which includes one line for each file you wish to process, as shown below for *file1.cwa*, *file2.cwa*, and *file2.cwa*.

Example text file *commands.txt*:
```console
actinet file1.cwa &
actinet file2.cwa &
actinet file3.cwa
:END
````
Once this file is created, run `cmd < commands.txt` from the terminal.

#### Linux
Create a file *command.sh* with:
```console
actinet file1.cwa
actinet file2.cwa
actinet file3.cwa
```
Then, run `bash command.sh` from the terminal.

#### Collating outputs

A utility script is provided to collate outputs from multiple runs:

```console
$ actinet-collate-outputs outputs/
```
This will collate all *-Info.json files found in outputs/ and generate a CSV file.

## Citing our work

When using this tool, please consider citing the works listed in [CITATION.md](https://github.com/OxWearables/actinet/blob/main/CITATION.md).


## Licence
See [LICENSE.md](https://github.com/OxWearables/actinet/blob/main/LICENSE.md).


## Acknowledgements
We would like to thank all our code contributors, manuscript co-authors, and research participants for their help in making this work possible.

# Sample PyPI package + GitHub Actions + Versioneer

This template aims to automate the tedious and error-prone steps of tagging/versioning, building and publishing new package versions. This is achieved by syncing git tags and versions with Versioneer, and automating the build and release with GitHub Actions, so that publishing a new version is as painless as:
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ build-backend = "setuptools.build_meta"
[tool.versioneer]
VCS = "git"
style = "pep440"
versionfile_source = "src/sample_package/_version.py"
versionfile_build = "sample_package/_version.py"
versionfile_source = "src/actinet/_version.py"
versionfile_build = "actinet/_version.py"
tag_prefix = "v"
parentdir_prefix = "sample-package-"
parentdir_prefix = "actinet-"
33 changes: 11 additions & 22 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ def main():
long_description = fh.read()

setup(
name="sample-package-chanshing",
name="actinet",
version=versioneer.get_version(), # Do not edit
cmdclass=versioneer.get_cmdclass(), # Do not edit
python_requires=">=3.8, <4",
description="An example Python project",
description="Activity detection algorithm compatible with the UK Biobank Accelerometer Dataset",
long_description=long_description, # Do not edit. See README.md
long_description_content_type="text/markdown",
keywords="example, setuptools, versioneer",
url="https://github.com/chanshing/sample-package",
download_url="https://github.com/chanshing/sample-package",
author=get_string("__author__"), # Do not edit. see src/sample_package/__init__.py
maintainer=get_string("__maintainer__"), # Do not edit. see src/sample_package/__init__.py
maintainer_email=get_string("__maintainer_email__"), # Do not edit. See src/sample_package/__init__.py
license=get_string("__license__"), # Do not edit. See src/sample_package/__init__.py
url="https://github.com/OxWearables/actinet",
download_url="https://github.com/OxWearables/actinet",
author=get_string("__author__"), # Do not edit. see src/actinet/__init__.py
maintainer=get_string("__maintainer__"), # Do not edit. see src/actinet/__init__.py
maintainer_email=get_string("__maintainer_email__"), # Do not edit. See src/actinet/__init__.py
license=get_string("__license__"), # Do not edit. See src/actinet/__init__.py

# This is for PyPI to categorize your project. See: https://pypi.org/classifiers/
classifiers=[
Expand All @@ -41,30 +41,19 @@ def main():
packages=find_packages(where="src", exclude=("test", "tests")),
package_dir={"": "src"},
# What other files to include, e.g. *.class if the package uses some Java code.
package_data={"sample_package": ["*.txt", "*.rst", "*.md"]},

# This option will include all files in the `src/sample_package` directory provided they
# are listed in the `MANIFEST.in` file, OR are being tracked by git.
# See: https://setuptools.pypa.io/en/latest/userguide/datafiles.html
# include_package_data=True,
package_data={"actinet": ["*.txt", "*.rst", "*.md"]},

# Dependencies
install_requires=[],

# Optional packages. Can be installed with:
# `$ pip install sample-package-chanshing[dev]` or
# `$ pip install sample-package-chanshing[docs]` or
# `$ pip install sample-package-chanshing[dev,docs]`
extras_require={
# Will be installed with `$ pip install sample-package-chanshing[dev]`
"dev": [
"versioneer",
"twine",
"ipdb",
"flake8",
"autopep8",
],
# Will be installed with `$ pip install sample-package-chanshing[docs]`
"docs": [
"sphinx>=4.2",
"sphinx_rtd_theme>=1.0",
Expand All @@ -76,7 +65,7 @@ def main():
# Define entry points for command-line scripts, e.g.: `$ hello --name Alice`
entry_points={
"console_scripts": [
"hello=sample_package.main:main",
"hello=actinet.main:main",
],
},

Expand All @@ -89,7 +78,7 @@ def read(rel_path):
return fp.read()


def get_string(string, rel_path="src/sample_package/__init__.py"):
def get_string(string, rel_path="src/actinet/__init__.py"):
for line in read(rel_path).splitlines():
if line.startswith(string):
delim = '"' if '"' in line else "'"
Expand Down
8 changes: 8 additions & 0 deletions src/actinet/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name = "actinet"
__author__ = "Shing Chan, Aidan Acquah, Charilaos Zisou, Aiden Doherty"
__maintainer__ = "Shing Chan"
__maintainer_email__ = "[email protected]"
__license__ = "See LICENSE file."

from . import _version
__version__ = _version.get_versions()['version']
Loading

0 comments on commit fd394d3

Please sign in to comment.