Skip to content

Commit 8445b75

Browse files
committed
change to scatter (a bit quicker but still slow)
1 parent c4c4ef1 commit 8445b75

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

atlaselectrophysiology/ephys_atlas_gui.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from atlaselectrophysiology.create_overview_plots import make_overview_plot
1313
from pathlib import Path
1414
import os
15-
15+
import time
1616

1717
class MainWindow(QtWidgets.QMainWindow, ephys_gui.Setup):
1818
def __init__(self, offline=False, probe_id=None, one=None):
@@ -867,9 +867,12 @@ def plot_scatter(self, data):
867867
[self.fig_img_cb.removeItem(cbar) for cbar in self.img_cbars]
868868
self.img_plots = []
869869
self.img_cbars = []
870+
start = time.time()
870871
connect = np.zeros(data['x'].size, dtype=int)
871872
size = data['size'].tolist()
872873
symbol = data['symbol'].tolist()
874+
end = time.time()
875+
print(end-start)
873876

874877
color_bar = cb.ColorBar(data['cmap'])
875878
cbar = color_bar.makeColourBar(20, 5, self.fig_img_cb, min=np.min(data['levels'][0]),
@@ -878,13 +881,22 @@ def plot_scatter(self, data):
878881
self.img_cbars.append(cbar)
879882

880883
if type(np.any(data['colours'])) == QtGui.QColor:
884+
start = time.time()
881885
brush = data['colours'].tolist()
886+
end = time.time()
887+
print(end-start)
882888
else:
883889
brush = color_bar.map.mapToQColor(data['colours'])
884890

885-
plot = pg.PlotDataItem()
886-
plot.setData(x=data['x'], y=data['y'], connect=connect,
887-
symbol=symbol, symbolSize=size, symbolBrush=brush, symbolPen=data['pen'])
891+
#plot = pg.PlotDataItem()
892+
#plot.setData(x=data['x'], y=data['y'], connect=connect,
893+
# symbol=symbol, symbolSize=size, symbolBrush=brush, symbolPen=data['pen'])
894+
plot = pg.ScatterPlotItem()
895+
start = time.time()
896+
plot.setData(x=data['x'], y=data['y'],
897+
symbol=symbol, size=size, brush=brush, pen=data['pen'])
898+
end = time.time()
899+
print(end - start)
888900
self.fig_img.addItem(plot)
889901
self.fig_img.setXRange(min=data['xrange'][0], max=data['xrange'][1],
890902
padding=0)
@@ -898,7 +910,8 @@ def plot_scatter(self, data):
898910

899911
if data['cluster']:
900912
self.data = data['x']
901-
self.data_plot.sigPointsClicked.connect(self.cluster_clicked)
913+
#self.data_plot.sigPointsClicked.connect(self.cluster_clicked)
914+
self.data_plot.sigClicked.connect(self.cluster_clicked)
902915

903916
def plot_line(self, data):
904917
"""

0 commit comments

Comments
 (0)