|
@@ -33,19 +33,15 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
"""
|
|
|
|
|
|
-# This loads the Neo and odML libraries shipped with this code. For production
|
|
|
-# use, please use the newest releases of odML and Neo.
|
|
|
-import load_local_neo_odml_elephant
|
|
|
-
|
|
|
import os
|
|
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
from matplotlib import gridspec, transforms
|
|
|
|
|
|
-import quantities as pq
|
|
|
import numpy as np
|
|
|
+import quantities as pq
|
|
|
|
|
|
-from neo import (AnalogSignal, SpikeTrain)
|
|
|
+from neo import SpikeTrain
|
|
|
from neo.utils import *
|
|
|
from reachgraspio import reachgraspio
|
|
|
|
|
@@ -83,8 +79,8 @@ chosen_events = ['TS-ON', 'WS-ON', 'CUE-ON', 'CUE-OFF', 'GO-ON', 'SR-ON',
|
|
|
# Load data and metadata for a monkey
|
|
|
# =============================================================================
|
|
|
# CHANGE this parameter to load data of the different monkeys
|
|
|
-# monkey = 'Nikos2'
|
|
|
-monkey = 'Lilou'
|
|
|
+monkey = 'Nikos2'
|
|
|
+# monkey = 'Lilou'
|
|
|
|
|
|
datafile = get_monkey_datafile(monkey)
|
|
|
|
|
@@ -94,11 +90,6 @@ session = reachgraspio.ReachGraspIO(
|
|
|
verbose=False)
|
|
|
|
|
|
bl = session.read_block(lazy=True)
|
|
|
- # channels=chosen_els[monkey],
|
|
|
- # units=[1], # loading only unit_id 1
|
|
|
- # load_waveforms=False,
|
|
|
- # load_events=True,
|
|
|
- # scaling='voltage')
|
|
|
|
|
|
seg = bl.segments[0]
|
|
|
|
|
@@ -138,10 +129,10 @@ seg.spiketrains = seg.filter(targdict={'unit_id': chosen_unit},
|
|
|
seg.analogsignals = seg.filter(targdict={'neural_signal': True},
|
|
|
objects='AnalogSignalProxy')
|
|
|
|
|
|
-# use most raw data if multiple versions are present
|
|
|
+# use prefiltered data if multiple versions are present
|
|
|
raw_signal = seg.analogsignals[0]
|
|
|
for sig in seg.analogsignals:
|
|
|
- if sig.sampling_rate > raw_signal.sampling_rate:
|
|
|
+ if sig.sampling_rate < raw_signal.sampling_rate:
|
|
|
raw_signal = sig
|
|
|
seg.analogsignals = [raw_signal]
|
|
|
|
|
@@ -150,7 +141,8 @@ seg.analogsignals = [raw_signal]
|
|
|
seg = load_segment(seg, load_wavefroms=True)
|
|
|
|
|
|
# only keep the chosen electrode signal in the AnalogSignal object
|
|
|
-mask = np.isin(seg.analogsignals[0].array_annotations['channel_ids'], chosen_els[monkey])
|
|
|
+mask = np.isin(np.asarray(seg.analogsignals[0].array_annotations['channel_ids'], dtype=int),
|
|
|
+ chosen_els[monkey])
|
|
|
|
|
|
seg.analogsignals[0] = seg.analogsignals[0][:, mask]
|
|
|
|
|
@@ -256,7 +248,8 @@ selected_trial = cut_segments[trial_index]
|
|
|
for el_idx, electrode_id in enumerate(chosen_els[monkey]):
|
|
|
|
|
|
# PLOT ANALOGSIGNALS in upper plot
|
|
|
- chosen_el_idx = np.where(cut_segments[0].analogsignals[0].array_annotations['channel_ids'] == electrode_id)[0][0]
|
|
|
+ chids = np.asarray(cut_segments[0].analogsignals[0].array_annotations['channel_ids'], dtype=int)
|
|
|
+ chosen_el_idx = np.where(chids == electrode_id)[0][0]
|
|
|
anasig = selected_trial.analogsignals[0][:, chosen_el_idx]
|
|
|
ax1.plot(anasig.times.rescale(time_unit),
|
|
|
np.asarray(anasig.rescale(lfp_unit))
|
|
@@ -309,7 +302,8 @@ ax3.set_xlabel('time [%s]' % time_unit, fontdict=fontdict_axis)
|
|
|
|
|
|
|
|
|
# plot data for each chosen trial
|
|
|
-chosen_el_idx = np.where(cut_segments[0].analogsignals[0].array_annotations['channel_ids'] == chosen_el[monkey])[0][0]
|
|
|
+chids = np.asarray(cut_segments[0].analogsignals[0].array_annotations['channel_ids'], dtype=int)
|
|
|
+chosen_el_idx = np.where(chids == chosen_el[monkey])[0][0]
|
|
|
for trial_idx, trial_id in enumerate(trial_indexes):
|
|
|
trial_spikes = cut_segments[trial_id].filter(channel_id=chosen_el[monkey], objects='SpikeTrain')
|
|
|
trial_type = cut_segments[trial_id].annotations['trialtype']
|