diff --git a/spec/ndx-events.extensions.yaml b/spec/ndx-events.extensions.yaml index 34418c8..236eaf5 100644 --- a/spec/ndx-events.extensions.yaml +++ b/spec/ndx-events.extensions.yaml @@ -74,6 +74,14 @@ groups: neurodata_type_inc: DurationVectorData doc: Optional column containing the duration of each event, in seconds. quantity: '?' + - name: value + neurodata_type_inc: VectorData + doc: Optional column containing a value/parameter associated with each event. + For example, if you have three levels of reward (e.g., 1 drop, 2 drops, 3 drops), + instead of encoding each level of reward as its own event type (e.g., 'reward_value_1', + 'reward_value_2', 'reward_value_3', you could encode 'reward' as the event type, + and the value for each event time could be 1, 2, or 3. + quantity: '?' - neurodata_type_def: TtlTypesTable neurodata_type_inc: EventTypesTable default_name: TtlTypesTable diff --git a/src/pynwb/tests/test_events.py b/src/pynwb/tests/test_events.py index 0709041..cc400dd 100644 --- a/src/pynwb/tests/test_events.py +++ b/src/pynwb/tests/test_events.py @@ -281,6 +281,7 @@ def test_add_row(self): stimulus_type="", event_type=0, duration=0.1, + value="", # hed_tags=["(White, Circle)"], ) events_table.add_row( @@ -289,6 +290,7 @@ def test_add_row(self): stimulus_type="animal", event_type=1, duration=0.15, + value="giraffe", ) events_table.add_row( timestamp=1.1, @@ -296,6 +298,7 @@ def test_add_row(self): stimulus_type="", event_type=0, duration=0.1, + value="", # hed_tags=["(Green, Square)"], ) events_table.add_row( @@ -304,12 +307,14 @@ def test_add_row(self): stimulus_type="landscape", event_type=1, duration=0.15, + value="farm", ) assert events_table["timestamp"].data == [0.1, 0.3, 1.1, 1.3] assert events_table["cue_type"].data == ["white circle", "", "green square", ""] assert events_table["stimulus_type"].data == ["", "animal", "", "landscape"] assert events_table["duration"].data == [0.1, 0.15, 0.1, 0.15] assert events_table["event_type"].data == [0, 1, 0, 1] + assert events_table["value"].data == ["", "giraffe", "", "farm"] # assert events_table["hed_tags"][0] == ["(White, Circle)"] # assert events_table["hed_tags"][2] == ["(Green, Square)"] @@ -350,6 +355,7 @@ def test_roundtrip(self): stimulus_type="", event_type=0, duration=0.1, + value="", # hed_tags=["(White, Circle)"], ) events_table.add_row( @@ -358,6 +364,7 @@ def test_roundtrip(self): stimulus_type="animal", event_type=1, duration=0.15, + value="giraffe", ) events_table.add_row( timestamp=1.1, @@ -365,6 +372,7 @@ def test_roundtrip(self): stimulus_type="", event_type=0, duration=0.1, + value="", # hed_tags=["(Green, Square)"], ) events_table.add_row( @@ -373,6 +381,7 @@ def test_roundtrip(self): stimulus_type="landscape", event_type=1, duration=0.15, + value="farm", ) task = Task() @@ -396,6 +405,7 @@ def test_roundtrip(self): assert all(read_events_table["stimulus_type"].data[:] == ["", "animal", "", "landscape"]) assert all(read_events_table["duration"].data[:] == [0.1, 0.15, 0.1, 0.15]) assert all(read_events_table["event_type"].data[:] == [0, 1, 0, 1]) + assert all(read_events_table["value"].data[:] == ["", "giraffe", "", "farm"]) assert read_events_table["event_type"].table is read_event_types_table diff --git a/src/spec/create_extension_spec.py b/src/spec/create_extension_spec.py index be63fe5..60bcecc 100644 --- a/src/spec/create_extension_spec.py +++ b/src/spec/create_extension_spec.py @@ -125,6 +125,19 @@ def main(): doc="Optional column containing the duration of each event, in seconds.", quantity="?", ), + NWBDatasetSpec( + name="value", + neurodata_type_inc="VectorData", + doc=( + "Optional column containing a value/parameter associated with each event. " + "For example, if you have three levels of reward (e.g., 1 drop, 2 drops, " + "3 drops), instead of encoding each level of reward as its own event " + "type (e.g., 'reward_value_1', 'reward_value_2', 'reward_value_3', " + "you could encode 'reward' as the event type, and the value for each " + "event time could be 1, 2, or 3." + ), + quantity="?", + ), ], )