-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from VisLab/main
Did some renaming of classes
- Loading branch information
Showing
10 changed files
with
383 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
# NOTE: it may be possible to relax these minimum requirements | ||
pynwb==2.5.0 | ||
hdmf==3.10.0 | ||
hedtools==0.4.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
datasets: | ||
- neurodata_type_def: HedAnnotations | ||
neurodata_type_inc: VectorData | ||
dtype: text | ||
doc: An extension of VectorData for Hierarchical Event Descriptor (HED) tags. If | ||
HED tags are used, the HED schema version must be specified in the NWB file using | ||
the HedMetadata type. | ||
groups: | ||
- neurodata_type_def: HedMetadata | ||
neurodata_type_inc: LabMetaData | ||
name: HedMetadata | ||
doc: An extension of LabMetaData to store the Hierarchical Event Descriptor (HED) | ||
schema version. TODO When merged with core, this will no longer inherit from LabMetaData | ||
but from NWBContainer and be placed optionally in /general. | ||
attributes: | ||
- name: hed_schema_version | ||
dtype: text | ||
doc: The version of the HED schema used to validate the HED tags, e.g., '8.2.0'. | ||
Required if HED tags are used in the NWB file. | ||
datasets: | ||
- neurodata_type_def: HedAnnotations | ||
neurodata_type_inc: VectorData | ||
dtype: text | ||
doc: An extension of VectorData for Hierarchical Event Descriptor (HED) tags. If | ||
HED tags are used, the HED schema version must be specified in the NWB file using | ||
the HedVersion type. | ||
attributes: | ||
- name: sub_name | ||
dtype: text | ||
doc: The smallest possible difference between two event times. Usually 1 divided | ||
by the event time sampling rate on the data acquisition system. | ||
required: false | ||
groups: | ||
- neurodata_type_def: HedVersion | ||
neurodata_type_inc: LabMetaData | ||
name: hed_version | ||
doc: An extension of LabMetaData to store the Hierarchical Event Descriptor (HED) | ||
schema version. TODO When merged with core, this will no longer inherit from LabMetaData | ||
but from NWBContainer and be placed optionally in /general. | ||
attributes: | ||
- name: version | ||
dtype: text | ||
shape: | ||
- null | ||
doc: The version of the HED schema used to validate the HED tags, e.g., '8.2.0'. | ||
Required if HED tags are used in the NWB file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
namespaces: | ||
- author: | ||
- Ryan Ly | ||
- Oliver Ruebel | ||
- Kay Robbins | ||
- Ian Callanan | ||
contact: | ||
- [email protected] | ||
- [email protected] | ||
- [email protected] | ||
- [email protected] | ||
doc: NWB extension for HED data | ||
name: ndx-hed | ||
schema: | ||
- namespace: core | ||
- source: ndx-hed.extensions.yaml | ||
version: 0.1.0 | ||
namespaces: | ||
- author: | ||
- Ryan Ly | ||
- Oliver Ruebel | ||
- Kay Robbins | ||
- Ian Callanan | ||
contact: | ||
- [email protected] | ||
- [email protected] | ||
- [email protected] | ||
- [email protected] | ||
doc: NWB extension for HED data | ||
name: ndx-hed | ||
schema: | ||
- namespace: core | ||
- source: ndx-hed.extensions.yaml | ||
version: 0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
from collections.abc import Iterable | ||
from hdmf.common import VectorData | ||
from hdmf.utils import docval, getargs, get_docval, popargs | ||
from hed.schema import HedSchema, HedSchemaGroup, load_schema_version | ||
from pynwb import register_class | ||
from pynwb.file import LabMetaData | ||
|
||
|
||
@register_class('HedAnnotations', 'ndx-hed') | ||
class HedAnnotations(VectorData): | ||
""" | ||
Column storing HED (Hierarchical Event Descriptors) annotations for a row. A HED string is a comma-separated, | ||
and possibly parenthesized list of HED tags selected from a valid HED vocabulary as specified by the | ||
NWBFile field HEDVersion. | ||
""" | ||
|
||
__nwbfields__ = ('sub_name') | ||
|
||
@docval(*get_docval(VectorData.__init__)) | ||
def __init__(self, **kwargs): | ||
# kwargs['name'] = 'HED' | ||
super().__init__(**kwargs) | ||
self._init_internal() | ||
|
||
def _init_internal(self): | ||
""" | ||
This finds the HED schema object of use in this NWBFile. | ||
TODO: How should errors be handled if this file doesn't have a HedVersion object in the LabMetaData? | ||
""" | ||
self.sub_name = "HED" | ||
root = self | ||
# parent = root.parent | ||
# while parent is not None: | ||
# root = parent | ||
# parent = root.parent | ||
# hed_version = parent.get_lab_meta_data("HedVersion") | ||
# if hed_version: | ||
# self.hed_schema = hed_version.get_schema() | ||
|
||
@docval({'name': 'val', 'type': str, | ||
'doc': 'the value to add to this column. Should be a valid HED string.'}) | ||
def add_row(self, **kwargs): | ||
"""Append a data value to this column.""" | ||
val = getargs('val', kwargs) | ||
# val.check_types() | ||
# TODO how to validate | ||
# | ||
# if val is not None and self.validate(val): | ||
# if self.term_set.validate(term=val): | ||
# self.append(val) | ||
# else: | ||
# msg = ("%s is not in the term set." % val) | ||
# raise ValueError(msg) | ||
# | ||
# else: | ||
# self.append(val) | ||
super().append(val) | ||
|
||
@docval({'name': 'key', 'type': 'str', 'doc': 'the value to add to this column'}) | ||
def get(self, key): | ||
""" | ||
Retrieve elements from this object. | ||
""" | ||
# TODO: Can key be more than a single value? Do we need to check validity of anything? | ||
vals = super().get(key) | ||
return vals | ||
|
||
@docval({'name': 'val', 'type': 'str', 'doc': 'the value to validate'}, | ||
{'name': 'return', 'type': 'list', 'doc': 'list of issues or none'}) | ||
def validate(self, **kwargs): | ||
"""Validate this HED string""" | ||
val = getargs('val', kwargs) | ||
return True | ||
|
||
|
||
@register_class("HedVersion", "ndx-hed") | ||
class HedVersion(LabMetaData): | ||
""" | ||
The class containing the HED versions and HED schema used in this data file. | ||
""" | ||
|
||
__nwbfields__ = ('name', 'description', 'version') | ||
|
||
@docval({'name': 'version', 'type': (str, list), 'doc': 'HED strings of type str'}) | ||
def __init__(self, version): | ||
kwargs = {'name': 'hed_version'} | ||
super().__init__(**kwargs) | ||
self.version = version | ||
self._init_internal() | ||
|
||
def _init_internal(self): | ||
""" | ||
Create a HedSchema or HedSchemaGroup object from the HED Versions | ||
""" | ||
self._hed_schema = load_schema_version(self.version) | ||
|
||
@docval(returns='The HED schema or schema group object for this version', rtype=(HedSchema, HedSchemaGroup)) | ||
def get_hed_schema(self): | ||
return self._hed_schema |
Oops, something went wrong.