|
@@ -128,9 +128,6 @@ def get_arraygrid(blackrock_elid_list, chosen_el, rej_el=None):
|
|
|
# monkey = 'Nikos2'
|
|
|
monkey = 'Lilou'
|
|
|
|
|
|
-nsx_none = {'Lilou': None, 'Nikos2': None}
|
|
|
-nsx_lfp = {'Lilou': 2, 'Nikos2': 2}
|
|
|
-nsx_raw = {'Lilou': 5, 'Nikos2': 6}
|
|
|
chosen_el = {'Lilou': 71, 'Nikos2': 63}
|
|
|
chosen_units = {'Lilou': range(1, 5), 'Nikos2': range(1, 5)}
|
|
|
|
|
@@ -141,19 +138,24 @@ session = reachgraspio.ReachGraspIO(
|
|
|
odml_directory=datasetdir,
|
|
|
verbose=False)
|
|
|
|
|
|
-bl = session.read_block(lazy=False, load_waveforms=False, scaling='voltage')
|
|
|
+# loads only ns2 data of all channels an chosen units
|
|
|
+#bl_lfp = session.read_block(
|
|
|
|
|
|
-seg = bl.segments[0]
|
|
|
+# loads raw data of chosen electrode and chosen units
|
|
|
+#bl_raw = session.read_block(
|
|
|
+
|
|
|
+block = session.read_block(lazy=True)
|
|
|
+segment = block.segment[0]
|
|
|
|
|
|
# Displaying loaded data structure as string output
|
|
|
print("\nBlock")
|
|
|
-print('Attributes ', bl.__dict__.keys())
|
|
|
-print('Annotations', bl_raw.annotations)
|
|
|
+print('Attributes ', block.__dict__.keys())
|
|
|
+print('Annotations', block.annotations)
|
|
|
print("\nSegment")
|
|
|
-print('Attributes ', seg_raw.__dict__.keys())
|
|
|
-print('Annotations', seg_raw.annotations)
|
|
|
+print('Attributes ', segment.__dict__.keys())
|
|
|
+print('Annotations', segment.annotations)
|
|
|
print("\nEvents")
|
|
|
-for x in seg_raw.events:
|
|
|
+for x in segment.events:
|
|
|
print('\tEvent with name', x.name)
|
|
|
print('\t\tAttributes ', x.__dict__.keys())
|
|
|
print('\t\tAnnotation keys', x.annotations.keys())
|
|
@@ -162,43 +164,39 @@ for x in seg_raw.events:
|
|
|
'trial_reject_IFC']:
|
|
|
print('\t\t'+anno_key, x.annotations[anno_key][:20])
|
|
|
|
|
|
-print("\nChannels")
|
|
|
-for x in bl_raw.channel_indexes:
|
|
|
- print('\tChannel with name', x.name)
|
|
|
- print('\t\tAttributes ', x.__dict__.keys())
|
|
|
- print('\t\tchannel_ids', x.channel_ids)
|
|
|
- print('\t\tchannel_names', x.channel_names)
|
|
|
- print('\t\tAnnotations', x.annotations)
|
|
|
-print("\nUnits")
|
|
|
-for x in bl_raw.list_units:
|
|
|
- print('\tUnit with name', x.name)
|
|
|
+print("\nGroups")
|
|
|
+for x in block.groups:
|
|
|
+ print('\tGroup with name', x.name)
|
|
|
print('\t\tAttributes ', x.__dict__.keys())
|
|
|
print('\t\tAnnotations', x.annotations)
|
|
|
- print('\t\tchannel_id', x.annotations['channel_id'])
|
|
|
- assert(x.annotations['channel_id'] == x.channel_index.channel_ids[0])
|
|
|
+ # TODO: Add more here
|
|
|
+
|
|
|
print("\nSpikeTrains")
|
|
|
-for x in seg_raw.spiketrains:
|
|
|
+for x in segment.spiketrains:
|
|
|
print('\tSpiketrain with name', x.name)
|
|
|
print('\t\tAttributes ', x.__dict__.keys())
|
|
|
print('\t\tAnnotations', x.annotations)
|
|
|
print('\t\tchannel_id', x.annotations['channel_id'])
|
|
|
+ print('\t\tunit_id', x.annotations['unit_id'])
|
|
|
+ print('\t\tis sua', x.annotations['sua'])
|
|
|
+ print('\t\tis mua', x.annotations['mua'])
|
|
|
print('\t\tspike times', x.times[0:20])
|
|
|
print("\nAnalogSignals")
|
|
|
-for x in seg_raw.analogsignals:
|
|
|
+for x in segment.analogsignals:
|
|
|
print('\tAnalogSignal with name', x.name)
|
|
|
print('\t\tAttributes ', x.__dict__.keys())
|
|
|
print('\t\tAnnotations', x.annotations)
|
|
|
- print('\t\tchannel_id', x.annotations['channel_id'])
|
|
|
+ print('\t\tchannel_ids', x.annotations['channel_ids'])
|
|
|
|
|
|
# get start and stop events of trials
|
|
|
start_events = neo_utils.get_events(
|
|
|
- seg_raw,
|
|
|
+ segment,
|
|
|
properties={
|
|
|
'name': 'TrialEvents',
|
|
|
'trial_event_labels': 'TS-ON',
|
|
|
'performance_in_trial': 255})
|
|
|
stop_events = neo_utils.get_events(
|
|
|
- seg_raw,
|
|
|
+ segment,
|
|
|
properties={
|
|
|
'name': 'TrialEvents',
|
|
|
'trial_event_labels': 'STOP',
|
|
@@ -210,7 +208,7 @@ assert len(stop_events) == 1
|
|
|
|
|
|
# insert epochs between 10ms before TS to 50ms after RW corresponding to trails
|
|
|
neo_utils.add_epoch(
|
|
|
- seg_raw,
|
|
|
+ segment,
|
|
|
start_events[0],
|
|
|
stop_events[0],
|
|
|
pre=-250 * pq.ms,
|
|
@@ -220,30 +218,26 @@ neo_utils.add_epoch(
|
|
|
trial_performance=start_events[0].annotations['performance_in_trial'])
|
|
|
|
|
|
# access single epoch of this data_segment
|
|
|
-epochs = neo_utils.get_epochs(seg_raw,
|
|
|
+epochs = neo_utils.get_epochs(segment,
|
|
|
properties={'trial_status': 'complete_trials'})
|
|
|
assert len(epochs) == 1
|
|
|
|
|
|
# cut segments according to inserted 'complete_trials' epochs and reset trial
|
|
|
# times
|
|
|
-cut_segments_raw = neo_utils.cut_segment_by_epoch(
|
|
|
- seg_raw, epochs[0], reset_time=True)
|
|
|
-
|
|
|
-cut_segments_lfp = neo_utils.cut_segment_by_epoch(
|
|
|
- seg_lfp, epochs[0], reset_time=True)
|
|
|
+cut_segments = neo_utils.cut_segment_by_epoch(
|
|
|
+ segment, epochs[0], reset_time=True)
|
|
|
|
|
|
# =============================================================================
|
|
|
# Define data for overview plots
|
|
|
# =============================================================================
|
|
|
trial_index = {'Lilou': 0, 'Nikos2': 6}
|
|
|
|
|
|
-trial_seg_raw = cut_segments_raw[trial_index[monkey]]
|
|
|
-trial_seg_lfp = cut_segments_lfp[trial_index[monkey]]
|
|
|
+trial_segment = cut_segments[trial_index[monkey]]
|
|
|
|
|
|
-blackrock_elid_list = bl_lfp.annotations['avail_electrode_ids']
|
|
|
+blackrock_elid_list = block.annotations['avail_electrode_ids']
|
|
|
|
|
|
# get 'TrialEvents'
|
|
|
-event = trial_seg_lfp.events[2]
|
|
|
+event = trial_segment.events[2]
|
|
|
start = event.annotations['trial_event_labels'].index('TS-ON')
|
|
|
trialx_trty = event.annotations['belongs_to_trialtype'][start]
|
|
|
trialx_trtimeid = event.annotations['trial_timestamp_id'][start]
|
|
@@ -255,7 +249,7 @@ if 'LF' in trialx_trty:
|
|
|
else:
|
|
|
trialz_trty = trialx_trty.replace('HF', 'LF')
|
|
|
|
|
|
-for i, tr in enumerate(cut_segments_lfp):
|
|
|
+for i, tr in enumerate(cut_segments):
|
|
|
eventz = tr.events[2]
|
|
|
nextft = eventz.annotations['trial_event_labels'].index('TS-ON')
|
|
|
if eventz.annotations['belongs_to_trialtype'][nextft] == trialz_trty:
|
|
@@ -428,7 +422,7 @@ unit_type = {1: '', 2: '', 3: ''}
|
|
|
|
|
|
wf_lim = []
|
|
|
# plotting waveform for all spiketrains available
|
|
|
-for spiketrain in trial_seg_raw.spiketrains:
|
|
|
+for spiketrain in trial_segment.spiketrains:
|
|
|
unit_id = spiketrain.annotations['unit_id']
|
|
|
# get unit type
|
|
|
if spiketrain.annotations['sua']:
|
|
@@ -479,7 +473,7 @@ ax2d.yaxis.set_label_position("right")
|
|
|
plotted_unit_ids = []
|
|
|
|
|
|
# plotting all available spiketrains
|
|
|
-for st in trial_seg_raw.spiketrains:
|
|
|
+for st in trial_segment.spiketrains:
|
|
|
unit_id = st.annotations['unit_id']
|
|
|
plotted_unit_ids.append(unit_id)
|
|
|
ax3.plot(st.times.rescale(plotting_time_unit),
|
|
@@ -500,8 +494,8 @@ ax3.set_title('spiketrains', fontdict_titles)
|
|
|
# PLOT "raw" SIGNAL of chosen trial of chosen electrode
|
|
|
# =============================================================================
|
|
|
# get "raw" data from chosen electrode
|
|
|
-assert len(trial_seg_raw.analogsignals) == 1
|
|
|
-el_raw_sig = trial_seg_raw.analogsignals[0]
|
|
|
+assert len(trial_segment.analogsignals) == 1
|
|
|
+el_raw_sig = trial_segment.analogsignals[0]
|
|
|
|
|
|
# plotting raw signal trace
|
|
|
ax4.plot(el_raw_sig.times.rescale(plotting_time_unit),
|
|
@@ -515,8 +509,8 @@ ax4.tick_params(axis='y', direction='in', length=3, labelsize='xx-small',
|
|
|
labelleft='off', labelright='on')
|
|
|
ax4.set_title('"raw" signal', fontdict_titles)
|
|
|
|
|
|
-ax4.set_xlim(trial_seg_raw.t_start.rescale(plotting_time_unit),
|
|
|
- trial_seg_raw.t_stop.rescale(plotting_time_unit))
|
|
|
+ax4.set_xlim(trial_segment.t_start.rescale(plotting_time_unit),
|
|
|
+ trial_segment.t_stop.rescale(plotting_time_unit))
|
|
|
ax4.xaxis.set_major_locator(ticker.MultipleLocator(base=1))
|
|
|
|
|
|
|
|
@@ -565,7 +559,8 @@ ax4.text(timebar_xmin + 0.25 * pq.s, timebar_ypos + timebar_labeloffset,
|
|
|
# PLOT BEHAVIORAL SIGNALS of chosen trial
|
|
|
# =============================================================================
|
|
|
# get behavioral signals
|
|
|
-ainp_signals = [nsig for nsig in trial_seg_lfp.analogsignals if
|
|
|
+# TODO: Adjust this to merged analogsignals
|
|
|
+ainp_signals = [nsig for nsig in trial_segment.analogsignals if
|
|
|
nsig.annotations['channel_id'] > 96]
|
|
|
|
|
|
ainp_trialz = [nsig for nsig in trialz_seg_lfp.analogsignals if
|