Browse Source

Fix r2gio annotation dtypes

Julia Sprenger 11 months ago
parent
commit
bc1fbddf69
1 changed files with 9 additions and 3 deletions
  1. 9 3
      code/reachgraspio/reachgraspio.py

+ 9 - 3
code/reachgraspio/reachgraspio.py

@@ -783,7 +783,7 @@ class ReachGraspIO(BlackrockIO):
         unit_dict = {}
         for seg in block.segments:
             for st in seg.spiketrains:
-                chid = st.annotations['channel_id']
+                chid = str(st.annotations['channel_id'])
                 unit_id = st.annotations['unit_id']
                 if chid not in unit_dict:
                     unit_dict[chid] = {}
@@ -843,7 +843,7 @@ class ReachGraspIO(BlackrockIO):
 
             try:
                 sec = self.odmldoc['UtahArray']['Array'][
-                    'Electrode_%03d' % un.annotations['channel_id']][
+                    'Electrode_%03d' % int(un.annotations['channel_id'])][
                     'OfflineSpikeSorting']
             except KeyError:
                 return
@@ -914,7 +914,7 @@ class ReachGraspIO(BlackrockIO):
                                                             props['LowPassFreq'].unit))
                 hi_pass_order = np.zeros_like(hi_pass_freq)
                 lo_pass_order = np.zeros_like(lo_pass_freq)
-                filter_type = np.empty((nchan), np.str)
+                filter_type = np.empty((nchan), str)
                 for chidx in range(nchan):
                     filter = 'Filter_ns%i' % nsx
                     sec = self.odmldoc['Cerebus']['NeuralSignalProcessor']['NeuralSignals'][filter]
@@ -1001,8 +1001,14 @@ class ReachGraspIO(BlackrockIO):
             for seg in block.segments:
                 sts.extend(seg.spiketrains)
 
+            # use same dtypes for annotations and array_annotations
+            for st in sts:
+                st.annotations['channel_id'] = str(st.annotations['channel_id'])
+
             for obj in sts + block.groups:
                 if 'channel_id' in obj.annotations:
+                    # use same dtype for annotations as array_annotations
+                    obj.annotations['channel_id'] = str(obj.annotations['channel_id'])
                     chid = obj.annotations['channel_id']
                     ca_id, *coordinates = self.__convert_chids_and_coordinates([chid])
                     obj.annotate(connector_aligned_id=ca_id[0],