NWB extension for survey/ behavioral data
Project description
ndx-survey-data Extension for NWB
Structure for storing the survey data in a NWB file.
Installation
$ pip install git+https://github.com/catalystneuro/ndx-survey-data.git
Usage
from pynwb import NWBHDF5IO, NWBFile
import datetime
from ndx_survey_data.survey_definitions import nrs_survey_table
nrs_survey_table.add_row(
pain_intensity_rating=1,
pain_relief_rating=5,
relative_pain_intensity_rating=2,
pain_unpleasantness=3,
unix_timestamp=1588217283
)
nrs_survey_table.add_row(
pain_intensity_rating=3,
pain_relief_rating=1,
relative_pain_intensity_rating=6,
pain_unpleasantness=2,
unix_timestamp=1588217283
)
nrs_survey_table.add_row(
pain_intensity_rating=5,
pain_relief_rating=2,
relative_pain_intensity_rating=0,
pain_unpleasantness=2,
unix_timestamp=1588217283
)
nrs_survey_table.add_row(
pain_intensity_rating=3,
pain_relief_rating=1,
relative_pain_intensity_rating=6,
pain_unpleasantness=2,
unix_timestamp=1588217283
)
nwbfile = NWBFile('description', 'id', datetime.now().astimezone())
nwbfile.create_processing_module(name='behavior', description='survey/behavioral data')
nwbfile.processing['behavior'].add(nrs_survey_table)
with NWBHDF5IO('test_nwb.nwb', 'w') as io:
io.write(nwbfile)
with NWBHDF5IO('test_nwb.nwb', 'r', load_namespaces=True) as io:
nwbfile = io.read()
print(nwbfile.processing['behavior'].data_interfaces['nrs_survey_table'].to_dataframe().to_html())
pain_intensity_rating | pain_relief_rating | relative_pain_intensity_rating | pain_unpleasantness | unix_timestamp | |
---|---|---|---|---|---|
id | |||||
0 | 1 | 5 | 2 | 3 | 1588217283 |
1 | 3 | 1 | 6 | 2 | 1588217283 |
2 | 5 | 2 | 0 | 2 | 1588217283 |
3 | 3 | 1 | 6 | 2 | 1588217283 |
To add a custom survey:
from ndx_survey_data import QuestionResponse, SurveyTable
q1 = QuestionResponse(name='question1',
description='desc',
options=['option 1', 'option 2', 'option 3'])
q2 = QuestionResponse(name='question2',
description='desc',
options=['option 1', 'option 2', 'option 3'])
q3 = QuestionResponse(name='question3',
description='desc',
options=['option 1', 'option 2', 'option 3'])
custom_survey_table = SurveyTable(name='custom_survey_table',
description='desc',
columns=[q1, q2, q3])
custom_survey_table.add_row(question1=1, question2=3, question3=0, unix_timestamp=1588217283)
custom_survey_table.add_row(question1=3, question2=1, question3=0, unix_timestamp=1588217283)
custom_survey_table.add_row(question1=2, question2=2, question3=2, unix_timestamp=1588217283)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ndx-survey-data-0.1.0.tar.gz
(13.8 kB
view details)
Built Distribution
File details
Details for the file ndx-survey-data-0.1.0.tar.gz
.
File metadata
- Download URL: ndx-survey-data-0.1.0.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bd18f9722f49362e1cae540cc9a96af7766c6c933a8b5e52de49ddc339467e8 |
|
MD5 | b1a42c073a83a2eafbd0a1e52388ae9a |
|
BLAKE2b-256 | 09622dbf940c62c72e443626fee1753b95531752b038effad15931556758c4e5 |
File details
Details for the file ndx_survey_data-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: ndx_survey_data-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a513f91d57cfc8a60f701f76dbe7249ae4f36ff1fbaa5257cda0a1bb1e36af89 |
|
MD5 | b07321b4f0eedefbdc57538fd4c9ae95 |
|
BLAKE2b-256 | 0e328215c5e8cdb220144274dc4171272573ffa0e7d6ae38e5d8df2e0e924af6 |