|
34 | 34 | import time as sysTime |
35 | 35 | from copy import deepcopy |
36 | 36 | import glob |
| 37 | +import pickle |
37 | 38 | from patchview.utilitis.linecollection_update import FigureUpdater |
38 | 39 | from patchview.utilitis.debugHelpers import debugInfo |
39 | 40 | from patchview.utilitis.AnalysisMethods import ( |
@@ -1762,7 +1763,7 @@ def event_pd_stateChange(self, param, changes): |
1762 | 1763 | df.to_csv(f, header=True, line_terminator="\n") |
1763 | 1764 |
|
1764 | 1765 | def exportFile(self, title=None, defaultName=None, extension="all files (*.*)"): |
1765 | | - fileName = QtGui.QFileDialog.getSaveFileName( |
| 1766 | + fileName = QtWidgets.QFileDialog.getSaveFileName( |
1766 | 1767 | None, title, defaultName, extension |
1767 | 1768 | ) |
1768 | 1769 | if isinstance(fileName, tuple): |
@@ -3715,7 +3716,7 @@ def save_clicked(self): |
3715 | 3716 |
|
3716 | 3717 | def saveSingleSeries(self, sel): |
3717 | 3718 | fileName = self.getSaveFileName() |
3718 | | - import pickle |
| 3719 | + |
3719 | 3720 |
|
3720 | 3721 | if fileName != "": |
3721 | 3722 | self.statusBar.showMessage("Saving " + fileName[:-4], 3000) |
@@ -4169,7 +4170,8 @@ def getEphyFeatures(self): |
4169 | 4170 | baseline_interval=baseline_interval1, |
4170 | 4171 | baseline_detect_thresh=baseline_detect_thresh1, |
4171 | 4172 | ) |
4172 | | - |
| 4173 | + self.ephyFpObjectList = {} |
| 4174 | + self.ephyFpObjectList[self.currentPulseTree.dat_file[:-4]] = self.EphyFeaturesObj |
4173 | 4175 | # fileName = self.currentPulseTree.dat_file[:-4]+'_Series' + str(sel.index[1]+1) + '_'+ sel.node.Label+'_PvSpikeFeatures.pdf' |
4174 | 4176 | self.plot_splitter.setStretchFactor(1, 3) |
4175 | 4177 | self.topPlot_splitter.setStretchFactor(1, 1) |
@@ -4529,6 +4531,7 @@ def checkEvent_action_clicked(self): |
4529 | 4531 |
|
4530 | 4532 | def checkFP_action_clicked(self): |
4531 | 4533 | # debugInfo('', True) |
| 4534 | + self.ephyFpObjectList = {} |
4532 | 4535 | self.visulization_view.setCurrentIndex(1) |
4533 | 4536 | ( |
4534 | 4537 | bundleFiles, |
@@ -4556,7 +4559,7 @@ def checkFP_action_clicked(self): |
4556 | 4559 | pars = self.splitViewTab_FP.getParTreePars( |
4557 | 4560 | "Data selection" |
4558 | 4561 | ) # self.fpParTree_data_view.p |
4559 | | - |
| 4562 | + |
4560 | 4563 | for file_idx, bundle in enumerate(bundleFiles): |
4561 | 4564 | sel = serieIndex[file_idx] |
4562 | 4565 | stimChanIndex = stimChanLabels[file_idx] |
@@ -4633,7 +4636,7 @@ def checkFP_action_clicked(self): |
4633 | 4636 | ) |
4634 | 4637 |
|
4635 | 4638 | self.updateEphyTable(sw, self.splitViewTab_FP.tables["Sweep features"], ephObj.title) |
4636 | | - |
| 4639 | + self.ephyFpObjectList[cellName] = ephObj |
4637 | 4640 | print(cellName, "done!") |
4638 | 4641 | # except: |
4639 | 4642 | # print(cellName, 'failed!') |
@@ -7238,6 +7241,7 @@ def plot_dvdt_v_phasePlot(self, v_spike, dvdt_spike, sweepNumber, plotWidget): |
7238 | 7241 | + str(v_spike.shape[1]) |
7239 | 7242 | ) |
7240 | 7243 | return plt |
| 7244 | + |
7241 | 7245 | def plot_alignedSpikes_SingleTrace_NWB(self, stim, data): |
7242 | 7246 | ## TODO: make use of cached analysis data |
7243 | 7247 | pass |
@@ -8037,7 +8041,24 @@ def spike_detection_event(self, param, changes): |
8037 | 8041 | ) |
8038 | 8042 | ) |
8039 | 8043 | self.showdialog(f"{seriesName} saved!") |
| 8044 | + elif childName == "Aligned spike list": |
| 8045 | + if hasattr(self, "ephyFpObjectList") and len(self.ephyFpObjectList)>0: |
| 8046 | + df = {} |
| 8047 | + for ephyFpObject in self.ephyFpObjectList: |
| 8048 | + eobj = self.ephyFpObjectList[ephyFpObject] |
| 8049 | + eobj.alignSpikes() |
| 8050 | + ## convert a dictionary with key as sweep number and value as a list of spike times |
| 8051 | + ## to a dataframe with columns as sweep number and rows as spike times |
| 8052 | + df[ephyFpObject] = eobj.spikeList |
8040 | 8053 |
|
| 8054 | + fileName = self.exportFile( |
| 8055 | + title="Save spike waveforms", |
| 8056 | + defaultName="Aligned_spike_list.pickle", |
| 8057 | + extension="Pickle files (*.pickle)", |
| 8058 | + ) |
| 8059 | + if fileName != []: |
| 8060 | + with open(fileName, "wb") as fd: |
| 8061 | + pickle.dump(df, fd) |
8041 | 8062 | def main(app): |
8042 | 8063 | main = MainWindow(app) |
8043 | 8064 | main.mainFrame.show() |
|
0 commit comments