INM-6 / swan

Swan (Sequential Waveform Analyzer) is an open-source graphical tool for tracking single units across multiple sessions of electrophysiological data that was recorded using chronically implanted microelectrode arrays.
BSD 3-Clause "New" or "Revised" License
5 stars 2 forks source link

Program crashes when loading files with different wave form sizes #3

Closed mdenker closed 3 years ago

mdenker commented 5 years ago

The number of samples per waveform can be set by the Blackrock recording software. Typical values could be 38 or 48 samples (in the 1/30000 s time resolution). SWAN however, does not check for this and crashes when trying to plot waveforms of different dimensions, e.g., the mean wave form plot exits with

Traceback (most recent call last):
  File "/home/denker/Projects/swan/swan/src/main.py", line 763, in refresh_views
    self.ui.view_1.do_plot(vum, data)
  File "/home/denker/Projects/swan/swan/src/pgwidget2d.py", line 127, in do_plot
    self.plotMean(x = xs, y = datas.rescale(V), color = col, name = "{}{}".format(i, j), clickable = True)
  File "/home/denker/Projects/swan/swan/src/pgwidget2d.py", line 73, in plotMean
    self._means.append(self.makePlot(x = x, y = y, color = color, name = name, clickable = clickable))
  File "/home/denker/Projects/swan/swan/src/mypgwidget.py", line 269, in makePlot
    *args, **kwargs)
  File "/home/denker/anaconda/envs/swan/lib/python3.6/site-packages/pyqtgraph/graphicsItems/PlotDataItem.py", line 177, in __init__
    self.setData(*args, **kargs)
  File "/home/denker/anaconda/envs/swan/lib/python3.6/site-packages/pyqtgraph/graphicsItems/PlotDataItem.py", line 461, in setData
    self.updateItems()
  File "/home/denker/anaconda/envs/swan/lib/python3.6/site-packages/pyqtgraph/graphicsItems/PlotDataItem.py", line 487, in updateItems
    self.curve.setData(x=x, y=y, **curveArgs)
  File "/home/denker/anaconda/envs/swan/lib/python3.6/site-packages/pyqtgraph/graphicsItems/PlotCurveItem.py", line 307, in setData
    self.updateData(*args, **kargs)
  File "/home/denker/anaconda/envs/swan/lib/python3.6/site-packages/pyqtgraph/graphicsItems/PlotCurveItem.py", line 353, in updateData
    raise Exception("X and Y arrays must be the same shape--got %s and %s." % (self.xData.shape, self.yData.shape))
Exception: X and Y arrays must be the same shape--got (38,) and (48,).
Aborted (core dumped)

The easiest solution would be to throw an error when trying to load files with incompatible waveform sizes.

shashwatsridhar commented 5 years ago

So, to be clear, the waveform sizes differed across different experimental sessions, or within different spiketrains in one session? I would then accordingly check if waveforms in different sessions have different lengths, or if the waveforms for different spiketrains within one session are different.

mdenker commented 3 years ago

SWAN should throw an error for now. Probably this should be done Neodata.py. @shashwatsridhar please check if you fixed this already.

mdenker commented 3 years ago

Fixed for 0.2.x branch. Todo: Backport to 0.1.0.

shashwatsridhar commented 3 years ago

Backported to 0.1.0 with PR #38. Closing this issue.