diff --git a/atlaselectrophysiology/alignment_with_easyqc.py b/atlaselectrophysiology/alignment_with_easyqc.py index bcc486e..7db8a04 100644 --- a/atlaselectrophysiology/alignment_with_easyqc.py +++ b/atlaselectrophysiology/alignment_with_easyqc.py @@ -1,7 +1,7 @@ from easyqc.gui import viewseis from ibllib.dsp import voltage from ibllib.ephys import neuropixel -from viewspikes.data import stream, get_ks2 +from viewspikes.data import stream from viewspikes.plots import overlay_spikes import scipy from PyQt5 import QtCore, QtGui @@ -140,12 +140,11 @@ def stream_ap(self, t): sos = scipy.signal.butter(3, 300 / self.ap.fs / 2, btype='highpass', output='sos') butt = scipy.signal.sosfiltfilt(sos, raw) destripe = voltage.destripe(raw, fs=self.ap.fs) - ks2 = get_ks2(raw, dsets, self.loaddata.one) + self.eqc['butterworth'] = viewseis(butt.T, si=1 / self.ap.fs, h=h, t0=t0, title='butt', taxis=0) self.eqc['destripe'] = viewseis(destripe.T, si=1 / self.ap.fs, h=h, t0=t0, title='destr', taxis=0) - self.eqc['ks2'] = viewseis(ks2.T, si=1 / self.ap.fs, h=h, t0=t0, title='ks2', taxis=0) overlay_spikes(self.eqc['butterworth'], self.plotdata.spikes, self.plotdata.clusters, self.plotdata.channels) diff --git a/atlaselectrophysiology/ephys_atlas_gui.py b/atlaselectrophysiology/ephys_atlas_gui.py index 9a46fdf..2350347 100644 --- a/atlaselectrophysiology/ephys_atlas_gui.py +++ b/atlaselectrophysiology/ephys_atlas_gui.py @@ -1273,6 +1273,11 @@ def data_button_pressed(self): self.probe_rfmap, self.rfmap_boundaries = self.plotdata.get_rfmap_data() self.img_stim_data = self.plotdata.get_passive_events() + if not self.offline: + self.img_raw_data = self.plotdata.get_raw_data_image(self.loaddata.probe_id, one=self.loaddata.one) + else: + self.img_raw_data = {} + if self.histology_exists: self.slice_data = self.loaddata.get_slice_images(self.ephysalign.xyz_samples) else: @@ -2113,7 +2118,7 @@ def viewer(probe_id, one=None, histology=False, spike_collection=None, title=Non parser = argparse.ArgumentParser(description='Offline vs online mode') parser.add_argument('-o', '--offline', default=False, required=False, help='Offline mode') - parser.add_argument('-r', '--remote', default=False, required=False, action='store_true', help='Remote mode') + parser.add_argument('-r', '--remote', default=False, required=False, action='store_true', help='Remote mode') parser.add_argument('-i', '--insertion', default=None, required=False, help='Insertion mode') args = parser.parse_args() diff --git a/atlaselectrophysiology/ephys_gui_setup.py b/atlaselectrophysiology/ephys_gui_setup.py index 37af73b..86cd6b9 100644 --- a/atlaselectrophysiology/ephys_gui_setup.py +++ b/atlaselectrophysiology/ephys_gui_setup.py @@ -105,6 +105,14 @@ def init_menubar(self): img_options.addAction(scatter_amp) self.img_options_group.addAction(scatter_amp) + raw_type = list(self.img_raw_data.keys()) + for raw in raw_type: + img = QtWidgets.QAction(raw, self, checkable=True, checked=False) + img.triggered.connect(lambda checked, item=raw: self.plot_image( + self.img_raw_data[item])) + img_options.addAction(img) + self.img_options_group.addAction(img) + stim_type = list(self.img_stim_data.keys()) for stim in stim_type: img = QtWidgets.QAction(stim, self, checkable=True, checked=False) diff --git a/atlaselectrophysiology/example_code.py b/atlaselectrophysiology/example_code.py index 7618439..82a6b00 100644 --- a/atlaselectrophysiology/example_code.py +++ b/atlaselectrophysiology/example_code.py @@ -6,6 +6,3 @@ av = viewer(probe_id, one=one) - - -# To add trials to the window \ No newline at end of file diff --git a/atlaselectrophysiology/plot_data.py b/atlaselectrophysiology/plot_data.py index e4f7c34..27d3e6d 100644 --- a/atlaselectrophysiology/plot_data.py +++ b/atlaselectrophysiology/plot_data.py @@ -3,8 +3,10 @@ import numpy as np import one.alf as alf from brainbox.processing import bincount2D +from brainbox.io.spikeglx import stream from brainbox.population.decode import xcorr from brainbox.task import passive +from ibllib.dsp import voltage import scipy from PyQt5 import QtGui @@ -472,6 +474,38 @@ def median_subtract(a): return data_img, data_probe + # only for IBL sorry + def get_raw_data_image(self, pid, t0=(1000, 2000, 3000), one=None): + + def gain2level(gain): + return 10 ** (gain / 20) * 4 * np.array([-1, 1]) + data_img = dict() + for t in t0: + + sr, t = stream(pid, t, one=one) + raw = sr[:, :-sr.nsync].T + channel_labels, channel_features = voltage.detect_bad_channels(raw, sr.fs) + raw = voltage.destripe(raw, fs=sr.fs, channel_labels=channel_labels) + raw_image = raw[:, int((450 / 1e3) * sr.fs):int((500 / 1e3) * sr.fs)].T + x_range = np.array([0, raw_image.shape[0] - 1]) / sr.fs * 1e3 + levels = gain2level(-90) + xscale = (x_range[1] - x_range[0]) / raw_image.shape[0] + yscale = (self.chn_max - self.chn_min) / raw_image.shape[1] + + data_raw = { + 'img': raw_image, + 'scale': np.array([xscale, yscale]), + 'levels': levels, + 'offset': np.array([0, 0]), + 'cmap': 'bone', + 'xrange': x_range, + 'xaxis': 'Time (ms)', + 'title': 'Power (uV)' + } + data_img[f'Raw data t={t}'] = data_raw + + return data_img + def get_lfp_spectrum_data(self): freq_bands = np.vstack(([0, 4], [4, 10], [10, 30], [30, 80], [80, 200])) data_probe = {}