From f70fcc99cd59b891369f7868ea7b4315e1748ef9 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Jul 2023 18:33:50 -0400 Subject: [PATCH] adding more gui stuff --- rastermap/gui/gui.py | 26 ++++++++++++++++++-------- rastermap/gui/io.py | 5 +---- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/rastermap/gui/gui.py b/rastermap/gui/gui.py index 6cb9ce9..e02c111 100644 --- a/rastermap/gui/gui.py +++ b/rastermap/gui/gui.py @@ -145,7 +145,7 @@ def __init__(self, filename=None, proc=False): # Add slider for saturation self.sat = [30., 70.] self.sat_slider = QRangeSlider(Horizontal) - self.sat_slider.setRange(0., 200.) + self.sat_slider.setRange(0., 100.) self.sat_slider.setTickPosition(QtW.QSlider.TickPosition.TicksAbove) self.sat_slider.valueChanged.connect(self.sat_changed) self.sat_slider.setValue((self.sat[0], self.sat[1])) @@ -290,9 +290,16 @@ def dragEnterEvent(self, event): def dropEvent(self, event): files = [u.toLocalFile() for u in event.mimeData().urls()] - ext = os.path.splitext(files[0])[-1] + file = files[0] + file0, ext = os.path.splitext(file) + proc_file = file0 + "_embedding.npy" if ext == ".npy" or ext == ".mat" or ext==".npz": - io.load_mat(self, name=files[0]) + if file[-14:] == "_embedding.npy": + io.load_proc(self, name=files[0]) + elif os.path.exists(proc_file): + io.load_proc(self, name=proc_file) + else: + io.load_mat(self, name=files[0]) else: print("ERROR: must drag and drop *.npy, *.npz, or *.mat files") @@ -451,8 +458,8 @@ def smooth_activity(self): (nn, N, -1)).mean(axis=1) self.sp_smoothed = (Usv_ds / self.sv) @ self.Vsv.T self.sp_smoothed = zscore(self.sp_smoothed, axis=1) - self.sp_smoothed = np.maximum(-4, np.minimum(8, self.sp_smoothed)) + 4 - self.sp_smoothed /= 12 + self.sp_smoothed = np.maximum(-2, np.minimum(5, self.sp_smoothed)) + 2 + self.sp_smoothed /= 7 else: self.sp_smoothed = self.sp.copy() self.nsmooth = self.sp_smoothed.shape[0] @@ -591,11 +598,13 @@ def plot_neuron_pos(self, init=False, roi_id=None): self.update_status_bar("ERROR: please upload neuron position data") def plot_scatter(self, x, y, roi_id=None, iplane=0): + subsample = 1 if self.all_neurons_checkBox.isChecked() and roi_id is None: colors = colormaps.gist_ncar[np.linspace( 0, 254, len(x)).astype("int")][self.sorting] - brushes = [pg.mkBrush(color=c) for c in colors] - self.scatter_plots[iplane][0].setData(x, y, symbol="o", size=3, + brushes = [pg.mkBrush(color=c) for c in colors[::subsample]] + self.scatter_plots[iplane][0].setData(x[::subsample], y[::subsample], + symbol="o", size=3, brush=brushes, hoverable=True) for i in range(1, nclust_max + 1): @@ -610,7 +619,8 @@ def plot_scatter(self, x, y, roi_id=None, iplane=0): if roi_id < len(self.cluster_rois): selected = self.neurons_selected(self.cluster_slices[roi_id]) self.scatter_plots[iplane][roi_id + 1].setData( - x[selected], y[selected], symbol="o", size=3, + x[selected][::subsample], y[selected][::subsample], + symbol="o", size=3, brush=pg.mkBrush(color=self.colors[roi_id][:3]), hoverable=True) else: diff --git a/rastermap/gui/io.py b/rastermap/gui/io.py index 6f15e60..dcdff58 100644 --- a/rastermap/gui/io.py +++ b/rastermap/gui/io.py @@ -350,9 +350,6 @@ def load_proc(parent, name=None): isort = parent.proc["isort"] y = parent.proc["embedding"] - Usv = parent.proc["Usv"] - Vsv = parent.proc["Vsv"] - sv = parent.proc["sv"] ops = parent.proc["ops"] user_clusters = parent.proc.get("user_clusters", None) @@ -369,11 +366,11 @@ def load_proc(parent, name=None): parent.smooth_bin = user_clusters[0]["binsize"] parent.smooth.setText(str(int(parent.smooth_bin))) + print(f"using sorting from {name}") parent.embedding = y parent.sorting = isort parent.Usv = Usv #if parent.Usv is None else parent.Usv parent.Vsv = Vsv #if parent.Vsv is None else parent.Vsv - parent.sv = sv #if parent.sv is None else parent.sv parent.ops = ops parent.user_clusters = user_clusters