asleep


Nameasleep JSON
Version 0.4.11 PyPI version JSON
download
home_pageNone
SummaryA sleep classification tool for wearables
upload_time2024-04-17 10:28:19
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
license# 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 “SSL-wearables” (“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 enquiries@innovation.ox.ac.uk
keywords sleep wearables machine learning
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # asleep: a sleep classifier for wearable sensor data using machine learning
This is a Python package for classifying sleep stages from wearable sensor data / wrist - worn accelerometer. The underlying model
was trained and tested in 1000 + nights of multi - centre polysomnography with tri - axial accelerometer data.

The key features of this package are as follows:
* A simple and easy - to - use API for sleep stage classification.
* Sleep / wake metric estimation including total sleep duration and sleep efficiency.
* Sleep architecture metric estimation including rapid - eye - movement(REM) / NREM sleep duration.


![](https://raw.githubusercontent.com/OxWearables/asleep/main/assets/figure.jpg)


# Dependencies
- Python 3.8
- Java 8 (1.8.0) or greater

Check with:
```bash
$ python --version
$ java -version
```

# Installation
```bash
$ pip install asleep
```

# Usage
All the processing will be much faster after the first time because the model weights will to have to be downloaded
the first time that the package is used.
```shell
# Process an AX3 file
$ get_sleep sample.cwa

# Or an ActiGraph file
$ get_sleep sample.gt3x

# Or a GENEActiv file
$ get_sleep sample.bin

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

Output
```shell
Summary
-------
{
    "Filename": "sample.cwa",
    "Filesize(MB)": 65.1,
    "Device": "Axivity",
    "DeviceID": 2278,
    "ReadErrors": 0,
    "SampleRate": 100.0,
    "ReadOK": 1,
    "StartTime": "2013-10-21 10:00:07",
    "EndTime": "2013-10-28 10:00:01",
    "Total sleep duration(min)": 655.7,
    "Total overnight sleep(min)": 43132,
    ...
}

Estimated total sleep duration
---------------------
              total sleep duration(min)
time
2013 - 10 - 21     435.2
2013 - 10 - 22     436.2
2013 - 10 - 23    432.2
...

Output: outputs /sample/
```

# Visualisation
You can visualise the sleep parameters using the following command:
```shell
$ visu_sleep PATH_TO_OUTPUT_FOLDER
```


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

Example:
```shell
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
```


# Citation
If you want to use our package for your project, please cite our paper below:
```bibtex
@article {Yuan2023.07.07.23292251,
	author = {Hang Yuan and Tatiana Plekhanova and Rosemary Walmsley and Amy C. Reynolds and Kathleen J. Maddison and Maja Bucan and Philip Gehrman and Alex Rowlands and David W. Ray and Derrick Bennett and Joanne McVeigh and Leon Straker and Peter Eastwood and Simon D. Kyle and Aiden Doherty},
	title = {Self-supervised learning of accelerometer data provides new insights for sleep and its association with mortality},
	elocation-id = {2023.07.07.23292251},
	year = {2023},
	doi = {10.1101/2023.07.07.23292251},
	publisher = {Cold Spring Harbor Laboratory Press},
	URL = {https://www.medrxiv.org/content/early/2023/07/08/2023.07.07.23292251},
	eprint = {https://www.medrxiv.org/content/early/2023/07/08/2023.07.07.23292251.full.pdf},
	journal = {medRxiv}
}
```

# Acknowledgements
We would like to thank all our code contributors, manuscript co - authors, and research participants for their help in making this work possible. The
data processing pipeline of this repository is based on the [step_count](https://github.com/OxWearables/stepcount) package from our group. Special
thanks to @chanshing for his help in developing the package.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "asleep",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "Hang Yuan <angerhangy@gmail.com>",
    "keywords": "sleep, wearables, machine learning",
    "author": null,
    "author_email": "Hang Yuan <angerhangy@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/25/2d/46781c10ca73bbe2487b35125d4fbf65d7046163ff1fdd325b230e018c72/asleep-0.4.11.tar.gz",
    "platform": null,
    "description": "# asleep: a sleep classifier for wearable sensor data using machine learning\nThis is a Python package for classifying sleep stages from wearable sensor data / wrist - worn accelerometer. The underlying model\nwas trained and tested in 1000 + nights of multi - centre polysomnography with tri - axial accelerometer data.\n\nThe key features of this package are as follows:\n* A simple and easy - to - use API for sleep stage classification.\n* Sleep / wake metric estimation including total sleep duration and sleep efficiency.\n* Sleep architecture metric estimation including rapid - eye - movement(REM) / NREM sleep duration.\n\n\n![](https://raw.githubusercontent.com/OxWearables/asleep/main/assets/figure.jpg)\n\n\n# Dependencies\n- Python 3.8\n- Java 8 (1.8.0) or greater\n\nCheck with:\n```bash\n$ python --version\n$ java -version\n```\n\n# Installation\n```bash\n$ pip install asleep\n```\n\n# Usage\nAll the processing will be much faster after the first time because the model weights will to have to be downloaded\nthe first time that the package is used.\n```shell\n# Process an AX3 file\n$ get_sleep sample.cwa\n\n# Or an ActiGraph file\n$ get_sleep sample.gt3x\n\n# Or a GENEActiv file\n$ get_sleep sample.bin\n\n# Or a CSV file (see data format below)\n$ get_sleep sample.csv\n```\n\nOutput\n```shell\nSummary\n-------\n{\n    \"Filename\": \"sample.cwa\",\n    \"Filesize(MB)\": 65.1,\n    \"Device\": \"Axivity\",\n    \"DeviceID\": 2278,\n    \"ReadErrors\": 0,\n    \"SampleRate\": 100.0,\n    \"ReadOK\": 1,\n    \"StartTime\": \"2013-10-21 10:00:07\",\n    \"EndTime\": \"2013-10-28 10:00:01\",\n    \"Total sleep duration(min)\": 655.7,\n    \"Total overnight sleep(min)\": 43132,\n    ...\n}\n\nEstimated total sleep duration\n---------------------\n              total sleep duration(min)\ntime\n2013 - 10 - 21     435.2\n2013 - 10 - 22     436.2\n2013 - 10 - 23    432.2\n...\n\nOutput: outputs /sample/\n```\n\n# Visualisation\nYou can visualise the sleep parameters using the following command:\n```shell\n$ visu_sleep PATH_TO_OUTPUT_FOLDER\n```\n\n\n# Processing CSV files\nIf a CSV file is provided, it must have the following header: time, x, y, z.\n\nExample:\n```shell\ntime, x, y, z\n2013 - 10 - 21 10: 00: 08.000, -0.078923, 0.396706, 0.917759\n2013 - 10 - 21 10: 00: 08.010, -0.094370, 0.381479, 0.933580\n2013 - 10 - 21 10: 00: 08.020, -0.094370, 0.366252, 0.901938\n2013 - 10 - 21 10: 00: 08.030, -0.078923, 0.411933, 0.901938\n```\n\n\n# Citation\nIf you want to use our package for your project, please cite our paper below:\n```bibtex\n@article {Yuan2023.07.07.23292251,\n\tauthor = {Hang Yuan and Tatiana Plekhanova and Rosemary Walmsley and Amy C. Reynolds and Kathleen J. Maddison and Maja Bucan and Philip Gehrman and Alex Rowlands and David W. Ray and Derrick Bennett and Joanne McVeigh and Leon Straker and Peter Eastwood and Simon D. Kyle and Aiden Doherty},\n\ttitle = {Self-supervised learning of accelerometer data provides new insights for sleep and its association with mortality},\n\telocation-id = {2023.07.07.23292251},\n\tyear = {2023},\n\tdoi = {10.1101/2023.07.07.23292251},\n\tpublisher = {Cold Spring Harbor Laboratory Press},\n\tURL = {https://www.medrxiv.org/content/early/2023/07/08/2023.07.07.23292251},\n\teprint = {https://www.medrxiv.org/content/early/2023/07/08/2023.07.07.23292251.full.pdf},\n\tjournal = {medRxiv}\n}\n```\n\n# Acknowledgements\nWe would like to thank all our code contributors, manuscript co - authors, and research participants for their help in making this work possible. The\ndata processing pipeline of this repository is based on the [step_count](https://github.com/OxWearables/stepcount) package from our group. Special\nthanks to @chanshing for his help in developing the package.\n",
    "bugtrack_url": null,
    "license": "# 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 \u201cUniversity\u201d) for use of \u201cSSL-wearables\u201d (\u201cthe Software\u201d) through this website (https://github.com/OxWearables) (the \u201dWebsite\u201d).  By downloading the Software through the Website, you (the \u201cLicensee\u201d) 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.\tAcademic Use Licence** 1.1\tThe 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)\tlimit 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)\tnot 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)\tuse 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)\tcomply with all applicable laws and regulations with respect to their use of the Software; and - (e)\tensure that the Copyright Notice \u201cCopyright \u00a9 2022, University of Oxford\u201d 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\tThe Licensee may only reproduce, modify, transmit or transfer the Software where: - (a)\tsuch reproduction, modification, transmission or transfer is for academic, research or other scholarly use; - (b)\tthe conditions of this Licence are imposed upon the receiver of the Software or any modified Software; - (c)\tall original and modified Source Code is included in any transmitted software program; and - (d)\tthe 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\tThe 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\tThe 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\tThis 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.\tIndemnity and Liability** 2.1\tThe 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\tThe Software is provided on an \u2018as is\u2019 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\tExcept 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\tThe 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.\tGeneral** **3.1\tSeverability** - 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\tEntire 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\tLaw 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 enquiries@innovation.ox.ac.uk ",
    "summary": "A sleep classification tool for wearables",
    "version": "0.4.11",
    "project_urls": {
        "Bug Reports": "https://github.com/OxWearables/asleep/issues",
        "Homepage": "https://github.com/OxWearables/asleep",
        "Source": "https://github.com/OxWearables/asleep"
    },
    "split_keywords": [
        "sleep",
        " wearables",
        " machine learning"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "140ee74791362b7189983b1e0ff17904a59044ff14943cfee445c6214bd95ee1",
                "md5": "e5e99ae338ff6ac2886042dda80bfb1c",
                "sha256": "0426f2e0b5afb9d60a4e91282d4f6e984b781d95471742eb719f3bafcb7397b3"
            },
            "downloads": -1,
            "filename": "asleep-0.4.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e5e99ae338ff6ac2886042dda80bfb1c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 43824,
            "upload_time": "2024-04-17T10:28:16",
            "upload_time_iso_8601": "2024-04-17T10:28:16.367165Z",
            "url": "https://files.pythonhosted.org/packages/14/0e/e74791362b7189983b1e0ff17904a59044ff14943cfee445c6214bd95ee1/asleep-0.4.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "252d46781c10ca73bbe2487b35125d4fbf65d7046163ff1fdd325b230e018c72",
                "md5": "20c05da75ede30579c8fd9754fe94ea0",
                "sha256": "34e7a411c041dcc6f47ab8d3aa268ce5fbeeed6d0e3797b522ddfd91332dad09"
            },
            "downloads": -1,
            "filename": "asleep-0.4.11.tar.gz",
            "has_sig": false,
            "md5_digest": "20c05da75ede30579c8fd9754fe94ea0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 41162283,
            "upload_time": "2024-04-17T10:28:19",
            "upload_time_iso_8601": "2024-04-17T10:28:19.445481Z",
            "url": "https://files.pythonhosted.org/packages/25/2d/46781c10ca73bbe2487b35125d4fbf65d7046163ff1fdd325b230e018c72/asleep-0.4.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-17 10:28:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "OxWearables",
    "github_project": "asleep",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "asleep"
}
        
Elapsed time: 0.23328s