ndx-hed 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ndx_hed/__init__.py +56 -0
- ndx_hed/hed_tags.py +62 -0
- ndx_hed/spec/ndx-hed.extensions.yaml +12 -0
- ndx_hed/spec/ndx-hed.namespace.yaml +19 -0
- ndx_hed-0.1.0.dist-info/METADATA +50 -0
- ndx_hed-0.1.0.dist-info/RECORD +8 -0
- ndx_hed-0.1.0.dist-info/WHEEL +4 -0
- ndx_hed-0.1.0.dist-info/licenses/LICENSE.txt +29 -0
ndx_hed/__init__.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from pynwb import load_namespaces, get_class
|
|
3
|
+
|
|
4
|
+
# Set path of the namespace.yaml file to the expected install location
|
|
5
|
+
ndx_hed_specpath = os.path.join(
|
|
6
|
+
os.path.dirname(__file__),
|
|
7
|
+
'spec',
|
|
8
|
+
'ndx-hed.namespace.yaml'
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
# If the extension has not been installed yet but we are running directly from
|
|
12
|
+
# the git repo
|
|
13
|
+
if not os.path.exists(ndx_hed_specpath):
|
|
14
|
+
ndx_hed_specpath = os.path.abspath(os.path.join(
|
|
15
|
+
os.path.dirname(__file__),
|
|
16
|
+
'..', '..', '..',
|
|
17
|
+
'spec',
|
|
18
|
+
'ndx-hed.namespace.yaml'
|
|
19
|
+
))
|
|
20
|
+
|
|
21
|
+
# Load the namespace
|
|
22
|
+
load_namespaces(ndx_hed_specpath)
|
|
23
|
+
#
|
|
24
|
+
# from . import io as __io # noqa: E402,F401
|
|
25
|
+
# from .hed_models import NWBHedVersion
|
|
26
|
+
#
|
|
27
|
+
# try:
|
|
28
|
+
# from importlib.resources import files
|
|
29
|
+
# except ImportError:
|
|
30
|
+
# # TODO: Remove when python 3.9 becomes the new minimum
|
|
31
|
+
# from importlib_resources import files
|
|
32
|
+
#
|
|
33
|
+
#
|
|
34
|
+
#
|
|
35
|
+
# # Get path to the namespace.yaml file with the expected location when installed not in editable mode
|
|
36
|
+
# __location_of_this_file = files(__name__)
|
|
37
|
+
# __spec_path = __location_of_this_file / "spec" / "ndx-hed.namespace.yaml"
|
|
38
|
+
#
|
|
39
|
+
# # If that path does not exist, we are likely running in editable mode. Use the local path instead
|
|
40
|
+
# if not os.path.exists(__spec_path):
|
|
41
|
+
# __spec_path = __location_of_this_file.parent.parent.parent / "spec" / "ndx-hed.namespace.yaml"
|
|
42
|
+
#
|
|
43
|
+
# # Load the namespace
|
|
44
|
+
# load_namespaces(str(__spec_path))
|
|
45
|
+
#
|
|
46
|
+
# # TODO: Define your classes here to make them accessible at the package level.
|
|
47
|
+
# # Either have PyNWB generate a class from the spec using `get_class` as shown
|
|
48
|
+
# # below or write a custom class and register it using the class decorator
|
|
49
|
+
# # `@register_class("TetrodeSeries", "ndx-hed")`
|
|
50
|
+
# # HedAnnotations = get_class("HedAnnotations", "ndx-hed")
|
|
51
|
+
# HedVersion = get_class("HedVersion", "ndx-hed")
|
|
52
|
+
#
|
|
53
|
+
# # Remove these functions from the package
|
|
54
|
+
del load_namespaces, get_class
|
|
55
|
+
|
|
56
|
+
from .hed_tags import HedTags
|
ndx_hed/hed_tags.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
|
|
2
|
+
from hdmf.common import VectorData
|
|
3
|
+
from hdmf.utils import docval, getargs, get_docval, popargs
|
|
4
|
+
from hed.errors import get_printable_issue_string
|
|
5
|
+
from hed.schema import load_schema_version
|
|
6
|
+
from hed.models import HedString
|
|
7
|
+
from pynwb import register_class
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@register_class('HedTags', 'ndx-hed')
|
|
11
|
+
class HedTags(VectorData):
|
|
12
|
+
"""
|
|
13
|
+
Column storing HED (Hierarchical Event Descriptors) annotations for a row. A HED string is a comma-separated,
|
|
14
|
+
and possibly parenthesized list of HED tags selected from a valid HED vocabulary as specified by the
|
|
15
|
+
NWBFile field HedVersion.
|
|
16
|
+
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
__nwbfields__ = ('_hed_schema', 'hed_version')
|
|
20
|
+
|
|
21
|
+
@docval({'name': 'hed_version', 'type': 'str', 'doc': 'The version of HED used by this data.'},
|
|
22
|
+
{'name': 'name', 'type': str, 'doc': 'The name of this VectorData', 'default': 'HED'},
|
|
23
|
+
{'name': 'description', 'type': str, 'doc': 'a description for this column',
|
|
24
|
+
'default': "Column that stores HED tags as text annotating their respective row."},
|
|
25
|
+
*get_docval(VectorData.__init__, 'data'))
|
|
26
|
+
def __init__(self, **kwargs):
|
|
27
|
+
hed_version = popargs('hed_version', kwargs)
|
|
28
|
+
super().__init__(**kwargs)
|
|
29
|
+
self.hed_version = hed_version
|
|
30
|
+
self._init_internal()
|
|
31
|
+
|
|
32
|
+
def _init_internal(self):
|
|
33
|
+
"""
|
|
34
|
+
This loads (a private pointer to) the HED schema and validates the HED data.
|
|
35
|
+
"""
|
|
36
|
+
self._hed_schema = load_schema_version(self.hed_version)
|
|
37
|
+
issues = []
|
|
38
|
+
for index in range(len(self.data)):
|
|
39
|
+
hed_obj = HedString(self.get(index), self._hed_schema)
|
|
40
|
+
these_issues = hed_obj.validate()
|
|
41
|
+
if these_issues:
|
|
42
|
+
issues.append(f"line {str(index)}: {get_printable_issue_string(these_issues)}")
|
|
43
|
+
if issues:
|
|
44
|
+
issue_str = "\n".join(issues)
|
|
45
|
+
raise ValueError(f"InvalidHEDData {issue_str}")
|
|
46
|
+
|
|
47
|
+
@docval({'name': 'val', 'type': str,
|
|
48
|
+
'doc': 'the value to add to this column. Should be a valid HED string -- just forces string.'})
|
|
49
|
+
def add_row(self, **kwargs):
|
|
50
|
+
"""Append a data value to this column."""
|
|
51
|
+
val = getargs('val', kwargs)
|
|
52
|
+
hed_obj = HedString(val, self._hed_schema)
|
|
53
|
+
these_issues = hed_obj.validate()
|
|
54
|
+
if these_issues:
|
|
55
|
+
raise ValueError(f"InvalidHEDValue [{str(val)}] issues: {get_printable_issue_string(these_issues)}")
|
|
56
|
+
super().append(val)
|
|
57
|
+
|
|
58
|
+
def get_hed_version(self):
|
|
59
|
+
return self.hed_version
|
|
60
|
+
|
|
61
|
+
def get_hed_schema(self):
|
|
62
|
+
return self._hed_schema
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
datasets:
|
|
2
|
+
- neurodata_type_def: HedTags
|
|
3
|
+
neurodata_type_inc: VectorData
|
|
4
|
+
dtype: text
|
|
5
|
+
doc: An extension of VectorData for Hierarchical Event Descriptor (HED) tags. If
|
|
6
|
+
HED tags are used, the HED schema version must be specified in the NWB file using
|
|
7
|
+
the HedMetadata type.
|
|
8
|
+
attributes:
|
|
9
|
+
- name: hed_version
|
|
10
|
+
dtype: text
|
|
11
|
+
doc: "The version of the HED schema used to validate the HED tags, e.g., '8.2.0'.
|
|
12
|
+
(Required). "
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
namespaces:
|
|
2
|
+
- author:
|
|
3
|
+
- Ryan Ly
|
|
4
|
+
- Oliver Ruebel
|
|
5
|
+
- Kay Robbins
|
|
6
|
+
- Ian Callanan
|
|
7
|
+
contact:
|
|
8
|
+
- rly@lbl.gov
|
|
9
|
+
- oruebel@lbl.gov
|
|
10
|
+
- kay.robbins@utsa.edu
|
|
11
|
+
- ianrcallanan@gmail.com
|
|
12
|
+
doc: NWB extension for HED data
|
|
13
|
+
name: ndx-hed
|
|
14
|
+
schema:
|
|
15
|
+
- namespace: core
|
|
16
|
+
neurodata_types:
|
|
17
|
+
- VectorData
|
|
18
|
+
- source: ndx-hed.extensions.yaml
|
|
19
|
+
version: 0.1.0
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: ndx-hed
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: NWB extension for HED data
|
|
5
|
+
Project-URL: Homepage, https://github.com/hed-standard/ndx-hed
|
|
6
|
+
Project-URL: Documentation, https://https://www.hed-resources.org/en/latest/HedAnnotationInNWB.html
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/hed-standard/ndx-hed/issues
|
|
8
|
+
Project-URL: Discussions, https://github.com/hed-standard/ndx-hed/discussions
|
|
9
|
+
Project-URL: Changelog, https://github.com/hed-standard/ndx-hed/CHANGELOG.md
|
|
10
|
+
Author-email: Ryan Ly <rly@lbl.gov>, Oliver Ruebel <oruebel@lbl.gov>, Kay Robbins <kay.robbins@utsa.edu>, Ian Callanan <ianrcallanan@gmail.com>
|
|
11
|
+
License: BSD-3
|
|
12
|
+
License-File: LICENSE.txt
|
|
13
|
+
Keywords: NWB,NeurodataWithoutBorders,ndx-extension,nwb-extension
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
18
|
+
Classifier: Programming Language :: Python
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Requires-Python: >=3.8
|
|
25
|
+
Requires-Dist: hdmf>=3.14.1
|
|
26
|
+
Requires-Dist: hedtools>=0.5.0
|
|
27
|
+
Requires-Dist: pynwb>=2.8.0
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# ndx-hed Extension for NWB
|
|
31
|
+
|
|
32
|
+
[**Neurodata Without Borders (NWB)**](https://www.nwb.org/) is a data standard for organizing neurophysiology data.
|
|
33
|
+
NWB is used extensively as the data representation for single cell and animal recordings as well as
|
|
34
|
+
human neuroimaging modalities such as IEEG. HED (Hierarchical Event Descriptors) is a system of
|
|
35
|
+
standardized vocabularies and supporting tools that allows fine-grained annotation of data.
|
|
36
|
+
HED annotations can now be used in NWB to provide a column of HED annotations for any NWB
|
|
37
|
+
dynamic table.
|
|
38
|
+
|
|
39
|
+
The [**HED annotation in NWB**](https://www.hed-resources.org/en/latest/HedAnnotationInNWB.html)
|
|
40
|
+
user guide explains in more detail how to use this extension for HED.
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
**Python:**
|
|
46
|
+
```bash
|
|
47
|
+
pip install -U ndx-hed
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Matlab:** The Matlab extension is under development
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
ndx_hed/spec/ndx-hed.extensions.yaml,sha256=Ujh24UBAJCSGKn7WI-h5THllp4qIkXBTEOgi8Wnat4k,452
|
|
2
|
+
ndx_hed/spec/ndx-hed.namespace.yaml,sha256=zmo5P0jNvIz7mwzr6cWmnsSNq_UhfB6GUJ4lbBEmtbw,374
|
|
3
|
+
ndx_hed/__init__.py,sha256=Ep4kOLhuG81AfZ-3ZLvpkgRAJmbB4bJEJfmvYrm7bkA,1971
|
|
4
|
+
ndx_hed/hed_tags.py,sha256=3VMBpVvPY1cnp82agJHPnCl-L8n_qbzvkqoFOFI7mTI,2618
|
|
5
|
+
ndx_hed-0.1.0.dist-info/METADATA,sha256=r9sHAnjfedHRj45NuP5JVLMlthsz6YHvkgE2f6bvEGY,2194
|
|
6
|
+
ndx_hed-0.1.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
7
|
+
ndx_hed-0.1.0.dist-info/licenses/LICENSE.txt,sha256=ogc7sj95gG_7TUtmjl1fBMf0bk9KVI76BgcApFqTxhw,1572
|
|
8
|
+
ndx_hed-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, Ryan Ly, Oliver Ruebel, Kay Robbins
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|