|
| 1 | +# ndx-wearables Extension for NWB |
| 2 | + |
| 3 | +Store data from wearable devices in NWB |
| 4 | + |
| 5 | +This extension is designed to help store data collected from a wide variety of wearable devices in a cross-device |
| 6 | +capable way, and with an eye towards clinical applications. |
| 7 | +For more details about the extension, see the paper "NDX-Wearables: An NWB Extension for Clinical Neuroscience" |
| 8 | +(to be presented at NER 2025). |
| 9 | + |
| 10 | + |
| 11 | +## Installation |
| 12 | + |
| 13 | +Create a new Python environment. Python 3.11 works well, python 3.8-3.12 have been tested. |
| 14 | + |
| 15 | +```terminal |
| 16 | +conda create -n <env_name> python=3.11 |
| 17 | +``` |
| 18 | +You should be able to install from pypi using `pip install ndx-wearables` |
| 19 | + |
| 20 | +If you would like to install and contribute to developing the package, follow the instructions below |
| 21 | +in [Installing in editable mode](#Installing-in-editable-mode) |
| 22 | + |
| 23 | +## Usage |
| 24 | + |
| 25 | +To see how the data stored using this extension looks, visit our example dataset on the |
| 26 | +[EMBER Archive](https://dandi.emberarchive.org/dandiset/000207). |
| 27 | + |
| 28 | +You can also generate a local copy of a synthetic datasets by running the relevant `examples/` scripts, for instance |
| 29 | +``` |
| 30 | +python examples/activity_classification.py |
| 31 | +``` |
| 32 | + |
| 33 | + |
| 34 | +## Notes on Extension Usage |
| 35 | + |
| 36 | +This extension provides three key classes (`WearableTimeSeries`, `WearableEnumSeries`, `WearableEvents`) to cover: |
| 37 | +- `WearableTimeSeries` for general time series data sampled from a wearable device, such as blood oxygenation level |
| 38 | +- `WearableEnumSeries` for categorical variables over time with pre-defined meanings (for example sleep stages over time) |
| 39 | +- `WearableEvents` for sparse events over long time periods (e.g. exercise events) |
| 40 | + |
| 41 | +In addition to these classes, metadata may be required, including: |
| 42 | +- `wearable_device` is required for classes that link to a device |
| 43 | +- `algorithm` is required for many classes to indicate how the data was derived |
| 44 | + |
| 45 | +The `PhysiologicalMeasure` class is povided to group together similar physiological measurements (e.g. heart rate variability, motion) from different devices/sources. This could include redundant measurements of the same physiological variable, or multiple measurements which will be fused by later processing to estimate an unknown quantity (e.g. multiple accelerometer measurements). |
| 46 | + |
| 47 | +If these arguments are omitted, instantiating the class will raise an error. You can find working examples in the scripts under `examples`. |
| 48 | + |
| 49 | +## Arguments for ndx-wearables Classes |
| 50 | + |
| 51 | +| Class Name | Required Arguments | Optional Arguments | |
| 52 | +|------------------------|------------------------------------------------------------------------|-----------------------------------------------| |
| 53 | +| `WearableTimeSeries` | `name`, `description`, `data`, `timestamps`, `wearable_device`, `algorithm` | `comments`, `resolution`, `conversion` | |
| 54 | +| `WearableEnumSeries` | `name`, `description`, `data`, `timestamps`, `wearable_device`, `meanings`, `algorithm` | `resolution`, `conversion`, `comments` | |
| 55 | +| `WearableEvents` | `name`, `description`, `columns`, `wearable_device`, `algorithm` | `resolution`, `conversion`, `comments` | |
| 56 | + |
| 57 | + |
| 58 | +These reflect typical usage in constructors. For full context or updates, refer to the class definitions in |
| 59 | +[`src/pynwb/ndx_wearables`](src/pynwb/ndx_wearables) and usage examples in [`examples`](examples). |
| 60 | + |
| 61 | + |
| 62 | +## Developing the extension |
| 63 | + |
| 64 | +We use a gitflow model for collaborative development. Each feature should be created on a branch that branches off of |
| 65 | +the `develop` branch. Draft PRs back into develop should be open for each WIP feature, and marked as ready for review |
| 66 | +once the feature is complete. Periodic releases will be made from develop into `main`. |
| 67 | + |
| 68 | +### Installing in editable mode |
| 69 | +Navigate to the project root `cd path/to/ndx-wearables`, then install the required dependencies. For developers, use: |
| 70 | + |
| 71 | +```terminal |
| 72 | +pip install -r requirements-dev.txt |
| 73 | +``` |
| 74 | +Custom extensions are added to the extension spec YAML file by running: |
| 75 | + |
| 76 | +```terminal |
| 77 | +python src/spec/create_extension_spec.py |
| 78 | +``` |
| 79 | + |
| 80 | +After running this script, you can verify that the extensions are correctly added to `spec/ndx-wearables.extensions.yaml`. |
| 81 | + |
| 82 | +Running test code may be done with PyTest using the test files located in `src/pynwb/tests`. |
| 83 | + |
| 84 | +To use custom extensions outside a PyTest setting, they must be registered by navigating to the directory root and installing the package: |
| 85 | +```terminal |
| 86 | +cd path/to/ndx-wearables |
| 87 | +pip install -e . |
| 88 | +``` |
| 89 | + |
| 90 | +--- |
| 91 | +This extension was created using [ndx-template](https://github.com/nwb-extensions/ndx-template). |
0 commit comments