Skip to content

Commit

Permalink
adding more gui stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
carsen-stringer committed Jul 27, 2023
1 parent 141a14e commit f70fcc9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
26 changes: 18 additions & 8 deletions rastermap/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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):
Expand All @@ -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:
Expand Down
5 changes: 1 addition & 4 deletions rastermap/gui/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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

Expand Down

0 comments on commit f70fcc9

Please sign in to comment.