Skip to content

Commit 6da7b5c

Browse files
authored
Merge pull request hed-standard#1083 from VisLab/develop
Fixed group_line error skipping in event_summary
2 parents 64a479a + 33dafb3 commit 6da7b5c

1 file changed

Lines changed: 4 additions & 39 deletions

File tree

hed/tools/analysis/events_summary.py

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def _initialize(self, hed_schema, file, sidecar, name):
6060
self.checker = EventsChecker(hed_schema, self.input_data, name)
6161
self.issues = self.checker.validate_event_tags()
6262
self.error_lines = EventsChecker.get_error_lines(self.issues)
63-
6463

6564
def extract_tag_summary(self):
6665
""" Extract a summary of the tags in a given tabular input file.
@@ -72,7 +71,7 @@ def extract_tag_summary(self):
7271

7372
group_dict = {key: set() for key in self.MATCH_TYPES}
7473
other = set()
75-
group_error_lines = self.error_lines.get(TagQualityErrors.IMPROPER_EVENT_GROUPS)
74+
group_error_lines = self.error_lines.get(TagQualityErrors.IMPROPER_EVENT_GROUPS, [])
7675
for index, hed_obj in enumerate(self.checker.hed_objs):
7776
if not hed_obj or index in group_error_lines:
7877
continue
@@ -111,9 +110,9 @@ def update_tags(self, tag_set, all_tags):
111110
def summarize_tags(schema, tsv, sidecar, name):
112111
""" Summarize the tags in a given tabular input file.
113112
114-
Args:
115-
hed_schema: The HED schema to use for validation.
116-
file: The path to the input file.
113+
Parameters:
114+
schema: The HED schema to use for validation.
115+
tsv: The path to the input file.
117116
sidecar: The path to the sidecar file (optional).
118117
name: The name of the dataset (optional).
119118
@@ -127,37 +126,3 @@ def summarize_tags(schema, tsv, sidecar, name):
127126
summary, others = events_summary.extract_tag_summary()
128127
return summary
129128

130-
131-
if __name__ == '__main__':
132-
schema = load_schema_version('8.4.0')
133-
134-
# # Wakeman Henson example
135-
root_dir = 'g:/HEDExamples/hed-examples/datasets/eeg_ds003645s_hed'
136-
sidecar_path = os.path.join(root_dir, 'task-FacePerception_events.json')
137-
tsv_path = os.path.join(root_dir, 'sub-002/eeg/sub-002_task-FacePerception_run-1_events.tsv')
138-
data_name = 'eeg_ds003645s_hed'
139-
140-
# # Attention shift example
141-
# root_dir = 'g:/HEDExamples/hed-examples/datasets/eeg_ds002893s_hed_attention_shift'
142-
# sidecar_path = os.path.join(root_dir, 'task-AuditoryVisualShift_events.json')
143-
# tsv_path = os.path.join(root_dir, 'sub-002/eeg/sub-002_task-AuditoryVisualShift_run-01_events.tsv')
144-
# data_name = 'eeg_ds002893s_hed_attention_shift'
145-
146-
# Sternberg example
147-
# root_dir = 'g:/HEDExamples/hed-examples/datasets/eeg_ds004117s_hed_sternberg'
148-
# sidecar_path = os.path.join(root_dir, 'task-WorkingMemory_events.json')
149-
# tsv_path = os.path.join(root_dir, 'sub-001/ses-01/eeg/sub-001_ses-01_task-WorkingMemory_run-1_events.tsv')
150-
# data_name = 'eeg_ds004117s_hed_sternberg'
151-
152-
# Create the event summary
153-
summary = summarize_tags(schema, tsv_path, sidecar=sidecar_path, name=data_name)
154-
if summary is None:
155-
print("Fatal errors in the input file. Cannot summarize tags.")
156-
exit(1)
157-
158-
for the_key, the_item in summary.items():
159-
if not the_item:
160-
continue
161-
print(f"{the_key}:")
162-
for the_tag in the_item:
163-
print(f" {the_tag}")

0 commit comments

Comments
 (0)