Skip to content

Commit 2a641f3

Browse files
authored
Merge branch 'hed-standard:develop' into develop
2 parents 840bd4b + da56f4c commit 2a641f3

8 files changed

Lines changed: 35 additions & 17 deletions

File tree

hed/models/string_util.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
from hed.models.hed_string import HedString
22

33

4+
def gather_descriptions(hed_string):
5+
"""Removes any description tags from the string and concatenates them
6+
7+
Parameters:
8+
hed_string(HedString): To be modified
9+
10+
Returns: tuple
11+
description(str): The concatenated values of all description tags.
12+
13+
Side-effect:
14+
The input HedString has its Definition tags removed.
15+
16+
"""
17+
desc_tags = hed_string.find_tags("description", recursive=True, include_groups=0)
18+
desc_string = " ".join([tag.extension if tag.extension.endswith(".") else tag.extension + "." for tag in desc_tags])
19+
20+
hed_string.remove(desc_tags)
21+
22+
return desc_string
23+
24+
425
def split_base_tags(hed_string, base_tags, remove_group=False):
526
""" Splits a HedString object into two separate HedString objects based on the presence of base tags.
627

hed/tools/analysis/annotation_util.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ def merge_hed_dict(sidecar_dict, hed_dict):
165165
hed_dict(dict): Dictionary derived from a dataframe representation of HED in sidecar.
166166
167167
"""
168+
168169
for key, value_dict in hed_dict.items():
169170
if key not in sidecar_dict:
170171
sidecar_dict[key] = value_dict

tests/data/bids_tests/eeg_ds003645s_hed/task-FacePerception_events.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@
6060
}
6161
},
6262
"trial": {
63-
"Description": "Indicates which trial this event belongs to.",
64-
"HED": "Experimental-trial/#"
63+
"Description": "Indicates which trial this event belongs to."
6564
},
6665
"rep_lag": {
6766
"Description": "How face images before this one was the image was previously presented.",

tests/data/bids_tests/eeg_ds003645s_hed_inheritance/task-FacePerception_events.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@
4343
}
4444
},
4545
"trial": {
46-
"Description": "Indicates which trial this event belongs to.",
47-
"HED": "Experimental-trial/#"
46+
"Description": "Indicates which trial this event belongs to."
4847
},
4948
"stim_file": {
5049
"Description": "Path of the stimulus file in the stimuli directory.",

tests/data/bids_tests/eeg_ds003645s_hed_library/task-FacePerception_events.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@
6060
}
6161
},
6262
"trial": {
63-
"Description": "Indicates which trial this event belongs to.",
64-
"HED": "Experimental-trial/#, test:Informational-property, sc:Discontinuous-background-activity"
63+
"Description": "Indicates which trial this event belongs to."
6564
},
6665
"rep_lag": {
6766
"Description": "How face images before this one was the image was previously presented.",
-7 Bytes
Binary file not shown.

tests/tools/analysis/test_event_manager.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,11 @@ def test_str_list_to_hed(self):
6565

6666
hed_obj2 = manager.str_list_to_hed([hed[1], base[1], '(Event-context, (' + context[1] + '))'])
6767
self.assertIsInstance(hed_obj2, HedString)
68-
self.assertEqual(10, len(hed_obj2.children))
68+
self.assertEqual(9, len(hed_obj2.children))
6969
hed3, base3, context3 = manager.unfold_context(remove_types=['Condition-variable', 'Task'])
70-
7170
hed_obj3 = manager.str_list_to_hed([hed3[1], base3[1], '(Event-context, (' + context3[1] + '))'])
7271
self.assertIsInstance(hed_obj3, HedString)
73-
self.assertEqual(6, len(hed_obj3.children))
72+
self.assertEqual(5, len(hed_obj3.children))
7473

7574
def test_get_type_defs(self):
7675
manager1 = EventManager(self.input_data, self.schema)

tests/tools/analysis/test_hed_tag_counts.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_constructor(self):
4848
counts.update_event_counts(HedString(self.input_df.iloc[k]['HED_assembled'], self.hed_schema),
4949
file_name='Base_name')
5050
self.assertIsInstance(counts.tag_dict, dict)
51-
self.assertEqual(len(counts.tag_dict), 15)
51+
self.assertEqual(14, len(counts.tag_dict))
5252

5353
def test_merge_tag_dicts(self):
5454
counts1 = HedTagCounts('Base_name1', 50)
@@ -61,10 +61,10 @@ def test_merge_tag_dicts(self):
6161
counts3 = HedTagCounts("All", 0)
6262
counts3.merge_tag_dicts(counts1.tag_dict)
6363
counts3.merge_tag_dicts(counts2.tag_dict)
64-
self.assertEqual(len(counts1.tag_dict), 15)
65-
self.assertEqual(len(counts2.tag_dict), 15)
66-
self.assertEqual(len(counts3.tag_dict), 15)
67-
self.assertEqual(counts3.tag_dict['experiment-structure'].events, 2)
64+
self.assertEqual(14, len(counts1.tag_dict))
65+
self.assertEqual(14, len(counts2.tag_dict))
66+
self.assertEqual(14, len(counts3.tag_dict))
67+
self.assertEqual(2, counts3.tag_dict['experiment-structure'].events)
6868

6969
def test_hed_tag_count(self):
7070
name = 'Base_name1'
@@ -82,10 +82,10 @@ def test_organize_tags(self):
8282
for hed in hed_strings:
8383
counts.update_event_counts(hed, 'run-1')
8484
self.assertIsInstance(counts.tag_dict, dict)
85-
self.assertEqual(len(counts.tag_dict), 47)
85+
self.assertEqual(46, len(counts.tag_dict))
8686
org_tags, leftovers = counts.organize_tags(self.tag_template)
87-
self.assertEqual(len(org_tags), 19)
88-
self.assertEqual(len(leftovers), 22)
87+
self.assertEqual(19, len(org_tags))
88+
self.assertEqual(21, len(leftovers))
8989

9090

9191
if __name__ == '__main__':

0 commit comments

Comments
 (0)