Browse Source

RGIO: Avoid invalid annotation dtype and improve array annotations

Julia Sprenger 4 years ago
parent
commit
4a5cc51b67
1 changed files with 13 additions and 1 deletions
  1. 13 1
      code/reachgraspio/reachgraspio.py

+ 13 - 1
code/reachgraspio/reachgraspio.py

@@ -538,10 +538,18 @@ class ReachGraspIO(BlackrockIO):
             name='AnalogTrialEvents',
             description='Events extracted from analog signals')
 
+        performance_str = []
+        for pit in performance_code:
+            if pit in self.performance_codes:
+                performance_str.append(self.performance_codes[pit])
+            else:
+                performance_str.append('unknown')
+
         analog_events.array_annotate(
             trial_id=trial_id,
             trial_timestamp_id=trial_timestamp_id,
             performance_in_trial=performance_code,
+            performance_in_trial_str=performance_str,
             belongs_to_trialtype=trial_type,
             trial_event_labels=event_name)
 
@@ -928,7 +936,7 @@ class ReachGraspIO(BlackrockIO):
             subject_name=sec.properties['GivenName'].values,
             subject_gender=sec.properties['Gender'].values,
             subject_activehand=sec.properties['ActiveHand'].values,
-            subject_birthday=sec.properties['Birthday'].values)
+            subject_birthday=str(sec.properties['Birthday'].values))  # datetime is not a valid annotation dtype
 
         sec = self.odmldoc['Setup']
         bl.annotate(setup_location=sec.properties['Location'].values)
@@ -992,6 +1000,7 @@ class ReachGraspIO(BlackrockIO):
         trial_id = []
         trial_timestamp_id = []
         performance_code = []
+        performance_str = []
         trial_type = []
 
         for event in events:
@@ -1012,6 +1021,8 @@ class ReachGraspIO(BlackrockIO):
                     event.array_annotations['trial_timestamp_id'])
                 performance_code.extend(
                     event.array_annotations['performance_in_trial'])
+                performance_str.extend(
+                    event.array_annotations['performance_in_trial_str'])
                 trial_type.extend(
                     event.array_annotations['belongs_to_trialtype'])
                 event_name.extend(
@@ -1032,6 +1043,7 @@ class ReachGraspIO(BlackrockIO):
             trial_id=[trial_id[_] for _ in sort_idx],
             trial_timestamp_id=[trial_timestamp_id[_] for _ in sort_idx],
             performance_in_trial=[performance_code[_] for _ in sort_idx],
+            performance_in_trial_str=[performance_str[_] for _ in sort_idx],
             belongs_to_trialtype=[trial_type[_] for _ in sort_idx],
             trial_event_labels=[event_name[_] for _ in sort_idx])