|
@@ -884,7 +884,7 @@ class ReachGraspIO(BlackrockIO):
|
|
|
"""
|
|
|
|
|
|
if self.odmldoc:
|
|
|
- chids = asig.array_annotations['channel_ids']
|
|
|
+ chids = np.asarray(asig.array_annotations['channel_ids'], dtype=int)
|
|
|
neural_chids = [chid in self.avail_electrode_ids for chid in chids]
|
|
|
|
|
|
if not any(neural_chids):
|
|
@@ -894,7 +894,11 @@ class ReachGraspIO(BlackrockIO):
|
|
|
|
|
|
# Annotate filter settings from odML
|
|
|
nchan = asig.shape[-1]
|
|
|
- filter = 'Filter_ns%i' % asig.array_annotations['nsx'][0]
|
|
|
+ if 'nsx' in asig.annotations:
|
|
|
+ nsx = asig.annotations['nsx']
|
|
|
+ else:
|
|
|
+ nsx = asig.array_annotations['nsx'][0]
|
|
|
+ filter = 'Filter_ns%i' % nsx
|
|
|
sec = self.odmldoc['Cerebus']['NeuralSignalProcessor']['NeuralSignals'][filter]
|
|
|
props = sec.properties
|
|
|
hi_pass_freq = np.full((nchan), pq.Quantity(props['HighPassFreq'].values[0],
|
|
@@ -905,7 +909,7 @@ class ReachGraspIO(BlackrockIO):
|
|
|
lo_pass_order = np.zeros_like(lo_pass_freq)
|
|
|
filter_type = np.empty((nchan), np.str)
|
|
|
for chidx in range(nchan):
|
|
|
- filter = 'Filter_ns%i' % asig.array_annotations['nsx'][chidx]
|
|
|
+ filter = 'Filter_ns%i' % nsx
|
|
|
sec = self.odmldoc['Cerebus']['NeuralSignalProcessor']['NeuralSignals'][filter]
|
|
|
hi_pass_freq[chidx] = pq.Quantity(
|
|
|
sec.properties['HighPassFreq'].values[0],
|
|
@@ -970,8 +974,8 @@ class ReachGraspIO(BlackrockIO):
|
|
|
for seg in block.segments:
|
|
|
for obj in seg.analogsignals:
|
|
|
if 'neural_signal' in obj.annotations and obj.annotations[
|
|
|
- 'neural_signal'] and 'channel_ids' in obj.array_annotations:
|
|
|
- chids = obj.array_annotations['channel_ids']
|
|
|
+ 'neural_signal'] and 'channel_ids' in obj.array_annotations:
|
|
|
+ chids = np.asarray(obj.array_annotations['channel_ids'], dtype=int)
|
|
|
ca_ids, *coordinates = self.__convert_chids_and_coordinates(chids)
|
|
|
obj.array_annotations.update(dict(connector_aligned_ids=ca_ids,
|
|
|
coordinates_x=coordinates[0],
|
|
@@ -1032,21 +1036,23 @@ class ReachGraspIO(BlackrockIO):
|
|
|
arraygrid_row_num=sec.properties['GridRows'].values,
|
|
|
arraygrid_col_num=sec.properties['GridColumns'].values)
|
|
|
|
|
|
- secs = self.odmldoc['UtahArray']['Array'].sections
|
|
|
bl.annotate(avail_electrode_ids=self.avail_electrode_ids)
|
|
|
|
|
|
- # TODO: add list of behavioral channels
|
|
|
- # bl.annotate(avail_behavsig_indexes=[])
|
|
|
-
|
|
|
def __correct_filter_shifts(self, asig):
|
|
|
if self.odmldoc and asig.annotations['neural_signal']:
|
|
|
# assert all signals are originating from same nsx file
|
|
|
- if len(np.unique(asig.array_annotations['nsx'])) > 1:
|
|
|
+ if 'nsx' in asig.array_annotations and \
|
|
|
+ len(np.unique(asig.array_annotations['nsx'])) > 1:
|
|
|
raise ValueError('Multiple nsx file origins (%s) in single AnalogSignal'
|
|
|
''.format(asig.array_annotations['nsx']))
|
|
|
|
|
|
+ if 'nsx' in asig.annotations:
|
|
|
+ nsx = asig.annotations['nsx']
|
|
|
+ else:
|
|
|
+ nsx = asig.array_annotations['nsx'][0]
|
|
|
+
|
|
|
# Get and correct for shifts
|
|
|
- filter_name = 'Filter_ns%i' % asig.array_annotations['nsx'][0] # use nsx of 1st signal
|
|
|
+ filter_name = 'Filter_ns%i' % nsx # use nsx of 1st signal
|
|
|
sec = self.odmldoc['Cerebus']['NeuralSignalProcessor']['NeuralSignals'][filter_name]
|
|
|
shift = pq.Quantity(
|
|
|
sec.properties['EstimatedShift'].values[0],
|