Skip to content

Commit

Permalink
bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ramintoosi committed Jul 16, 2023
1 parent 2ba5f7c commit a91ab20
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
28 changes: 18 additions & 10 deletions ross_ui/controller/mainWindow.py
Expand Up @@ -729,14 +729,18 @@ def onPlotClusterWave(self):

def onPlotLiveTime(self):
try:
number_of_clusters = self.number_of_clusters
clus_un = np.unique(self.clusters_tmp)
number_of_clusters = len(clus_un)
colors = self.colors
spike_clustered_time = dict()
for i in range(number_of_clusters):
spike_clustered_time[i] = self.spike_time[self.clusters == i]
for i in clus_un:
if i == -1:
number_of_clusters -= 1
continue
spike_clustered_time[i] = self.spike_time[self.clusters_tmp == i]

figure = MatPlotFigures('LiveTime', number_of_clusters, width=10, height=6, dpi=100)
for i, ax in enumerate(figure.axes):
for i, ax in zip(spike_clustered_time, figure.axes):
ax.hist(spike_clustered_time[i], bins=100, color=tuple(colors[i] / 255))
ax.set_title('Cluster {}'.format(i + 1))
plt.tight_layout()
Expand All @@ -745,21 +749,25 @@ def onPlotLiveTime(self):
except:
print(traceback.format_exc())

def onPlotIsi(self):
def onPlotISI(self):
try:
number_of_clusters = self.number_of_clusters
clus_un = np.unique(self.clusters_tmp)
number_of_clusters = len(clus_un)
colors = self.colors
spike_clustered_time = dict()
spike_clustered_delta = dict()
for i in range(number_of_clusters):
spike_clustered_time[i] = self.spike_time[self.clusters == i]
for i in clus_un:
if i == -1:
number_of_clusters -= 1
continue
spike_clustered_time[i] = self.spike_time[self.clusters_tmp == i]
tmp2 = spike_clustered_time[i][:len(spike_clustered_time[i]) - 1].copy()
tmp1 = spike_clustered_time[i][1:].copy()
spike_clustered_delta[i] = tmp1 - tmp2

figure = MatPlotFigures('ISI', number_of_clusters, width=10, height=6, dpi=100)

for i, ax in enumerate(figure.axes):
for i, ax in zip(spike_clustered_delta, figure.axes):
gamma = stats.gamma
x = np.linspace(0, np.max(spike_clustered_delta[i]), 100)
param = gamma.fit(spike_clustered_delta[i], floc=0)
Expand All @@ -775,7 +783,7 @@ def onPlotIsi(self):
plt.show()

except:
pass
print(traceback.format_exc())

def onPlot3d(self):
# self.subwindow_3d.setVisible(self.plot3dAct.isChecked())
Expand Down
7 changes: 6 additions & 1 deletion ross_ui/controller/signin.py
@@ -1,4 +1,5 @@
from PyQt5 import QtWidgets
import requests

from model.api import API
from view.signin import Signin_Dialog
Expand All @@ -15,7 +16,11 @@ def accept_in(self):
username = self.textEdit_username.text()
password = self.textEdit_password.text()
self.user = API(self.url)
res = self.user.sign_in(username, password)
try:
res = self.user.sign_in(username, password)
except requests.exceptions.ConnectionError as e:
QtWidgets.QMessageBox.critical(self, "Connection Error", str(e))
return None
if res['stat']:
super().accept()
else:
Expand Down
6 changes: 5 additions & 1 deletion ross_ui/view/exportResults.py
Expand Up @@ -30,12 +30,16 @@ def __init__(self):
groupboxradio.setLayout(hboxradio)

self.radioPickle = QtWidgets.QRadioButton("pickle")
self.radioMat = QtWidgets.QRadioButton("mat")
self.radioMat = QtWidgets.QRadioButton("MAT")
self.radioCSV = QtWidgets.QRadioButton("CSV")
self.radioJSON = QtWidgets.QRadioButton("JSON")

self.radioPickle.setChecked(True)

hboxradio.addWidget(self.radioPickle)
hboxradio.addWidget(self.radioMat)
hboxradio.addWidget(self.radioCSV)
hboxradio.addWidget(self.radioJSON)

hboxpush = QtWidgets.QHBoxLayout()
self.pushExport = QtWidgets.QPushButton("Export")
Expand Down
2 changes: 1 addition & 1 deletion ross_ui/view/mainWindow.py
Expand Up @@ -284,7 +284,7 @@ def createActions(self):
# self.isiAct.setCheckable(True)
# self.isiAct.setChecked(False)
self.isiAct.setStatusTip(self.tr("Plotting Inter Spike Interval Histogram"))
self.isiAct.triggered.connect(self.onPlotIsi)
self.isiAct.triggered.connect(self.onPlotISI)

self.plot3dAct = QtWidgets.QAction(self.tr("&3D Plot"))
# self.plot3dAct.setCheckable(True)
Expand Down

0 comments on commit a91ab20

Please sign in to comment.