|
@@ -915,26 +915,27 @@ class ReachGraspIO(BlackrockIO):
|
|
|
filter_type=filter_type
|
|
|
))
|
|
|
|
|
|
- # Get rejection bands
|
|
|
- sec = self.odmldoc['PreProcessing']
|
|
|
- bands = sec.properties['LFPBands'].values
|
|
|
+ self.__annotate_electrode_rejections(asig)
|
|
|
|
|
|
- if hasattr(bands, '__iter__'):
|
|
|
- for band in bands:
|
|
|
- sec = self.odmldoc['PreProcessing'][band]
|
|
|
+ def __annotate_electrode_rejections(self, obj):
|
|
|
+ # Get rejection bands
|
|
|
+ sec = self.odmldoc['PreProcessing']
|
|
|
+ bands = sec.properties['LFPBands'].values
|
|
|
|
|
|
- # default: No rejection information present
|
|
|
- rej = np.full((asig.shape[-1]), None)
|
|
|
-
|
|
|
- if sec.properties['RejElectrodes'].values:
|
|
|
- rej_els = np.asarray(sec.properties['RejElectrodes'].values, dtype=int)
|
|
|
- rej = np.isin(asig.array_annotations['channel_ids'], rej_els)
|
|
|
- else:
|
|
|
- raise ValueError(
|
|
|
- "Invalid entry %s in odML for rejected electrodes "
|
|
|
- "in LFP band %s." % (sec.properties['RejElectrodes'].values, band))
|
|
|
+ if hasattr(bands, '__iter__'):
|
|
|
+ for band in bands:
|
|
|
+ sec = self.odmldoc['PreProcessing'][band]
|
|
|
+ rej_els = np.asarray(sec.properties['RejElectrodes'].values, dtype=int)
|
|
|
|
|
|
- asig.array_annotations.update({str('electrode_reject_' + band): rej})
|
|
|
+ if 'channel_id' in obj.annotations:
|
|
|
+ rejection_value = bool(obj.annotations['channel_id'] in rej_els)
|
|
|
+ obj.annotations['electrode_reject_' + band] = rejection_value
|
|
|
+ elif hasattr(obj, 'array_annotations') and 'channel_ids' in obj.array_annotations:
|
|
|
+ rej = np.isin(obj.array_annotations['channel_ids'], rej_els)
|
|
|
+ obj.array_annotations.update({str('electrode_reject_' + band): rej})
|
|
|
+ else:
|
|
|
+ warnings.warn(
|
|
|
+ 'Could not annotate {} with electrode rejection information.'.format(obj))
|
|
|
|
|
|
def __convert_chids_and_coordinates(self, channel_ids):
|
|
|
nchan = len(channel_ids)
|
|
@@ -1667,6 +1668,9 @@ class ReachGraspIO(BlackrockIO):
|
|
|
if correct_filter_shifts:
|
|
|
self.__correct_filter_shifts(asig)
|
|
|
|
|
|
+ for st in seg.spiketrains:
|
|
|
+ self.__annotate_electrode_rejections(st)
|
|
|
+
|
|
|
for ev in seg.events:
|
|
|
# Modify digital trial events to include semantic event information
|
|
|
if ev.name == 'digital_input_port':
|