Browse Source

Added version of reachgraspio that uses arrayannotations

Michael Denker 4 years ago
parent
commit
90a4797b47
1 changed files with 16 additions and 16 deletions
  1. 16 16
      code/reachgraspio/reachgraspio.py

+ 16 - 16
code/reachgraspio/reachgraspio.py

@@ -456,14 +456,14 @@ class ReachGraspIO(BlackrockIO):
 
                 if type(sec.properties['RejTrials'].values) != [-1]:
                     rej_trials = [int(_) for _ in sec.properties['RejTrials'].values]
-                    rej_index = np.in1d(event.annotations['trial_id'], rej_trials)
+                    rej_index = np.in1d(event.array_annotations['trial_id'], rej_trials)
                 elif sec.properties['RejTrials'].values == [-1]:
-                    rej_index = np.zeros((len(event.annotations['trial_id'])), dtype=bool)
+                    rej_index = np.zeros((len(event.array_annotations['trial_id'])), dtype=bool)
                 else:
                     raise ValueError(
                         "Invalid entry %s in odML for rejected trials in LFP  band %s." %
                         (sec.properties['RejTrials'].values, band))
-                event.annotate(**{str('trial_reject_' + band): list(rej_index)})
+                event.array_annotate(**{str('trial_reject_' + band): list(rej_index)})
 
     def __extract_task_condition(self, trialtypes):
         """
@@ -538,7 +538,7 @@ class ReachGraspIO(BlackrockIO):
             name='AnalogTrialEvents',
             description='Events extracted from analog signals')
 
-        analog_events.annotate(
+        analog_events.array_annotate(
             trial_id=trial_id,
             trial_timestamp_id=trial_timestamp_id,
             performance_in_trial=performance_code,
@@ -741,13 +741,13 @@ class ReachGraspIO(BlackrockIO):
                     raise ValueError("Unknown event label.")
 
         # add modified trial_event_labels to annotations
-        events.annotate(trial_event_labels=trial_event_labels)
+        events.array_annotate(trial_event_labels=trial_event_labels)
 
         # add trial timestamp IDs
-        events.annotate(trial_timestamp_id=trial_timestamp_ID)
+        events.array_annotate(trial_timestamp_id=trial_timestamp_ID)
 
         # add trial IDs
-        events.annotate(trial_id=trial_ID)
+        events.array_annotate(trial_id=trial_ID)
 
         # add modified belongs_to_trialtype to annotations
         for tid in trial_timestamp_ID:
@@ -755,12 +755,12 @@ class ReachGraspIO(BlackrockIO):
                 trialtypes[tid] = 'NONE'
         belongs_to_trialtype = [
             trialtypes[tid] for tid in trial_timestamp_ID]
-        events.annotate(belongs_to_trialtype=belongs_to_trialtype)
+        events.array_annotate(belongs_to_trialtype=belongs_to_trialtype)
 
         # add modified trial_performance_codes to annotations
         performance_in_trial = [
             trialsequence[tid] for tid in trial_timestamp_ID]
-        events.annotate(performance_in_trial=performance_in_trial)
+        events.array_annotate(performance_in_trial=performance_in_trial)
 
     def __annotate_units_with_odml(self, units):
         """
@@ -1001,15 +1001,15 @@ class ReachGraspIO(BlackrockIO):
 
                 # Transfer annotations
                 trial_id.extend(
-                    event.annotations['trial_id'])
+                    event.array_annotations['trial_id'])
                 trial_timestamp_id.extend(
-                    event.annotations['trial_timestamp_id'])
+                    event.array_annotations['trial_timestamp_id'])
                 performance_code.extend(
-                    event.annotations['performance_in_trial'])
+                    event.array_annotations['performance_in_trial'])
                 trial_type.extend(
-                    event.annotations['belongs_to_trialtype'])
+                    event.array_annotations['belongs_to_trialtype'])
                 event_name.extend(
-                    event.annotations['trial_event_labels'])
+                    event.array_annotations['trial_event_labels'])
 
         # Sort time stamps and save sort order
         sort_idx = np.argsort(event_time)
@@ -1022,7 +1022,7 @@ class ReachGraspIO(BlackrockIO):
             name='TrialEvents',
             description='All trial events (digital and analog)')
 
-        merged_event.annotate(
+        merged_event.array_annotate(
             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],
@@ -1536,7 +1536,7 @@ class ReachGraspIO(BlackrockIO):
                     self.__add_rejection_to_event(ev)
 
                     cnd = self.__extract_task_condition(
-                        ev.annotations['belongs_to_trialtype'])
+                        ev.array_annotations['belongs_to_trialtype'])
                     seg.annotate(condition=cnd)
 
             # If digital trial events exist, extract analog events from odML