Skip to content

Commit be8d65f

Browse files
committed
Cache SpikeViewer thresholds as they are set
1 parent c30ac5f commit be8d65f

4 files changed

Lines changed: 28 additions & 10 deletions

File tree

Plugins/BasicSpikeDisplay/SpikeDisplayNode/SpikeDisplayCanvas.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ void SpikeDisplayCanvas::cacheDisplaySettings(int electrode, int channel, double
117117
monitors[electrode] = isMonitored;
118118
}
119119

120+
void SpikeDisplayCanvas::cacheDisplayThreshold(int electrode, int channel, double threshold)
121+
{
122+
thresholds[electrode][channel] = threshold;
123+
}
124+
120125
bool SpikeDisplayCanvas::hasCachedDisplaySettings(int electrode, int channel)
121126
{
122127
return thresholds[electrode].count(channel) > 0;

Plugins/BasicSpikeDisplay/SpikeDisplayNode/SpikeDisplayCanvas.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ class SpikeDisplayCanvas : public Visualizer,
127127

128128
void cacheDisplaySettings(int electrodeIndex, int channelIndex, double threshold, double range, bool isMonitored);
129129

130+
void cacheDisplayThreshold(int electrodeIndex, int channelIndex, double threshold);
131+
130132
bool hasCachedDisplaySettings(int electrodeIndex, int channelIndex);
131133

132134
void invalidateDisplaySettings(int electrodeIndex);

Plugins/BasicSpikeDisplay/SpikeDisplayNode/SpikePlots.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ void SpikePlot::initAxes()
179179

180180
for (int i = 0; i < nWaveAx; i++)
181181
{
182-
WaveAxes* wAx = new WaveAxes(WAVE1 + i);
182+
WaveAxes* wAx = new WaveAxes(canvas, electrodeNumber, WAVE1 + i);
183183
waveAxes.add(wAx);
184184
addAndMakeVisible(wAx);
185185
ranges.add(250.0f); // default range is 250 microvolts
@@ -188,7 +188,7 @@ void SpikePlot::initAxes()
188188
for (int i = 0; i < nProjAx; i++)
189189
{
190190
Projection proj = Projection(int(PROJ1x2) + i);
191-
ProjectionAxes* pAx = new ProjectionAxes(proj);
191+
ProjectionAxes* pAx = new ProjectionAxes(canvas, proj);
192192
projectionAxes.add(pAx);
193193
addAndMakeVisible(pAx);
194194
}
@@ -364,6 +364,7 @@ float SpikePlot::getDisplayThresholdForChannel(int i)
364364

365365
void SpikePlot::setDisplayThresholdForChannel(int i, float thresh)
366366
{
367+
LOGD("Setting threshold for channel ", i, " to ", thresh, "");
367368
waveAxes[i]->setDisplayThreshold(thresh);
368369
}
369370

@@ -446,9 +447,10 @@ void SpikePlot::invertSpikes(bool shouldInvert)
446447
}
447448

448449

449-
GenericAxes::GenericAxes(SpikePlotType type_) :
450-
gotFirstSpike(false),
451-
type(type_)
450+
GenericAxes::GenericAxes(SpikeDisplayCanvas* canvas, SpikePlotType type_) :
451+
canvas(canvas),
452+
type(type_),
453+
gotFirstSpike(false)
452454
{
453455
ylims[0] = 0;
454456
ylims[1] = 1;
@@ -540,7 +542,8 @@ double GenericAxes::ad16ToUv(int x, int gain)
540542
}
541543

542544

543-
WaveAxes::WaveAxes(int channel_) : GenericAxes(WAVE_AXES),
545+
WaveAxes::WaveAxes(SpikeDisplayCanvas* canvas, int electrodeIndex, int channel_) : GenericAxes(canvas, WAVE_AXES),
546+
electrodeIndex(electrodeIndex),
544547
drawGrid(true),
545548
displayThresholdLevel(0.0f),
546549
detectorThresholdLevel(0.0f),
@@ -849,6 +852,10 @@ void WaveAxes::mouseDrag(const MouseEvent& event)
849852
thresholdCoordinator->thresholdChanged(displayThresholdLevel,range);
850853
}
851854

855+
LOGA("Updated threshold for electrode: ", electrodeIndex, "channel: ", channel, " to " + String(displayThresholdLevel));
856+
857+
canvas->cacheDisplayThreshold(electrodeIndex, channel, displayThresholdLevel);
858+
852859
repaint();
853860
}
854861
}
@@ -881,14 +888,15 @@ void WaveAxes::registerThresholdCoordinator(SpikeThresholdCoordinator* stc)
881888

882889
void WaveAxes::setDisplayThreshold(float threshold)
883890
{
891+
884892
displayThresholdLevel = threshold;
885893

886894
repaint();
887895
}
888896

889897
// --------------------------------------------------
890898

891-
ProjectionAxes::ProjectionAxes(Projection proj_) : GenericAxes(PROJECTION_AXES), imageDim(500),
899+
ProjectionAxes::ProjectionAxes(SpikeDisplayCanvas* canvas, Projection proj_) : GenericAxes(canvas, PROJECTION_AXES), imageDim(500),
892900
rangeX(250), rangeY(250), spikesReceivedSinceLastRedraw(0), proj(proj_)
893901
{
894902
projectionImage = Image(Image::RGB, imageDim, imageDim, true);

Plugins/BasicSpikeDisplay/SpikeDisplayNode/SpikePlots.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class GenericAxes : public Component
194194
public:
195195

196196
/** Constructor */
197-
GenericAxes(SpikePlotType type);
197+
GenericAxes(SpikeDisplayCanvas* canvas, SpikePlotType type);
198198

199199
/** Destructor */
200200
virtual ~GenericAxes() { }
@@ -214,6 +214,8 @@ class GenericAxes : public Component
214214
/** Helper function for creating units labels*/
215215
void makeLabel(int val, int gain, bool convert, char* s);
216216

217+
SpikeDisplayCanvas* canvas;
218+
217219
protected:
218220
double xlims[2];
219221
double ylims[2];
@@ -242,7 +244,7 @@ class WaveAxes : public GenericAxes
242244
public:
243245

244246
/** Constructor*/
245-
WaveAxes(int channel);
247+
WaveAxes(SpikeDisplayCanvas* canvas, int electrodeIndex, int channel);
246248

247249
/** Destructor*/
248250
~WaveAxes() {}
@@ -292,6 +294,7 @@ class WaveAxes : public GenericAxes
292294
Colour thresholdColour;
293295
Colour gridColour;
294296

297+
int electrodeIndex;
295298
int channel;
296299

297300
bool drawGrid;
@@ -336,7 +339,7 @@ class ProjectionAxes : public GenericAxes
336339
public:
337340

338341
/** Constructor */
339-
ProjectionAxes(Projection proj);
342+
ProjectionAxes(SpikeDisplayCanvas* canvas, Projection proj);
340343

341344
/** Destructor*/
342345
~ProjectionAxes() { }

0 commit comments

Comments
 (0)