Skip to content

Commit daf7b81

Browse files
committed
fix: separate screen and display buffer for substract offset feature lfp viewer
1 parent 24e4db0 commit daf7b81

4 files changed

Lines changed: 28 additions & 7 deletions

File tree

Plugins/LfpDisplayNode/LfpChannelDisplay.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ void LfpChannelDisplay::pxPaint()
243243
double a = (canvasSplit->getYCoordMax(chan, index)/range*channelHeightFloat);
244244
double b = (canvasSplit->getYCoordMin(chan, index)/range*channelHeightFloat);
245245

246-
double mean = (canvasSplit->getMean(chan)/range*channelHeightFloat);
246+
double mean = (canvasSplit->getScreenBufferMean(chan)/range*channelHeightFloat);
247247

248248
if (drawWithOffsetCorrection)
249249
{
@@ -508,7 +508,7 @@ void LfpChannelDisplay::pxPaintHistory(int playhead, int rightEdge, int maxScree
508508
double a = (canvasSplit->getYCoordMax(chan, index) / range * channelHeightFloat);
509509
double b = (canvasSplit->getYCoordMin(chan, index) / range * channelHeightFloat);
510510

511-
double mean = (canvasSplit->getMean(chan) / range * channelHeightFloat);
511+
double mean = (canvasSplit->getScreenBufferMean(chan) / range * channelHeightFloat);
512512

513513
if (drawWithOffsetCorrection)
514514
{

Plugins/LfpDisplayNode/LfpChannelDisplayInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ void LfpChannelDisplayInfo::paint(Graphics& g)
247247

248248
g.setColour(Colours::grey);
249249
g.drawText(String(canvasSplit->getStd(chan)), 5, center+110,41,10,Justification::centred,false);
250-
g.drawText(String(canvasSplit->getMean(chan)), 5, center+60,41,10,Justification::centred,false);
250+
g.drawText(String(canvasSplit->getDisplayBufferMean(chan)), 5, center+60,41,10,Justification::centred,false);
251251

252252
if (x > 0)
253253
{

Plugins/LfpDisplayNode/LfpDisplayCanvas.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,25 @@ uint16 LfpDisplaySplitter::getChannelStreamId(int channel)
15481548
return processor->getContinuousChannel(channel)->getStreamId();
15491549
}
15501550

1551-
float LfpDisplaySplitter::getMean(int chan)
1551+
float LfpDisplaySplitter::getScreenBufferMean(int chan)
1552+
{
1553+
float total = 0.0f;
1554+
float numPts = 0;
1555+
1556+
float sample = 0.0f;
1557+
for (int samp = 0; samp < (lfpDisplay->getWidth() - leftmargin); samp += 10)
1558+
{
1559+
sample = *screenBufferMean->getReadPointer(chan, samp);
1560+
total += sample;
1561+
numPts++;
1562+
}
1563+
1564+
//std::cout << sample << std::endl;
1565+
1566+
return total / numPts;
1567+
}
1568+
1569+
float LfpDisplaySplitter::getDisplayBufferMean(int chan)
15521570
{
15531571
float total = 0.0f;
15541572
float numPts = 0;
@@ -1579,7 +1597,7 @@ float LfpDisplaySplitter::getStd(int chan)
15791597
float std = 0.0f;
15801598
float sample = 0.0f;
15811599

1582-
float mean = getMean(chan);
1600+
float mean = getDisplayBufferMean(chan);
15831601
float numPts = 1;
15841602

15851603
// use 0.1s of sample to compute Mean and Std

Plugins/LfpDisplayNode/LfpDisplayCanvas.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,11 @@ class LfpDisplaySplitter : public Component,
263263
/** Gets the event channel state for a particular sample */
264264
const float getEventState(int samp);
265265

266-
/** Returns the mean of a given channel */
267-
float getMean(int chan);
266+
/** Returns the mean of a given channel, computed from the screen buffer */
267+
float getScreenBufferMean(int chan);
268+
269+
/** Returns the mean of a given channel, computed from the display buffer */
270+
float getDisplayBufferMean(int chan);
268271

269272
/** Returns the standard deviation of a given channnel*/
270273
float getStd(int chan);

0 commit comments

Comments
 (0)